Go to the documentation of this file.
17 #ifndef LLVM_CLANG_FRONTEND_FRONTENDACTION_H
18 #define LLVM_CLANG_FRONTEND_FRONTENDACTION_H
25 #include "llvm/ADT/StringRef.h"
26 #include "llvm/Support/Error.h"
33 class CompilerInstance;
38 std::unique_ptr<ASTUnit> CurrentASTUnit;
71 StringRef InFile) = 0;
120 assert(Instance &&
"Compiler instance not registered!");
131 assert(!CurrentInput.
isEmpty() &&
"No current file!");
132 return (
bool)CurrentASTUnit;
140 assert(!CurrentInput.
isEmpty() &&
"No current file!");
145 assert(!CurrentInput.
isEmpty() &&
"No current file!");
146 return CurrentInput.
isFile()
148 : CurrentInput.
getBuffer().getBufferIdentifier();
152 assert(!CurrentInput.
isEmpty() &&
"No current file!");
157 assert(CurrentASTUnit &&
"No current AST unit!");
158 return *CurrentASTUnit;
164 return std::move(CurrentASTUnit);
168 std::unique_ptr<ASTUnit> AST =
nullptr);
258 virtual void anchor();
261 StringRef InFile)
override = 0;
270 const std::vector<std::string> &
arg) = 0;
293 StringRef InFile)
override;
311 StringRef InFile)
override;
std::unique_ptr< ASTUnit > takeCurrentASTUnit()
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Utility class for loading a ASTContext from an AST file.
Abstract base class to use for preprocessor-based frontend actions.
@ AddAfterMainAction
Execute the action after the main action.
friend class WrapperFrontendAction
virtual bool isModelParsingAction() const
Is this action invoked on a model file?
@ ReplaceAction
Replace the main action.
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Provide a default implementation which returns aborts; this method should never be called by Frontend...
virtual bool hasIRSupport() const
Does this action support use with IR files?
TranslationUnitKind getTranslationUnitKind() override
For AST-based actions, the kind of translation unit we're handling.
virtual void EndSourceFile()
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
bool hasPCHSupport() const override
Does this action support use with PCH?
ASTUnit & getCurrentASTUnit() const
Module * getCurrentModule() const
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
virtual bool hasASTFileSupport() const
Does this action support use with AST files?
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
@ AddBeforeMainAction
Execute the action before the main action.
Describes a module or submodule.
bool hasIRSupport() const override
Does this action support use with IR files?
virtual ~FrontendAction()
StringRef getCurrentFileOrBufferName() const
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override=0
Create the AST consumer object for this action, if supported.
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input)
Prepare the action for processing the input file Input.
virtual bool hasPCHSupport() const
Does this action support use with PCH?
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile)=0
Create the AST consumer object for this action, if supported.
CompilerInstance & getCompilerInstance() const
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
void setCurrentInput(const FrontendInputFile &CurrentInput, std::unique_ptr< ASTUnit > AST=nullptr)
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
InputKind getCurrentFileKind() const
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
const FrontendInputFile & getCurrentInput() const
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
Frontend action adaptor that merges ASTs together.
StringRef getCurrentFile() const
llvm::Error Execute()
Set the source manager's main input file, and run the action.
virtual bool PrepareToExecuteAction(CompilerInstance &CI)
Prepare to execute the action on the given CompilerInstance.
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
TranslationUnitKind
Describes the kind of translation unit being processed.
bool PrepareToExecute(CompilerInstance &CI)
Prepare the action to execute on the given compiler instance.
virtual bool ParseArgs(const CompilerInstance &CI, const std::vector< std::string > &arg)=0
Parse the given plugin command line arguments.
Abstract base class for actions which can be performed by the frontend.
bool isCurrentFileAST() const
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
std::unique_ptr< FrontendAction > WrappedAction
bool PrepareToExecuteAction(CompilerInstance &CI) override
Prepare to execute the action on the given CompilerInstance.
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
@ TU_Complete
The translation unit is a complete translation unit.
void EndSourceFile() override
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
virtual ActionType getActionType()
Get the action type for this plugin.
bool hasASTFileSupport() const override
Does this action support use with AST files?
Abstract base class to use for AST consumer-based frontend actions.
@ CmdlineAfterMainAction
Execute the action after the main action if on the command line.
void setCompilerInstance(CompilerInstance *Value)
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
virtual bool usesPreprocessorOnly() const =0
Does this action only use the preprocessor?
void EndSourceFileAction() override
Callback at the end of processing a single input.
@ CmdlineBeforeMainAction
Execute the action before the main action if on the command line.
A frontend action which simply wraps some other runtime-specified frontend action.