From: Argyrios Kyrtzidis Date: Tue, 9 Feb 2016 19:07:07 +0000 (+0000) Subject: [libclang] indexing: Have the semantic container of synthesized ObjC getter/setter... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08437e9e8855ef9f1e438f4f1dfe6fc93b044ab8;p=clang [libclang] indexing: Have the semantic container of synthesized ObjC getter/setter methods be the implementation decl. Matches the behavior of other ObjC methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260250 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index f7640c63e0..5d944bae1c 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -309,7 +309,8 @@ void IndexingContext::handleDiagnosticSet(CXDiagnostic CXDiagSet) { bool IndexingContext::handleDecl(const NamedDecl *D, SourceLocation Loc, CXCursor Cursor, DeclInfo &DInfo, - const DeclContext *LexicalDC) { + const DeclContext *LexicalDC, + const DeclContext *SemaDC) { if (!CB.indexDeclaration || !D) return false; if (D->isImplicit() && shouldIgnoreIfImplicit(D)) @@ -335,10 +336,12 @@ bool IndexingContext::handleDecl(const NamedDecl *D, DInfo.attributes = DInfo.EntInfo.attributes; DInfo.numAttributes = DInfo.EntInfo.numAttributes; - getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer); + if (!SemaDC) + SemaDC = D->getDeclContext(); + getContainerInfo(SemaDC, DInfo.SemanticContainer); DInfo.semanticContainer = &DInfo.SemanticContainer; - if (LexicalDC == D->getDeclContext()) { + if (LexicalDC == SemaDC) { DInfo.lexicalContainer = &DInfo.SemanticContainer; } else if (isTemplateImplicitInstantiation(D)) { // Implicit instantiations have the lexical context of where they were @@ -598,7 +601,7 @@ bool IndexingContext::handleSynthesizedObjCMethod(const ObjCMethodDecl *D, const DeclContext *LexicalDC) { DeclInfo DInfo(/*isRedeclaration=*/true, /*isDefinition=*/true, /*isContainer=*/false); - return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC); + return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC, LexicalDC); } bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) { diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h index 4da6aebaf6..2b1355ad32 100644 --- a/tools/libclang/IndexingContext.h +++ b/tools/libclang/IndexingContext.h @@ -468,7 +468,8 @@ private: bool handleDecl(const NamedDecl *D, SourceLocation Loc, CXCursor Cursor, DeclInfo &DInfo, - const DeclContext *LexicalDC = nullptr); + const DeclContext *LexicalDC = nullptr, + const DeclContext *SemaDC = nullptr); bool handleObjCContainer(const ObjCContainerDecl *D, SourceLocation Loc, CXCursor Cursor,