summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-02-29 07:56:07 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2016-02-29 07:56:07 +0000
commit113387e08e55e28d0614373e168b5202bc83339a (patch)
tree490ad63b80f576122a754da65bca0b7ea3909fdd /clang
parenta8b51c1e200a8f7f8cb274b5d8d744d94e0fdb59 (diff)
downloadbcm5719-llvm-113387e08e55e28d0614373e168b5202bc83339a.tar.gz
bcm5719-llvm-113387e08e55e28d0614373e168b5202bc83339a.zip
[index] Print and test module import references.
llvm-svn: 262208
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Index/IndexSymbol.cpp3
-rw-r--r--clang/lib/Index/IndexingContext.cpp9
-rw-r--r--clang/test/Index/Core/Inputs/module/ModA.h2
-rw-r--r--clang/test/Index/Core/Inputs/module/module.modulemap1
-rw-r--r--clang/test/Index/Core/index-with-module.m12
-rw-r--r--clang/tools/c-index-test/core_main.cpp20
6 files changed, 45 insertions, 2 deletions
diff --git a/clang/lib/Index/IndexSymbol.cpp b/clang/lib/Index/IndexSymbol.cpp
index 39812c4fe4f..62e2facde19 100644
--- a/clang/lib/Index/IndexSymbol.cpp
+++ b/clang/lib/Index/IndexSymbol.cpp
@@ -53,6 +53,9 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
} else {
switch (D->getKind()) {
+ case Decl::Import:
+ Info.Kind = SymbolKind::Module;
+ break;
case Decl::Typedef:
Info.Kind = SymbolKind::Typedef; break;
case Decl::Function:
diff --git a/clang/lib/Index/IndexingContext.cpp b/clang/lib/Index/IndexingContext.cpp
index 9ac22f85e1d..1645a9ab0bd 100644
--- a/clang/lib/Index/IndexingContext.cpp
+++ b/clang/lib/Index/IndexingContext.cpp
@@ -58,7 +58,12 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
}
bool IndexingContext::importedModule(const ImportDecl *ImportD) {
- SourceLocation Loc = ImportD->getLocation();
+ SourceLocation Loc;
+ auto IdLocs = ImportD->getIdentifierLocs();
+ if (!IdLocs.empty())
+ Loc = IdLocs.front();
+ else
+ Loc = ImportD->getLocation();
SourceManager &SM = Ctx->getSourceManager();
Loc = SM.getFileLoc(Loc);
if (Loc.isInvalid())
@@ -85,7 +90,7 @@ bool IndexingContext::importedModule(const ImportDecl *ImportD) {
}
}
- SymbolRoleSet Roles{};
+ SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
if (ImportD->isImplicit())
Roles |= (unsigned)SymbolRole::Implicit;
diff --git a/clang/test/Index/Core/Inputs/module/ModA.h b/clang/test/Index/Core/Inputs/module/ModA.h
new file mode 100644
index 00000000000..081d86cc451
--- /dev/null
+++ b/clang/test/Index/Core/Inputs/module/ModA.h
@@ -0,0 +1,2 @@
+
+void ModA_func(void);
diff --git a/clang/test/Index/Core/Inputs/module/module.modulemap b/clang/test/Index/Core/Inputs/module/module.modulemap
new file mode 100644
index 00000000000..a132562eafd
--- /dev/null
+++ b/clang/test/Index/Core/Inputs/module/module.modulemap
@@ -0,0 +1 @@
+module ModA { header "ModA.h" export * }
diff --git a/clang/test/Index/Core/index-with-module.m b/clang/test/Index/Core/index-with-module.m
new file mode 100644
index 00000000000..646a48a2c93
--- /dev/null
+++ b/clang/test/Index/Core/index-with-module.m
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t.mcp
+// RUN: c-index-test core -print-source-symbols -- %s -I %S/Inputs/module -fmodules -fmodules-cache-path=%t.mcp | FileCheck %s
+
+// CHECK: [[@LINE+1]]:9 | module/C | ModA | Ref |
+@import ModA;
+// CHECK: [[@LINE+1]]:1 | module/C | ModA | Ref,Impl |
+#include "ModA.h"
+
+void foo() {
+ // CHECK: [[@LINE+1]]:3 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | Ref,Call,RelCall | rel: 1
+ ModA_func();
+} \ No newline at end of file
diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp
index e72b9f93efd..1881e31e207 100644
--- a/clang/tools/c-index-test/core_main.cpp
+++ b/clang/tools/c-index-test/core_main.cpp
@@ -107,6 +107,26 @@ public:
return true;
}
+
+ bool handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles,
+ FileID FID, unsigned Offset) override {
+ ASTContext &Ctx = ImportD->getASTContext();
+ SourceManager &SM = Ctx.getSourceManager();
+
+ unsigned Line = SM.getLineNumber(FID, Offset);
+ unsigned Col = SM.getColumnNumber(FID, Offset);
+ OS << Line << ':' << Col << " | ";
+
+ printSymbolInfo(getSymbolInfo(ImportD), OS);
+ OS << " | ";
+
+ OS << ImportD->getImportedModule()->getFullModuleName() << " | ";
+
+ printSymbolRoles(Roles, OS);
+ OS << " |\n";
+
+ return true;
+ }
};
} // anonymous namespace
OpenPOWER on IntegriCloud