diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:52:09 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:52:09 +0000 |
commit | 519fc96c475680de2cc49e7811dbbfadb912cbcc (patch) | |
tree | 310ca684459b7e9ae13c9a3b9abf308b3a634afe /include/clang/Index | |
parent | 2298981669bf3bd63335a4be179bc0f96823a8f4 (diff) |
Notes
Diffstat (limited to 'include/clang/Index')
-rw-r--r-- | include/clang/Index/CodegenNameGenerator.h | 52 | ||||
-rw-r--r-- | include/clang/Index/IndexDataConsumer.h | 16 | ||||
-rw-r--r-- | include/clang/Index/IndexingAction.h | 37 | ||||
-rw-r--r-- | include/clang/Index/IndexingOptions.h | 42 |
4 files changed, 69 insertions, 78 deletions
diff --git a/include/clang/Index/CodegenNameGenerator.h b/include/clang/Index/CodegenNameGenerator.h deleted file mode 100644 index 98b3a5de817af..0000000000000 --- a/include/clang/Index/CodegenNameGenerator.h +++ /dev/null @@ -1,52 +0,0 @@ -//===- CodegenNameGenerator.h - Codegen name generation -------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Determines the name that the symbol will get for code generation. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H -#define LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H - -#include "clang/AST/Mangle.h" -#include "clang/Basic/LLVM.h" -#include <memory> -#include <string> -#include <vector> - -namespace clang { - class ASTContext; - class Decl; - -namespace index { - -class CodegenNameGenerator { -public: - explicit CodegenNameGenerator(ASTContext &Ctx); - ~CodegenNameGenerator(); - - /// \returns true on failure to produce a name for the given decl, false on - /// success. - bool writeName(const Decl *D, raw_ostream &OS); - - /// Version of \c writeName function that returns a string. - std::string getName(const Decl *D); - - /// This can return multiple mangled names when applicable, e.g. for C++ - /// constructors/destructors. - std::vector<std::string> getAllManglings(const Decl *D); - -private: - struct Implementation; - std::unique_ptr<ASTNameGenerator> Impl; -}; - -} // namespace index -} // namespace clang - -#endif // LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H diff --git a/include/clang/Index/IndexDataConsumer.h b/include/clang/Index/IndexDataConsumer.h index bc1d86696df91..72747821bf545 100644 --- a/include/clang/Index/IndexDataConsumer.h +++ b/include/clang/Index/IndexDataConsumer.h @@ -32,7 +32,7 @@ public: const DeclContext *ContainerDC; }; - virtual ~IndexDataConsumer() {} + virtual ~IndexDataConsumer() = default; virtual void initialize(ASTContext &Ctx) {} @@ -41,12 +41,16 @@ public: /// \returns true to continue indexing, or false to abort. virtual bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles, ArrayRef<SymbolRelation> Relations, - SourceLocation Loc, ASTNodeInfo ASTNode); + SourceLocation Loc, ASTNodeInfo ASTNode) { + return true; + } /// \returns true to continue indexing, or false to abort. virtual bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI, SymbolRoleSet Roles, - SourceLocation Loc); + SourceLocation Loc) { + return true; + } /// \returns true to continue indexing, or false to abort. /// @@ -54,8 +58,10 @@ public: /// For "@import MyMod.SubMod", there will be a call for 'MyMod' with the /// 'reference' role, and a call for 'SubMod' with the 'declaration' role. virtual bool handleModuleOccurence(const ImportDecl *ImportD, - const Module *Mod, - SymbolRoleSet Roles, SourceLocation Loc); + const Module *Mod, SymbolRoleSet Roles, + SourceLocation Loc) { + return true; + } virtual void finish() {} }; diff --git a/include/clang/Index/IndexingAction.h b/include/clang/Index/IndexingAction.h index 9756f3c539e65..9ed2a018f1617 100644 --- a/include/clang/Index/IndexingAction.h +++ b/include/clang/Index/IndexingAction.h @@ -9,7 +9,9 @@ #ifndef LLVM_CLANG_INDEX_INDEXINGACTION_H #define LLVM_CLANG_INDEX_INDEXINGACTION_H +#include "clang/AST/ASTConsumer.h" #include "clang/Basic/LLVM.h" +#include "clang/Index/IndexingOptions.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/ArrayRef.h" @@ -17,6 +19,7 @@ namespace clang { class ASTContext; + class ASTConsumer; class ASTReader; class ASTUnit; class Decl; @@ -29,32 +32,24 @@ namespace serialization { namespace index { class IndexDataConsumer; -struct IndexingOptions { - enum class SystemSymbolFilterKind { - None, - DeclarationsOnly, - All, - }; +/// Creates an ASTConsumer that indexes all symbols (macros and AST decls). +std::unique_ptr<ASTConsumer> createIndexingASTConsumer( + std::shared_ptr<IndexDataConsumer> DataConsumer, + const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP, + std::function<bool(const Decl *)> ShouldSkipFunctionBody); - SystemSymbolFilterKind SystemSymbolFilter - = SystemSymbolFilterKind::DeclarationsOnly; - bool IndexFunctionLocals = false; - bool IndexImplicitInstantiation = false; - // Whether to index macro definitions in the Preprocesor when preprocessor - // callback is not available (e.g. after parsing has finished). Note that - // macro references are not available in Proprocessor. - bool IndexMacrosInPreprocessor = false; - // Has no effect if IndexFunctionLocals are false. - bool IndexParametersInDeclarations = false; - bool IndexTemplateParameters = false; -}; +inline std::unique_ptr<ASTConsumer> createIndexingASTConsumer( + std::shared_ptr<IndexDataConsumer> DataConsumer, + const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP) { + return createIndexingASTConsumer( + std::move(DataConsumer), Opts, std::move(PP), + /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; }); +} /// Creates a frontend action that indexes all symbols (macros and AST decls). -/// \param WrappedAction another frontend action to wrap over or null. std::unique_ptr<FrontendAction> createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts, - std::unique_ptr<FrontendAction> WrappedAction); + const IndexingOptions &Opts); /// Recursively indexes all decls in the AST. void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer, diff --git a/include/clang/Index/IndexingOptions.h b/include/clang/Index/IndexingOptions.h new file mode 100644 index 0000000000000..bbfd6e4a72c62 --- /dev/null +++ b/include/clang/Index/IndexingOptions.h @@ -0,0 +1,42 @@ +//===--- IndexingOptions.h - Options for indexing ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_INDEX_INDEXINGOPTIONS_H +#define LLVM_CLANG_INDEX_INDEXINGOPTIONS_H + +#include "clang/Frontend/FrontendOptions.h" +#include <memory> +#include <string> + +namespace clang { +namespace index { + +struct IndexingOptions { + enum class SystemSymbolFilterKind { + None, + DeclarationsOnly, + All, + }; + + SystemSymbolFilterKind SystemSymbolFilter = + SystemSymbolFilterKind::DeclarationsOnly; + bool IndexFunctionLocals = false; + bool IndexImplicitInstantiation = false; + // Whether to index macro definitions in the Preprocesor when preprocessor + // callback is not available (e.g. after parsing has finished). Note that + // macro references are not available in Proprocessor. + bool IndexMacrosInPreprocessor = false; + // Has no effect if IndexFunctionLocals are false. + bool IndexParametersInDeclarations = false; + bool IndexTemplateParameters = false; +}; + +} // namespace index +} // namespace clang + +#endif // LLVM_CLANG_INDEX_INDEXINGOPTIONS_H |