Skip to content
Snippets Groups Projects
Commit d6c8209f authored by Argyrios Kyrtzidis's avatar Argyrios Kyrtzidis
Browse files

[libclang] Indexing API: make sure we do not try to index local declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144764 91177308-0d34-0410-b5e6-96231b3b80d8
parent c6b4a509
No related branches found
No related tags found
No related merge requests found
...@@ -32,35 +32,18 @@ public: ...@@ -32,35 +32,18 @@ public:
} }
bool VisitDeclRefExpr(DeclRefExpr *E) { bool VisitDeclRefExpr(DeclRefExpr *E) {
const NamedDecl *D = E->getDecl(); IndexCtx.handleReference(E->getDecl(), E->getLocation(), 0, ParentDC, E);
if (!D)
return true;
if (D->getParentFunctionOrMethod())
return true;
IndexCtx.handleReference(D, E->getLocation(), 0, ParentDC, E);
return true; return true;
} }
bool VisitMemberExpr(MemberExpr *E) { bool VisitMemberExpr(MemberExpr *E) {
const NamedDecl *D = E->getMemberDecl(); IndexCtx.handleReference(E->getMemberDecl(), E->getMemberLoc(), 0, ParentDC,
if (!D) E);
return true;
if (D->getParentFunctionOrMethod())
return true;
IndexCtx.handleReference(D, E->getMemberLoc(), 0, ParentDC, E);
return true; return true;
} }
bool VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { bool VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
const NamedDecl *D = E->getDecl(); IndexCtx.handleReference(E->getDecl(), E->getLocation(), 0, ParentDC, E);
if (!D)
return true;
if (D->getParentFunctionOrMethod())
return true;
IndexCtx.handleReference(D, E->getLocation(), 0, ParentDC, E);
return true; return true;
} }
......
...@@ -36,6 +36,8 @@ public: ...@@ -36,6 +36,8 @@ public:
bool VisitTagTypeLoc(TagTypeLoc TL) { bool VisitTagTypeLoc(TagTypeLoc TL) {
TagDecl *D = TL.getDecl(); TagDecl *D = TL.getDecl();
if (D->getParentFunctionOrMethod())
return true;
if (TL.isDefinition()) { if (TL.isDefinition()) {
IndexCtx.indexTagDecl(D); IndexCtx.indexTagDecl(D);
......
...@@ -283,6 +283,10 @@ void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc, ...@@ -283,6 +283,10 @@ void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
const DeclContext *DC, const DeclContext *DC,
const Expr *E, const Expr *E,
CXIdxEntityRefKind Kind) { CXIdxEntityRefKind Kind) {
if (!D)
return;
if (D->getParentFunctionOrMethod())
return;
if (Loc.isInvalid()) if (Loc.isInvalid())
return; return;
if (!CB.indexEntityReference) if (!CB.indexEntityReference)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment