[Lldb-commits] [PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

Gabor Marton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 30 12:32:57 PDT 2019


martong marked 2 inline comments as done.
martong added inline comments.


================
Comment at: lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c:8
     int b;
-} FILE;
+} MYFILE;
 
----------------
In TestCmodules.py we have `import Darwin` and then `expr *fopen("/dev/zero", "w")`. This imports the name `FILE` from the Darwin module. Then when we want `expr *myFile`, the two different definition of the `FILE` structs collides.
This happens because now the lookup finds the existing definition for the `FILE` in the TU associated with the expression evaluator, and that comes from the Darwin module.


================
Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:640
       }
-
-      DeclContext *decl_context_non_const =
----------------
We must remove the below addDeclInternal call, because that may be called from another
addDeclInternal:
```
6  clang::CXXConstructorDecl::isDefaultConstructor() const + 87
7  clang::CXXRecordDecl::addedMember(clang::Decl*) + 803
8  clang::DeclContext::addHiddenDecl(clang::Decl*) + 341
9  clang::DeclContext::addDeclInternal(clang::Decl*) + 29
10 lldb_private::ClangASTSource::FindExternalLexicalDecls(clang::DeclContext const*, llvm::function_ref<bool (clang::Decl::Kind)>, llvm::SmallVectorImpl<clang::Decl*>&) + 3917
11 lldb_private::ClangASTSource::ClangASTSourceProxy::FindExternalLexicalDecls(clang::DeclContext const*, llvm::function_ref<bool (clang::Decl::Kind)>, llvm::SmallVectorImpl<clang::Decl*>&) + 102
12 clang::ExternalASTSource::FindExternalLexicalDecls(clang::DeclContext const*, llvm::SmallVectorImpl<clang::Decl*>&) + 101
13 clang::DeclContext::LoadLexicalDeclsFromExternalStorage() const + 269
14 clang::DeclContext::buildLookup() + 336
15 clang::DeclContext::makeDeclVisibleInContextWithFlags(clang::NamedDecl*, bool, bool) + 403
16 clang::DeclContext::addDeclInternal(clang::Decl*) + 92
17 clang::ASTNodeImporter::VisitFieldDecl(clang::FieldDecl*) + 3851
```
... and at the second call of addDeclInternal we may add an incomplete Decl (CXXConstructorDecl above).
We must always avoid redundant work in lldb which is already handled in Clang::ASTImporter.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61333/new/

https://reviews.llvm.org/D61333





More information about the lldb-commits mailing list