17 using namespace clang;
18 using namespace clang::index;
20 void IndexDataConsumer::_anchor() {}
48 : IndexCtx(IndexCtx) {}
53 IndexCtx.getDataConsumer().initialize(Context);
57 return IndexCtx.indexDeclGroupRef(DG);
64 void HandleTopLevelDeclInObjCContainer(
DeclGroupRef DG)
override {
65 IndexCtx.indexDeclGroupRef(DG);
68 void HandleTranslationUnit(
ASTContext &Ctx)
override {
72 class IndexActionBase {
74 std::shared_ptr<IndexDataConsumer> DataConsumer;
77 IndexActionBase(std::shared_ptr<IndexDataConsumer> dataConsumer,
79 : DataConsumer(std::move(dataConsumer)),
80 IndexCtx(Opts, *DataConsumer) {}
82 std::unique_ptr<IndexASTConsumer> createIndexASTConsumer() {
83 return llvm::make_unique<IndexASTConsumer>(IndexCtx);
87 DataConsumer->finish();
93 IndexAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
95 : IndexActionBase(std::move(DataConsumer), Opts) {}
99 StringRef InFile)
override {
100 return createIndexASTConsumer();
103 void EndSourceFileAction()
override {
110 bool IndexActionFailed =
false;
113 WrappingIndexAction(std::unique_ptr<FrontendAction> WrappedAction,
114 std::shared_ptr<IndexDataConsumer> DataConsumer,
117 IndexActionBase(std::move(DataConsumer), Opts) {}
121 StringRef InFile)
override;
122 void EndSourceFileAction()
override;
127 void WrappingIndexAction::EndSourceFileAction() {
130 if (!IndexActionFailed)
134 std::unique_ptr<ASTConsumer>
135 WrappingIndexAction::CreateASTConsumer(
CompilerInstance &CI, StringRef InFile) {
137 if (!OtherConsumer) {
138 IndexActionFailed =
true;
142 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
143 Consumers.push_back(std::move(OtherConsumer));
144 Consumers.push_back(createIndexASTConsumer());
145 return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
148 std::unique_ptr<FrontendAction>
151 std::unique_ptr<FrontendAction> WrappedAction) {
153 return llvm::make_unique<WrappingIndexAction>(std::move(WrappedAction),
154 std::move(DataConsumer),
156 return llvm::make_unique<IndexAction>(std::move(DataConsumer), Opts);
170 std::shared_ptr<IndexDataConsumer> DataConsumer,
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
virtual bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles, ArrayRef< SymbolRelation > Relations, FileID FID, unsigned Offset, ASTNodeInfo ASTNode)
bool indexTopLevelDecl(const Decl *D)
void setASTContext(ASTContext &ctx)
One of these records is kept for each identifier that is lexed.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Utility class for loading a ASTContext from an AST file.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Defines the clang::Preprocessor interface.
virtual bool handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles, FileID FID, unsigned Offset)
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
void EndSourceFileAction() override
Callback at the end of processing a single input.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Abstract base class to use for AST consumer-based frontend actions.
bool visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn)
Iterate over local declarations (locally parsed if this is a parsed source file or the loaded declara...
const ASTContext & getASTContext() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
A frontend action which simply wraps some other runtime-specified frontend action.
Encapsulates the data about a macro definition (e.g.
void indexASTUnit(ASTUnit &Unit, std::shared_ptr< IndexDataConsumer > DataConsumer, IndexingOptions Opts)
static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IndexCtx)
virtual bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI, SymbolRoleSet Roles, FileID FID, unsigned Offset)
std::unique_ptr< FrontendAction > createIndexingAction(std::shared_ptr< IndexDataConsumer > DataConsumer, IndexingOptions Opts, std::unique_ptr< FrontendAction > WrappedAction)
static bool topLevelDeclVisitor(void *context, const Decl *D)
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...