diff options
| author | 2019-01-27 16:42:12 +0000 | |
|---|---|---|
| committer | 2019-01-27 16:42:12 +0000 | |
| commit | b773203fb58f3ef282fb69c832d8710cab5bc82d (patch) | |
| tree | e75913f147570fbd75169647b144df85b88a038c /gnu/llvm/tools/clang/lib/Index/IndexingContext.cpp | |
| parent | tweak errno in previous (diff) | |
| download | wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.tar.xz wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.zip | |
Import LLVM 7.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/Index/IndexingContext.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/Index/IndexingContext.cpp | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/gnu/llvm/tools/clang/lib/Index/IndexingContext.cpp b/gnu/llvm/tools/clang/lib/Index/IndexingContext.cpp index de9fe39df03..333f9dc3091 100644 --- a/gnu/llvm/tools/clang/lib/Index/IndexingContext.cpp +++ b/gnu/llvm/tools/clang/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) { @@ -70,7 +75,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc, if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D)) return true; - + return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations, RefE, RefD, DC); } @@ -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); } |
