diff options
| author | 2019-06-23 21:36:31 +0000 | |
|---|---|---|
| committer | 2019-06-23 21:36:31 +0000 | |
| commit | 23f101f37937a1bd4a29726cab2f76e0fb038b35 (patch) | |
| tree | f7da7d6b32c2e07114da399150bfa88d72187012 /gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp | |
| parent | sort previous; ok deraadt (diff) | |
| download | wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.tar.xz wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.zip | |
Import LLVM 8.0.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp b/gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp index 16f6c21745e..5cdec4b4528 100644 --- a/gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp +++ b/gnu/llvm/tools/clang/lib/Index/IndexingAction.cpp @@ -37,6 +37,7 @@ bool IndexDataConsumer::handleMacroOccurence(const IdentifierInfo *Name, } bool IndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD, + const Module *Mod, SymbolRoleSet Roles, SourceLocation Loc) { return true; @@ -215,23 +216,41 @@ static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IndexCtx) { Unit.visitLocalTopLevelDecls(&IndexCtx, topLevelDeclVisitor); } +static void indexPreprocessorMacros(const Preprocessor &PP, + IndexDataConsumer &DataConsumer) { + for (const auto &M : PP.macros()) + if (MacroDirective *MD = M.second.getLatest()) + DataConsumer.handleMacroOccurence( + M.first, MD->getMacroInfo(), + static_cast<unsigned>(index::SymbolRole::Definition), + MD->getLocation()); +} + void index::indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer, IndexingOptions Opts) { IndexingContext IndexCtx(Opts, DataConsumer); IndexCtx.setASTContext(Unit.getASTContext()); DataConsumer.initialize(Unit.getASTContext()); DataConsumer.setPreprocessor(Unit.getPreprocessorPtr()); + + if (Opts.IndexMacrosInPreprocessor) + indexPreprocessorMacros(Unit.getPreprocessor(), DataConsumer); indexTranslationUnit(Unit, IndexCtx); DataConsumer.finish(); } -void index::indexTopLevelDecls(ASTContext &Ctx, ArrayRef<const Decl *> Decls, +void index::indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP, + ArrayRef<const Decl *> Decls, IndexDataConsumer &DataConsumer, IndexingOptions Opts) { IndexingContext IndexCtx(Opts, DataConsumer); IndexCtx.setASTContext(Ctx); DataConsumer.initialize(Ctx); + + if (Opts.IndexMacrosInPreprocessor) + indexPreprocessorMacros(PP, DataConsumer); + for (const Decl *D : Decls) IndexCtx.indexTopLevelDecl(D); DataConsumer.finish(); @@ -251,6 +270,9 @@ void index::indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader, IndexCtx.setASTContext(Ctx); DataConsumer.initialize(Ctx); + if (Opts.IndexMacrosInPreprocessor) + indexPreprocessorMacros(Reader.getPreprocessor(), DataConsumer); + for (const Decl *D : Reader.getModuleFileLevelDecls(Mod)) { IndexCtx.indexTopLevelDecl(D); } |
