diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h @@ -30,6 +30,9 @@ llvm::function_ref IsKindWeWant, llvm::SmallVectorImpl &Result) override; + bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC, + clang::DeclarationName Name) override; + void CompleteType(clang::TagDecl *tag_decl) override; void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp @@ -10,6 +10,7 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclObjC.h" using namespace lldb_private; @@ -46,6 +47,19 @@ } } +bool ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName( + const clang::DeclContext *DC, clang::DeclarationName Name) { + llvm::SmallVector decls; + // Objective-C methods are not added into the LookupPtr when they originate + // from an external source. SetExternalVisibleDeclsForName() adds them. + if (auto *oid = llvm::dyn_cast(DC)) { + for (auto *omd : oid->methods()) + if (omd->getDeclName() == Name) + decls.push_back(omd); + } + return !SetExternalVisibleDeclsForName(DC, Name, decls).empty(); +} + OptionalClangModuleID ClangExternalASTSourceCallbacks::RegisterModule(clang::Module *module) { m_modules.push_back(module); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -344,6 +344,13 @@ member->setFromASTFile(); member->setOwningModuleID(id.GetValue()); member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible); + if (auto *nd = llvm::dyn_cast(member)) + if (auto *dc = llvm::dyn_cast(parent)) { + dc->setHasExternalVisibleStorage(true); + // This triggers ExternalASTSource::FindExternalVisibleDeclsByName() to be + // called when searching for members. + dc->setHasExternalLexicalStorage(true); + } } char TypeSystemClang::ID; diff --git a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm --- a/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ b/lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -33,14 +33,21 @@ // CHECK-DAG: EnumDecl {{.*}} imported in A {{.*}} Enum_e // FIXME: -EnumConstantDecl {{.*}} imported in A a +@implementation SomeClass { + int private_ivar; +} +@synthesize number = private_ivar; +@end + SomeClass *obj1; // RUN: lldb-test symbols -dump-clang-ast -find type --language=ObjC++ \ // RUN: -compiler-context 'Module:A,Struct:SomeClass' %t.o \ // RUN: | FileCheck %s --check-prefix=CHECK-OBJC // CHECK-OBJC: ObjCInterfaceDecl {{.*}} imported in A SomeClass -// CHECK-OBJC: |-ObjCPropertyDecl {{.*}} imported in A number 'int' readonly -// CHECK-OBJC: | `-getter ObjCMethod {{.*}} 'number' -// CHECK-OBJC: `-ObjCMethodDecl {{.*}} imported in A implicit - number 'int' +// CHECK-OBJC-NEXT: |-ObjCIvarDecl +// CHECK-OBJC-NEXT: |-ObjCMethodDecl 0x[[NUMBER:[0-9a-f]+]]{{.*}} imported in A +// CHECK-OBJC-NEXT: `-ObjCPropertyDecl {{.*}} imported in A number 'int' readonly +// CHECK-OBJC-NEXT: `-getter ObjCMethod 0x[[NUMBER]] 'number' // Template specializations are not yet supported, so they lack the ownership info: Template t2;