18 #ifndef LLVM_CLANG_FRONTEND_FRONTENDACTION_H
19 #define LLVM_CLANG_FRONTEND_FRONTENDACTION_H
26 #include "llvm/ADT/StringRef.h"
33 class CompilerInstance;
38 std::unique_ptr<ASTUnit> CurrentASTUnit;
65 StringRef InFile) = 0;
115 assert(Instance &&
"Compiler instance not registered!");
126 assert(!CurrentInput.
isEmpty() &&
"No current file!");
127 return (
bool)CurrentASTUnit;
135 assert(!CurrentInput.
isEmpty() &&
"No current file!");
140 assert(!CurrentInput.
isEmpty() &&
"No current file!");
145 assert(CurrentASTUnit &&
"No current AST unit!");
146 return *CurrentASTUnit;
150 return std::move(CurrentASTUnit);
154 std::unique_ptr<ASTUnit> AST =
nullptr);
239 virtual void anchor();
242 StringRef InFile)
override = 0;
251 const std::vector<std::string> &arg) = 0;
273 StringRef InFile)
override;
286 std::unique_ptr<FrontendAction> WrappedAction;
290 StringRef InFile)
override;
virtual bool isModelParsingAction() const
Is this action invoked on a model file?
void EndSourceFile()
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
Abstract base class for actions which can be performed by the frontend.
CompilerInstance & getCompilerInstance() const
std::unique_ptr< ASTUnit > takeCurrentASTUnit()
virtual bool usesPreprocessorOnly() const =0
Does this action only use the preprocessor?
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...
bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override
Callback at the start of processing a single input.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
InputKind getCurrentFileKind() const
const FrontendInputFile & getCurrentInput() const
Utility class for loading a ASTContext from an AST file.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input)
Prepare the action for processing the input file Input.
virtual bool hasASTFileSupport() const
Does this action support use with AST files?
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Execute the action before the main action.
bool hasPCHSupport() const override
Does this action support use with PCH?
Action is determined by the cc1 command-line.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override=0
Create the AST consumer object for this action, if supported.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
virtual ~FrontendAction()
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
virtual bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename)
Callback at the start of processing a single input.
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
void setCurrentInput(const FrontendInputFile &CurrentInput, std::unique_ptr< ASTUnit > AST=nullptr)
bool hasIRSupport() const override
Does this action support use with IR files?
Defines the clang::LangOptions interface.
WrapperFrontendAction(std::unique_ptr< FrontendAction > WrappedAction)
Construct a WrapperFrontendAction from an existing action, taking ownership of it.
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
TranslationUnitKind getTranslationUnitKind() override
For AST-based actions, the kind of translation unit we're handling.
virtual bool hasIRSupport() const
Does this action support use with IR files?
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile)=0
Create the AST consumer object for this action, if supported.
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
void EndSourceFileAction() override
Callback at the end of processing a single input.
virtual bool ParseArgs(const CompilerInstance &CI, const std::vector< std::string > &arg)=0
Parse the given plugin command line arguments.
virtual ActionType getActionType()
Get the action type for this plugin.
Frontend action adaptor that merges ASTs together.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
bool Execute()
Set the source manager's main input file, and run the action.
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
const StringRef getCurrentFile() const
Abstract base class to use for AST consumer-based frontend actions.
Execute the action after the main action.
Abstract base class to use for preprocessor-based frontend actions.
bool isCurrentFileAST() const
A frontend action which simply wraps some other runtime-specified frontend action.
virtual bool hasPCHSupport() const
Does this action support use with PCH?
bool hasASTFileSupport() const override
Does this action support use with AST files?
void setCompilerInstance(CompilerInstance *Value)
TranslationUnitKind
Describes the kind of translation unit being processed.
The translation unit is a complete translation unit.
ASTUnit & getCurrentASTUnit() const