diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-16 02:35:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-16 02:35:01 +0000 |
commit | d6c8209fd1567db9c2721f441b50cb23cdf8d835 (patch) | |
tree | 6651b627fb5058fd0842c0068c66c1ce84ca8bea | |
parent | c6b4a5099588fd21b49c80f730a596a64b2766c6 (diff) |
[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
-rw-r--r-- | tools/libclang/IndexBody.cpp | 25 | ||||
-rw-r--r-- | tools/libclang/IndexTypeSourceInfo.cpp | 2 | ||||
-rw-r--r-- | tools/libclang/IndexingContext.cpp | 4 |
3 files changed, 10 insertions, 21 deletions
diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp index 769a1c7ae8..ece1ed429c 100644 --- a/tools/libclang/IndexBody.cpp +++ b/tools/libclang/IndexBody.cpp @@ -32,35 +32,18 @@ public: } bool VisitDeclRefExpr(DeclRefExpr *E) { - const NamedDecl *D = E->getDecl(); - if (!D) - return true; - if (D->getParentFunctionOrMethod()) - return true; - - IndexCtx.handleReference(D, E->getLocation(), 0, ParentDC, E); + IndexCtx.handleReference(E->getDecl(), E->getLocation(), 0, ParentDC, E); return true; } bool VisitMemberExpr(MemberExpr *E) { - const NamedDecl *D = E->getMemberDecl(); - if (!D) - return true; - if (D->getParentFunctionOrMethod()) - return true; - - IndexCtx.handleReference(D, E->getMemberLoc(), 0, ParentDC, E); + IndexCtx.handleReference(E->getMemberDecl(), E->getMemberLoc(), 0, ParentDC, + E); return true; } bool VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { - const NamedDecl *D = E->getDecl(); - if (!D) - return true; - if (D->getParentFunctionOrMethod()) - return true; - - IndexCtx.handleReference(D, E->getLocation(), 0, ParentDC, E); + IndexCtx.handleReference(E->getDecl(), E->getLocation(), 0, ParentDC, E); return true; } diff --git a/tools/libclang/IndexTypeSourceInfo.cpp b/tools/libclang/IndexTypeSourceInfo.cpp index b63ebddfb0..5aeee0d263 100644 --- a/tools/libclang/IndexTypeSourceInfo.cpp +++ b/tools/libclang/IndexTypeSourceInfo.cpp @@ -36,6 +36,8 @@ public: bool VisitTagTypeLoc(TagTypeLoc TL) { TagDecl *D = TL.getDecl(); + if (D->getParentFunctionOrMethod()) + return true; if (TL.isDefinition()) { IndexCtx.indexTagDecl(D); diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index 15fcde174d..3ecc560d35 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -283,6 +283,10 @@ void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc, const DeclContext *DC, const Expr *E, CXIdxEntityRefKind Kind) { + if (!D) + return; + if (D->getParentFunctionOrMethod()) + return; if (Loc.isInvalid()) return; if (!CB.indexEntityReference) |