summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CXIndexDataConsumer.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-03-31 20:18:22 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-03-31 20:18:22 +0000
commit66c49f78a35625e6cd5f82af030b5919effb3182 (patch)
treebdb066038adbc95ed613b7ddae2f619d95244cb3 /clang/tools/libclang/CXIndexDataConsumer.cpp
parent6099a4e7d4d190725add90fd471934480b00da5e (diff)
downloadbcm5719-llvm-66c49f78a35625e6cd5f82af030b5919effb3182.tar.gz
bcm5719-llvm-66c49f78a35625e6cd5f82af030b5919effb3182.zip
[index] Fix regression where ObjC method declarations may mistakenly get indexed as definition.
rdar://25372906 llvm-svn: 265042
Diffstat (limited to 'clang/tools/libclang/CXIndexDataConsumer.cpp')
-rw-r--r--clang/tools/libclang/CXIndexDataConsumer.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/clang/tools/libclang/CXIndexDataConsumer.cpp b/clang/tools/libclang/CXIndexDataConsumer.cpp
index bc19d53aeac..3b556d441c7 100644
--- a/clang/tools/libclang/CXIndexDataConsumer.cpp
+++ b/clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -92,7 +92,7 @@ public:
}
bool VisitObjCMethodDecl(const ObjCMethodDecl *D) {
- if (D->getDeclContext() != LexicalDC)
+ if (isa<ObjCImplDecl>(LexicalDC) && !D->isThisDeclarationADefinition())
DataConsumer.handleSynthesizedObjCMethod(D, DeclLoc, LexicalDC);
else
DataConsumer.handleObjCMethod(D);
@@ -191,22 +191,28 @@ bool CXIndexDataConsumer::handleDeclOccurence(const Decl *D,
cast<Decl>(ASTNode.ContainerDC),
getCXTU());
} else {
- const NamedDecl *CursorD = dyn_cast_or_null<NamedDecl>(ASTNode.OrigD);
- if (!CursorD)
- CursorD = ND;
- Cursor = getRefCursor(CursorD, Loc);
+ if (ASTNode.OrigD) {
+ if (auto *OrigND = dyn_cast<NamedDecl>(ASTNode.OrigD))
+ Cursor = getRefCursor(OrigND, Loc);
+ else
+ Cursor = MakeCXCursor(ASTNode.OrigD, CXTU);
+ } else {
+ Cursor = getRefCursor(ND, Loc);
+ }
}
handleReference(ND, Loc, Cursor,
dyn_cast_or_null<NamedDecl>(ASTNode.Parent),
ASTNode.ContainerDC, ASTNode.OrigE, Kind);
} else {
- const DeclContext *DC = nullptr;
- for (const auto &SymRel : Relations) {
- if (SymRel.Roles & (unsigned)SymbolRole::RelationChildOf)
- DC = dyn_cast<DeclContext>(SymRel.RelatedSymbol);
+ const DeclContext *LexicalDC = ASTNode.ContainerDC;
+ if (!LexicalDC) {
+ for (const auto &SymRel : Relations) {
+ if (SymRel.Roles & (unsigned)SymbolRole::RelationChildOf)
+ LexicalDC = dyn_cast<DeclContext>(SymRel.RelatedSymbol);
+ }
}
- IndexingDeclVisitor(*this, Loc, DC).Visit(ASTNode.OrigD);
+ IndexingDeclVisitor(*this, Loc, LexicalDC).Visit(ASTNode.OrigD);
}
return !shouldAbort();
@@ -816,7 +822,7 @@ bool CXIndexDataConsumer::handleSynthesizedObjCMethod(const ObjCMethodDecl *D,
const DeclContext *LexicalDC) {
DeclInfo DInfo(/*isRedeclaration=*/true, /*isDefinition=*/true,
/*isContainer=*/false);
- return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC, LexicalDC);
+ return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC, D->getDeclContext());
}
bool CXIndexDataConsumer::handleObjCProperty(const ObjCPropertyDecl *D) {
OpenPOWER on IntegriCloud