Enforce that FileUnit + LoadedFile have trivial destructors

We already do this for other ASTContext-allocated types (see
Decl.cpp). This will prevent the sort of mistakes in the previous two
commits.

Note that if any particular subclass of FileUnit wants to have its
destructor run, it can opt into that manually using
ASTContext::addDestructorCleanup. SourceFile and BuiltinUnit both do
this. But we generally don't /want/ to do this if we can avoid it
because it adds to compiler teardown time.
This commit is contained in:
Jordan Rose
2019-08-23 17:28:02 -07:00
parent 764e2b8ce6
commit 5c785d42b3
7 changed files with 21 additions and 15 deletions

View File

@@ -38,6 +38,9 @@ using namespace swift::serialization;
using namespace llvm::support;
using llvm::Expected;
static_assert(IsTriviallyDestructible<SerializedASTFile>::value,
"SerializedASTFiles are BumpPtrAllocated; d'tors are not called");
static bool checkModuleSignature(llvm::BitstreamCursor &cursor,
ArrayRef<unsigned char> signature) {
for (unsigned char byte : signature)