[Lldb-commits] [lldb] 7cfa6e1 - [lldb] Let ClangASTImporter assert that the target AST has an external source

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 25 02:42:45 PST 2021


Author: Raphael Isemann
Date: 2021-02-25T11:42:14+01:00
New Revision: 7cfa6e1cc64bc41e644cfc4a43bc122790896569

URL: https://github.com/llvm/llvm-project/commit/7cfa6e1cc64bc41e644cfc4a43bc122790896569
DIFF: https://github.com/llvm/llvm-project/commit/7cfa6e1cc64bc41e644cfc4a43bc122790896569.diff

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

This prevents people from accidentially using this code outside the
intended setup.

Added: 
    

Modified: 
    lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index f4ea3af8d9b9..79465316dbc2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -198,6 +198,12 @@ class ClangASTImporter {
       // nodes within the same AST doesn't make any sense as the whole idea
       // is to import them to a 
diff erent 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);
     }
 


        


More information about the lldb-commits mailing list