[index] Print and test module import references.
llvm-svn: 262208
This commit is contained in:
parent
a8b51c1e20
commit
113387e08e
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
void ModA_func(void);
|
|
@ -0,0 +1 @@
|
|||
module ModA { header "ModA.h" export * }
|
|
@ -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();
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue