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 /lib/Index | |
parent | 2298981669bf3bd63335a4be179bc0f96823a8f4 (diff) |
Notes
Diffstat (limited to 'lib/Index')
-rw-r--r-- | lib/Index/CodegenNameGenerator.cpp | 36 | ||||
-rw-r--r-- | lib/Index/IndexSymbol.cpp | 2 | ||||
-rw-r--r-- | lib/Index/IndexingAction.cpp | 178 | ||||
-rw-r--r-- | lib/Index/USRGeneration.cpp | 3 |
4 files changed, 59 insertions, 160 deletions
diff --git a/lib/Index/CodegenNameGenerator.cpp b/lib/Index/CodegenNameGenerator.cpp deleted file mode 100644 index 56d3d06034861..0000000000000 --- a/lib/Index/CodegenNameGenerator.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===- CodegenNameGenerator.cpp - 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. -// -//===----------------------------------------------------------------------===// - -#include "clang/Index/CodegenNameGenerator.h" -#include "clang/AST/ASTContext.h" - -using namespace clang; -using namespace clang::index; - -CodegenNameGenerator::CodegenNameGenerator(ASTContext &Ctx) - : Impl(new ASTNameGenerator(Ctx)) { -} - -CodegenNameGenerator::~CodegenNameGenerator() { -} - -bool CodegenNameGenerator::writeName(const Decl *D, raw_ostream &OS) { - return Impl->writeName(D, OS); -} - -std::string CodegenNameGenerator::getName(const Decl *D) { - return Impl->getName(D); -} - -std::vector<std::string> CodegenNameGenerator::getAllManglings(const Decl *D) { - return Impl->getAllManglings(D); -} diff --git a/lib/Index/IndexSymbol.cpp b/lib/Index/IndexSymbol.cpp index 064f3ae32f9ec..5165567ff75eb 100644 --- a/lib/Index/IndexSymbol.cpp +++ b/lib/Index/IndexSymbol.cpp @@ -513,7 +513,7 @@ StringRef index::getSymbolKindString(SymbolKind K) { case SymbolKind::StaticProperty: return "static-property"; case SymbolKind::Constructor: return "constructor"; case SymbolKind::Destructor: return "destructor"; - case SymbolKind::ConversionFunction: return "coversion-func"; + case SymbolKind::ConversionFunction: return "conversion-func"; case SymbolKind::Parameter: return "param"; case SymbolKind::Using: return "using"; } diff --git a/lib/Index/IndexingAction.cpp b/lib/Index/IndexingAction.cpp index 5a805c4abcd63..6d6133e89d864 100644 --- a/lib/Index/IndexingAction.cpp +++ b/lib/Index/IndexingAction.cpp @@ -21,62 +21,9 @@ using namespace clang; using namespace clang::index; -bool IndexDataConsumer::handleDeclOccurence(const Decl *D, SymbolRoleSet Roles, - ArrayRef<SymbolRelation> Relations, - SourceLocation Loc, - ASTNodeInfo ASTNode) { - return true; -} - -bool IndexDataConsumer::handleMacroOccurence(const IdentifierInfo *Name, - const MacroInfo *MI, - SymbolRoleSet Roles, - SourceLocation Loc) { - return true; -} - -bool IndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD, - const Module *Mod, - SymbolRoleSet Roles, - SourceLocation Loc) { - return true; -} - namespace { -class IndexASTConsumer : public ASTConsumer { - std::shared_ptr<Preprocessor> PP; - std::shared_ptr<IndexingContext> IndexCtx; - -public: - IndexASTConsumer(std::shared_ptr<Preprocessor> PP, - std::shared_ptr<IndexingContext> IndexCtx) - : PP(std::move(PP)), IndexCtx(std::move(IndexCtx)) {} - -protected: - void Initialize(ASTContext &Context) override { - IndexCtx->setASTContext(Context); - IndexCtx->getDataConsumer().initialize(Context); - IndexCtx->getDataConsumer().setPreprocessor(PP); - } - - bool HandleTopLevelDecl(DeclGroupRef DG) override { - return IndexCtx->indexDeclGroupRef(DG); - } - - void HandleInterestingDecl(DeclGroupRef DG) override { - // Ignore deserialized decls. - } - - void HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) override { - IndexCtx->indexDeclGroupRef(DG); - } - - void HandleTranslationUnit(ASTContext &Ctx) override { - } -}; - -class IndexPPCallbacks : public PPCallbacks { +class IndexPPCallbacks final : public PPCallbacks { std::shared_ptr<IndexingContext> IndexCtx; public: @@ -106,104 +53,89 @@ public: } }; -class IndexActionBase { -protected: +class IndexASTConsumer final : public ASTConsumer { std::shared_ptr<IndexDataConsumer> DataConsumer; std::shared_ptr<IndexingContext> IndexCtx; + std::shared_ptr<Preprocessor> PP; + std::function<bool(const Decl *)> ShouldSkipFunctionBody; - IndexActionBase(std::shared_ptr<IndexDataConsumer> dataConsumer, - IndexingOptions Opts) - : DataConsumer(std::move(dataConsumer)), - IndexCtx(new IndexingContext(Opts, *DataConsumer)) {} - - std::unique_ptr<IndexASTConsumer> - createIndexASTConsumer(CompilerInstance &CI) { - return llvm::make_unique<IndexASTConsumer>(CI.getPreprocessorPtr(), - IndexCtx); +public: + IndexASTConsumer(std::shared_ptr<IndexDataConsumer> DataConsumer, + const IndexingOptions &Opts, + std::shared_ptr<Preprocessor> PP, + std::function<bool(const Decl *)> ShouldSkipFunctionBody) + : DataConsumer(std::move(DataConsumer)), + IndexCtx(new IndexingContext(Opts, *this->DataConsumer)), + PP(std::move(PP)), + ShouldSkipFunctionBody(std::move(ShouldSkipFunctionBody)) { + assert(this->DataConsumer != nullptr); + assert(this->PP != nullptr); } - std::unique_ptr<PPCallbacks> createIndexPPCallbacks() { - return llvm::make_unique<IndexPPCallbacks>(IndexCtx); +protected: + void Initialize(ASTContext &Context) override { + IndexCtx->setASTContext(Context); + IndexCtx->getDataConsumer().initialize(Context); + IndexCtx->getDataConsumer().setPreprocessor(PP); + PP->addPPCallbacks(std::make_unique<IndexPPCallbacks>(IndexCtx)); } - void finish() { - DataConsumer->finish(); + bool HandleTopLevelDecl(DeclGroupRef DG) override { + return IndexCtx->indexDeclGroupRef(DG); } -}; -class IndexAction : public ASTFrontendAction, IndexActionBase { -public: - IndexAction(std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts) - : IndexActionBase(std::move(DataConsumer), Opts) {} + void HandleInterestingDecl(DeclGroupRef DG) override { + // Ignore deserialized decls. + } -protected: - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override { - return createIndexASTConsumer(CI); + void HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) override { + IndexCtx->indexDeclGroupRef(DG); } - bool BeginSourceFileAction(clang::CompilerInstance &CI) override { - CI.getPreprocessor().addPPCallbacks(createIndexPPCallbacks()); - return true; + void HandleTranslationUnit(ASTContext &Ctx) override { + DataConsumer->finish(); } - void EndSourceFileAction() override { - FrontendAction::EndSourceFileAction(); - finish(); + bool shouldSkipFunctionBody(Decl *D) override { + return ShouldSkipFunctionBody(D); } }; -class WrappingIndexAction : public WrapperFrontendAction, IndexActionBase { - bool IndexActionFailed = false; +class IndexAction final : public ASTFrontendAction { + std::shared_ptr<IndexDataConsumer> DataConsumer; + IndexingOptions Opts; public: - WrappingIndexAction(std::unique_ptr<FrontendAction> WrappedAction, - std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts) - : WrapperFrontendAction(std::move(WrappedAction)), - IndexActionBase(std::move(DataConsumer), Opts) {} + IndexAction(std::shared_ptr<IndexDataConsumer> DataConsumer, + const IndexingOptions &Opts) + : DataConsumer(std::move(DataConsumer)), Opts(Opts) { + assert(this->DataConsumer != nullptr); + } protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { - auto OtherConsumer = WrapperFrontendAction::CreateASTConsumer(CI, InFile); - if (!OtherConsumer) { - IndexActionFailed = true; - return nullptr; - } - - std::vector<std::unique_ptr<ASTConsumer>> Consumers; - Consumers.push_back(std::move(OtherConsumer)); - Consumers.push_back(createIndexASTConsumer(CI)); - return llvm::make_unique<MultiplexConsumer>(std::move(Consumers)); - } - - bool BeginSourceFileAction(clang::CompilerInstance &CI) override { - WrapperFrontendAction::BeginSourceFileAction(CI); - CI.getPreprocessor().addPPCallbacks(createIndexPPCallbacks()); - return true; - } - - void EndSourceFileAction() override { - // Invoke wrapped action's method. - WrapperFrontendAction::EndSourceFileAction(); - if (!IndexActionFailed) - finish(); + return std::make_unique<IndexASTConsumer>( + DataConsumer, Opts, CI.getPreprocessorPtr(), + /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; }); } }; } // anonymous namespace +std::unique_ptr<ASTConsumer> index::createIndexingASTConsumer( + std::shared_ptr<IndexDataConsumer> DataConsumer, + const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP, + std::function<bool(const Decl *)> ShouldSkipFunctionBody) { + return std::make_unique<IndexASTConsumer>(DataConsumer, Opts, PP, + ShouldSkipFunctionBody); +} + std::unique_ptr<FrontendAction> index::createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer, - IndexingOptions Opts, - std::unique_ptr<FrontendAction> WrappedAction) { - if (WrappedAction) - return llvm::make_unique<WrappingIndexAction>(std::move(WrappedAction), - std::move(DataConsumer), - Opts); - return llvm::make_unique<IndexAction>(std::move(DataConsumer), Opts); + const IndexingOptions &Opts) { + assert(DataConsumer != nullptr); + return std::make_unique<IndexAction>(std::move(DataConsumer), Opts); } static bool topLevelDeclVisitor(void *context, const Decl *D) { @@ -257,7 +189,7 @@ void index::indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP, std::unique_ptr<PPCallbacks> index::indexMacrosCallback(IndexDataConsumer &Consumer, IndexingOptions Opts) { - return llvm::make_unique<IndexPPCallbacks>( + return std::make_unique<IndexPPCallbacks>( std::make_shared<IndexingContext>(Opts, Consumer)); } diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index 228651de928e5..f4316fe7d0674 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -724,6 +724,9 @@ void USRGenerator::VisitType(QualType T) { case BuiltinType::OCLQueue: case BuiltinType::OCLReserveID: case BuiltinType::OCLSampler: +#define SVE_TYPE(Name, Id, SingletonId) \ + case BuiltinType::Id: +#include "clang/Basic/AArch64SVEACLETypes.def" case BuiltinType::ShortAccum: case BuiltinType::Accum: case BuiltinType::LongAccum: |