Use the same alignment for writing and readin .swift_ast section contents.

This fixes a bug that made it impossible to read any subsequent Swift modules
out of a .swift_ast section a previous section had a size divisible by 4.

rdar://problem/57110020
This commit is contained in:
Adrian Prantl
2019-12-04 14:13:21 -08:00
parent 41a116b95a
commit bdc1eec983
5 changed files with 59 additions and 4 deletions

View File

@@ -375,8 +375,8 @@ ValidationInfo serialization::validateSerializedAST(
ValidationInfo result;
// Check 32-bit alignment.
if (data.size() % 4 != 0 ||
reinterpret_cast<uintptr_t>(data.data()) % 4 != 0)
if (data.size() % SWIFTMODULE_ALIGNMENT != 0 ||
reinterpret_cast<uintptr_t>(data.data()) % SWIFTMODULE_ALIGNMENT != 0)
return result;
llvm::BitstreamCursor cursor(data);