18 using namespace clang;
20 std::unique_ptr<ASTConsumer>
22 return AdaptedAction->CreateASTConsumer(CI, InFile);
30 AdaptedAction->setCompilerInstance(&CI);
31 return AdaptedAction->BeginSourceFileAction(CI);
44 for (
unsigned I = 0, N = ASTFiles.size(); I != N; ++I) {
58 Unit->getASTContext(), Unit->getFileManager(),
62 for (
auto *D : TU->decls()) {
64 if (
const auto *ND = dyn_cast<NamedDecl>(D))
66 if (II->isStr(
"__va_list_tag") || II->isStr(
"__builtin_va_list"))
69 Decl *ToD = Importer.Import(D);
78 AdaptedAction->ExecuteAction();
83 return AdaptedAction->EndSourceFileAction();
88 : AdaptedAction(
std::move(adaptedAction)), ASTFiles(ASTFiles.begin(), ASTFiles.end()) {
89 assert(AdaptedAction &&
"ASTMergeAction needs an action to adapt");
96 return AdaptedAction->usesPreprocessorOnly();
100 return AdaptedAction->getTranslationUnitKind();
104 return AdaptedAction->hasPCHSupport();
108 return AdaptedAction->hasASTFileSupport();
112 return AdaptedAction->hasCodeCompletionSupport();
Defines the clang::ASTContext interface.
DiagnosticConsumer * getClient()
bool hasPCHSupport() const override
Does this action support use with PCH?
Load everything, including Sema.
Decl - This represents one declaration (or definition), e.g.
DiagnosticOptions & getDiagnosticOpts()
std::unique_ptr< ASTUnit > takeCurrentASTUnit()
static std::unique_ptr< ASTUnit > LoadFromASTFile(const std::string &Filename, const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, const FileSystemOptions &FileSystemOpts, bool UseDebugInfo=false, bool OnlyLocalDecls=false, ArrayRef< RemappedFile > RemappedFiles=None, bool CaptureDiagnostics=false, bool AllowPCHWithCompilerErrors=false, bool UserFilesAreVolatile=false)
Create a ASTUnit from an AST file.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
ASTContext & getASTContext() const
virtual void EndSourceFile()
Callback to inform the diagnostic client that processing of a source file has ended.
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
One of these records is kept for each identifier that is lexed.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
CompilerInstance & getCompilerInstance() const
Concrete class used by the front-end to report problems and issues.
ASTConsumer & getASTConsumer() const
Defines the Diagnostic-related interfaces.
ASTMergeAction(std::unique_ptr< FrontendAction > AdaptedAction, ArrayRef< std::string > ASTFiles)
FileSystemOptions & getFileSystemOpts()
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
~ASTMergeAction() override
Diagnostic consumer that forwards diagnostics along to an existing, already-initialized diagnostic co...
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
Dataflow Directional Tag Classes.
FileManager & getFileManager() const
Return the current file manager to the caller.
const FrontendInputFile & getCurrentInput() const
bool hasASTFileSupport() const override
Does this action support use with AST files?
void FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
DiagnosticsEngine argument formatting function for diagnostics that involve AST nodes.
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
void EndSourceFileAction() override
Callback at the end of processing a single input.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
TranslationUnitDecl * getTranslationUnitDecl() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
TranslationUnitKind
Describes the kind of translation unit being processed.
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
TranslationUnitKind getTranslationUnitKind() override
For AST-based actions, the kind of translation unit we're handling.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
The top declaration context.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
virtual void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP=nullptr)
Callback to inform the diagnostic client that processing of a source file is beginning.
const LangOptions & getLangOpts() const