aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/IndexingContext.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-09-10 22:58:04 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-09-10 22:58:04 +0000
commit3bed3d196dbb5ad2ea7442da4b6c2fbf6bb5fcc6 (patch)
tree5c363089c186d5caac88a271f9d3af229b574817 /tools/libclang/IndexingContext.cpp
parent57330eed3fbe530cb05996e4a346cc5fc217c0d9 (diff)
[libclang] Do index 'extern' declarations inside functions.
rdar://12257073 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/IndexingContext.cpp')
-rw-r--r--tools/libclang/IndexingContext.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 6e1b04df57..210dc36d52 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -204,6 +204,26 @@ void IndexingContext::setPreprocessor(Preprocessor &PP) {
static_cast<ASTUnit*>(CXTU->TUData)->setPreprocessor(&PP);
}
+bool IndexingContext::isFunctionLocalDecl(const Decl *D) {
+ assert(D);
+
+ if (!D->getParentFunctionOrMethod())
+ return false;
+
+ if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
+ switch (ND->getLinkage()) {
+ case NoLinkage:
+ case InternalLinkage:
+ return true;
+ case UniqueExternalLinkage:
+ case ExternalLinkage:
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool IndexingContext::shouldAbort() {
if (!CB.abortQuery)
return false;
@@ -590,7 +610,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
return false;
if (Loc.isInvalid())
return false;
- if (!shouldIndexFunctionLocalSymbols() && D->getParentFunctionOrMethod())
+ if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalDecl(D))
return false;
if (isNotFromSourceFile(D->getLocation()))
return false;