clang-tools 24.0.0git
clang::clangd::FeatureModule::ASTListener Struct Reference

Extension point that allows modules to observe and modify an AST build. More...

#include <FeatureModule.h>

Public Member Functions

virtual ~ASTListener ()=default
 Listeners are destroyed once the AST is built.
virtual void beforeBeginSourceFile (CompilerInstance &CI)
 Called for a main-file build immediately before BeginSourceFile().
virtual void beforePPCallbacks (CompilerInstance &CI)
 Called before every AST build, after the Preprocessor and ASTConsumer are set up, but before clangd installs its include and macro collectors.
virtual void beforeExecute (CompilerInstance &CI)
 Called before every AST build, both for main file and preamble.
virtual void afterExecute (CompilerInstance &CI)
 Called after FrontendAction::Execute() for a main-file build, once clangd has collected tokens and restricted the AST traversal scope.
virtual void sawDiagnostic (const clang::Diagnostic &, clangd::Diag &)
 Called everytime a diagnostic is encountered.
virtual void finalizeDiagnostic (clangd::Diag &)
 Called after a diagnostic is fully assembled, including notes and fixes, and before it is returned to the caller.

Detailed Description

Extension point that allows modules to observe and modify an AST build.

One instance is created each time clangd produces a ParsedAST or PrecompiledPreamble. For a given instance, lifecycle methods are always called on a single thread.

Definition at line 107 of file FeatureModule.h.

Constructor & Destructor Documentation

◆ ~ASTListener()

virtual clang::clangd::FeatureModule::ASTListener::~ASTListener ( )
virtualdefault

Listeners are destroyed once the AST is built.

Member Function Documentation

◆ afterExecute()

virtual void clang::clangd::FeatureModule::ASTListener::afterExecute ( CompilerInstance & CI)
inlinevirtual

Called after FrontendAction::Execute() for a main-file build, once clangd has collected tokens and restricted the AST traversal scope.

The preprocessor has not received EndSourceFile() yet.

Definition at line 140 of file FeatureModule.h.

◆ beforeBeginSourceFile()

virtual void clang::clangd::FeatureModule::ASTListener::beforeBeginSourceFile ( CompilerInstance & CI)
inlinevirtual

Called for a main-file build immediately before BeginSourceFile().

Not called for preamble builds. The virtual filesystem, diagnostics, target, and file manager are available. The source manager, preprocessor, AST context, and AST consumer are not set up yet. Use this to configure diagnostics emitted during frontend initialization, including loading precompiled modules. Normal diagnostic filtering still applies. Do not change the frontend inputs or options affecting compilation semantics (e.g. macro definitions): they must remain consistent with the preamble, which may already have been built.

Definition at line 120 of file FeatureModule.h.

◆ beforeExecute()

virtual void clang::clangd::FeatureModule::ASTListener::beforeExecute ( CompilerInstance & CI)
inlinevirtual

Called before every AST build, both for main file and preamble.

The call happens immediately before FrontendAction::Execute(), with Preprocessor set up already and after BeginSourceFile() on main file was called.

Definition at line 135 of file FeatureModule.h.

◆ beforePPCallbacks()

virtual void clang::clangd::FeatureModule::ASTListener::beforePPCallbacks ( CompilerInstance & CI)
inlinevirtual

Called before every AST build, after the Preprocessor and ASTConsumer are set up, but before clangd installs its include and macro collectors.

Modules should only use this when their PPCallbacks must observe preamble events replayed during a main-file build. Reusing a preamble skips the main file's initial preprocessing directives. ReplayPreamble synthesizes callbacks for selected events from that region and captures their recipients before beforeExecute() is called.

Definition at line 130 of file FeatureModule.h.

◆ finalizeDiagnostic()

virtual void clang::clangd::FeatureModule::ASTListener::finalizeDiagnostic ( clangd::Diag & )
inlinevirtual

Called after a diagnostic is fully assembled, including notes and fixes, and before it is returned to the caller.

Definition at line 149 of file FeatureModule.h.

◆ sawDiagnostic()

virtual void clang::clangd::FeatureModule::ASTListener::sawDiagnostic ( const clang::Diagnostic & ,
clangd::Diag &  )
inlinevirtual

Called everytime a diagnostic is encountered.

Modules can use this modify the final diagnostic, or store some information to surface code actions later on.

Definition at line 145 of file FeatureModule.h.


The documentation for this struct was generated from the following file: