[lldb] Let ClangASTImporter assert that the target AST has an external source

This prevents people from accidentially using this code outside the
intended setup.
This commit is contained in:
Raphael Isemann 2021-02-25 11:28:43 +01:00
parent a54f160b3a
commit 7cfa6e1cc6
1 changed files with 6 additions and 0 deletions

View File

@ -198,6 +198,12 @@ public:
// nodes within the same AST doesn't make any sense as the whole idea
// is to import them to a different AST.
lldbassert(target_ctx != source_ctx && "Can't import into itself");
// This is always doing a minimal import of any declarations. This means
// that there has to be an ExternalASTSource in the target ASTContext
// (that should implement the callbacks that complete any declarations
// on demand). Without an ExternalASTSource, this ASTImporter will just
// do a minimal import and the imported declarations won't be completed.
assert(target_ctx->getExternalSource() && "Missing ExternalSource");
setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
}