From 7cfa6e1cc64bc41e644cfc4a43bc122790896569 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 25 Feb 2021 11:28:43 +0100 Subject: [PATCH] [lldb] Let ClangASTImporter assert that the target AST has an external source This prevents people from accidentially using this code outside the intended setup. --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h index f4ea3af..7946531 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h @@ -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); } -- 2.7.4