summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-28 17:50:39 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-28 17:50:39 +0000
commitf911242f43ae1b0a85c323631fe817df95c9cbe9 (patch)
tree03cd3e316b71ca61e1ba900de00367b40d8d07a9 /tools
parent792db266f3d2f12a7a16bf37d90074f54bca1e6f (diff)
[AST] When we @synthesize a property with a user-defined ivar name,
make sure to record the source location of the ivar name. [libclang] When indexing @synthesized objc methods, report the @implementation as the lexical container. Fixes rdar://10905472 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/libclang/IndexDecl.cpp6
-rw-r--r--tools/libclang/IndexingContext.cpp15
-rw-r--r--tools/libclang/IndexingContext.h6
3 files changed, 18 insertions, 9 deletions
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp
index 2bd71295e6..3f2c8b5710 100644
--- a/tools/libclang/IndexDecl.cpp
+++ b/tools/libclang/IndexDecl.cpp
@@ -216,11 +216,13 @@ public:
if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) {
if (MD->isSynthesized())
- IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
+ IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation(),
+ D->getLexicalDeclContext());
}
if (ObjCMethodDecl *MD = PD->getSetterMethodDecl()) {
if (MD->isSynthesized())
- IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
+ IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation(),
+ D->getLexicalDeclContext());
}
return true;
}
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 6797cc244a..c9150b9a5d 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -257,7 +257,8 @@ void IndexingContext::handleDiagnosticSet(CXDiagnostic CXDiagSet) {
bool IndexingContext::handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
- DeclInfo &DInfo) {
+ DeclInfo &DInfo,
+ const DeclContext *LexicalDC) {
if (!CB.indexDeclaration || !D)
return false;
if (D->isImplicit() && shouldIgnoreIfImplicit(D))
@@ -269,6 +270,9 @@ bool IndexingContext::handleDecl(const NamedDecl *D,
|| Loc.isInvalid())
return false;
+ if (!LexicalDC)
+ LexicalDC = D->getLexicalDeclContext();
+
if (shouldSuppressRefs())
markEntityOccurrenceInFile(D, Loc);
@@ -284,7 +288,7 @@ bool IndexingContext::handleDecl(const NamedDecl *D,
getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer);
DInfo.semanticContainer = &DInfo.SemanticContainer;
- if (D->getLexicalDeclContext() == D->getDeclContext()) {
+ if (LexicalDC == D->getDeclContext()) {
DInfo.lexicalContainer = &DInfo.SemanticContainer;
} else if (isTemplateImplicitInstantiation(D)) {
// Implicit instantiations have the lexical context of where they were
@@ -295,7 +299,7 @@ bool IndexingContext::handleDecl(const NamedDecl *D,
// information anyway.
DInfo.lexicalContainer = &DInfo.SemanticContainer;
} else {
- getContainerInfo(D->getLexicalDeclContext(), DInfo.LexicalContainer);
+ getContainerInfo(LexicalDC, DInfo.LexicalContainer);
DInfo.lexicalContainer = &DInfo.LexicalContainer;
}
@@ -510,10 +514,11 @@ bool IndexingContext::handleSynthesizedObjCProperty(
}
bool IndexingContext::handleSynthesizedObjCMethod(const ObjCMethodDecl *D,
- SourceLocation Loc) {
+ SourceLocation Loc,
+ const DeclContext *LexicalDC) {
DeclInfo DInfo(/*isRedeclaration=*/true, /*isDefinition=*/true,
/*isContainer=*/false);
- return handleDecl(D, Loc, getCursor(D), DInfo);
+ return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC);
}
bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h
index 8463e3fedf..d828b17ca5 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -406,7 +406,8 @@ public:
bool handleObjCMethod(const ObjCMethodDecl *D);
bool handleSynthesizedObjCProperty(const ObjCPropertyImplDecl *D);
- bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc);
+ bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc,
+ const DeclContext *LexicalDC);
bool handleObjCProperty(const ObjCPropertyDecl *D);
@@ -452,7 +453,8 @@ public:
private:
bool handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
- DeclInfo &DInfo);
+ DeclInfo &DInfo,
+ const DeclContext *LexicalDC = 0);
bool handleObjCContainer(const ObjCContainerDecl *D,
SourceLocation Loc, CXCursor Cursor,