aboutsummaryrefslogtreecommitdiff
path: root/lib/Index/IndexingContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Index/IndexingContext.cpp')
-rw-r--r--lib/Index/IndexingContext.cpp57
1 files changed, 36 insertions, 21 deletions
diff --git a/lib/Index/IndexingContext.cpp b/lib/Index/IndexingContext.cpp
index de9fe39df031..80d851b43d73 100644
--- a/lib/Index/IndexingContext.cpp
+++ b/lib/Index/IndexingContext.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "IndexingContext.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Index/IndexDataConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
@@ -36,6 +37,10 @@ bool IndexingContext::shouldIndexFunctionLocalSymbols() const {
return IndexOpts.IndexFunctionLocals;
}
+bool IndexingContext::shouldIndexImplicitInstantiation() const {
+ return IndexOpts.IndexImplicitInstantiation;
+}
+
bool IndexingContext::handleDecl(const Decl *D,
SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations) {
@@ -82,14 +87,9 @@ bool IndexingContext::importedModule(const ImportDecl *ImportD) {
Loc = IdLocs.front();
else
Loc = ImportD->getLocation();
- SourceManager &SM = Ctx->getSourceManager();
- Loc = SM.getFileLoc(Loc);
- if (Loc.isInvalid())
- return true;
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SM.getDecomposedLoc(Loc);
+ SourceManager &SM = Ctx->getSourceManager();
+ FileID FID = SM.getFileID(SM.getFileLoc(Loc));
if (FID.isInvalid())
return true;
@@ -112,7 +112,7 @@ bool IndexingContext::importedModule(const ImportDecl *ImportD) {
if (ImportD->isImplicit())
Roles |= (unsigned)SymbolRole::Implicit;
- return DataConsumer.handleModuleOccurence(ImportD, Roles, FID, Offset);
+ return DataConsumer.handleModuleOccurence(ImportD, Roles, Loc);
}
bool IndexingContext::isTemplateImplicitInstantiation(const Decl *D) {
@@ -295,6 +295,7 @@ static bool shouldReportOccurrenceForSystemDeclOnlyMode(
case SymbolRole::Dynamic:
case SymbolRole::AddressOf:
case SymbolRole::Implicit:
+ case SymbolRole::Undefinition:
case SymbolRole::RelationReceivedBy:
case SymbolRole::RelationCalledBy:
case SymbolRole::RelationContainedBy:
@@ -327,13 +328,7 @@ bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
return true;
SourceManager &SM = Ctx->getSourceManager();
- Loc = SM.getFileLoc(Loc);
- if (Loc.isInvalid())
- return true;
-
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SM.getDecomposedLoc(Loc);
+ FileID FID = SM.getFileID(SM.getFileLoc(Loc));
if (FID.isInvalid())
return true;
@@ -355,6 +350,9 @@ bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
}
}
+ if (!OrigD)
+ OrigD = D;
+
if (isTemplateImplicitInstantiation(D)) {
if (!IsRef)
return true;
@@ -364,9 +362,6 @@ bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
assert(!isTemplateImplicitInstantiation(D));
}
- if (!OrigD)
- OrigD = D;
-
if (IsRef)
Roles |= (unsigned)SymbolRole::Reference;
else if (isDeclADefinition(OrigD, ContainerDC, *Ctx))
@@ -414,7 +409,27 @@ bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
Rel.RelatedSymbol->getCanonicalDecl()));
}
- IndexDataConsumer::ASTNodeInfo Node{ OrigE, OrigD, Parent, ContainerDC };
- return DataConsumer.handleDeclOccurence(D, Roles, FinalRelations, FID, Offset,
- Node);
+ IndexDataConsumer::ASTNodeInfo Node{OrigE, OrigD, Parent, ContainerDC};
+ return DataConsumer.handleDeclOccurence(D, Roles, FinalRelations, Loc, Node);
+}
+
+void IndexingContext::handleMacroDefined(const IdentifierInfo &Name,
+ SourceLocation Loc,
+ const MacroInfo &MI) {
+ SymbolRoleSet Roles = (unsigned)SymbolRole::Definition;
+ DataConsumer.handleMacroOccurence(&Name, &MI, Roles, Loc);
+}
+
+void IndexingContext::handleMacroUndefined(const IdentifierInfo &Name,
+ SourceLocation Loc,
+ const MacroInfo &MI) {
+ SymbolRoleSet Roles = (unsigned)SymbolRole::Undefinition;
+ DataConsumer.handleMacroOccurence(&Name, &MI, Roles, Loc);
+}
+
+void IndexingContext::handleMacroReference(const IdentifierInfo &Name,
+ SourceLocation Loc,
+ const MacroInfo &MI) {
+ SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
+ DataConsumer.handleMacroOccurence(&Name, &MI, Roles, Loc);
}