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"
39 std::unique_ptr<ASTUnit> CurrentASTUnit;
72 StringRef InFile) = 0;
119 assert(Instance &&
"Compiler instance not registered!");
130 assert(!CurrentInput.isEmpty() &&
"No current file!");
131 return (
bool)CurrentASTUnit;
139 assert(!CurrentInput.isEmpty() &&
"No current file!");
140 return CurrentInput.getFile();
144 assert(!CurrentInput.isEmpty() &&
"No current file!");
145 return CurrentInput.isFile()
146 ? CurrentInput.getFile()
147 : CurrentInput.getBuffer().getBufferIdentifier();
151 assert(!CurrentInput.isEmpty() &&
"No current file!");
152 return CurrentInput.getKind();
156 assert(CurrentASTUnit &&
"No current AST unit!");
157 return *CurrentASTUnit;
165 std::unique_ptr<ASTUnit> AST =
nullptr);
255 virtual void anchor();
258 StringRef InFile)
override = 0;
267 const std::vector<std::string> &arg) = 0;
290 StringRef InFile)
override;
308 StringRef InFile)
override;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
Frontend action adaptor that merges ASTs together.
Utility class for loading a ASTContext from an AST file.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
const FrontendInputFile & getCurrentInput() const
InputKind getCurrentFileKind() const
virtual void EndSourceFile()
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
virtual bool hasIRSupport() const
Does this action support use with IR files?
friend class ASTMergeAction
bool PrepareToExecute(CompilerInstance &CI)
Prepare the action to execute on the given compiler instance.
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile)=0
Create the AST consumer object for this action, if supported.
ASTUnit & getCurrentASTUnit() const
std::unique_ptr< ASTUnit > takeCurrentASTUnit()
CompilerInstance & getCompilerInstance() const
virtual bool PrepareToExecuteAction(CompilerInstance &CI)
Prepare to execute the action on the given CompilerInstance.
llvm::Error Execute()
Set the source manager's main input file, and run the action.
virtual bool hasASTFileSupport() const
Does this action support use with AST files?
Module * getCurrentModule() const
void setCurrentInput(const FrontendInputFile &CurrentInput, std::unique_ptr< ASTUnit > AST=nullptr)
StringRef getCurrentFile() const
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
void setCompilerInstance(CompilerInstance *Value)
virtual ~FrontendAction()
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input)
Prepare the action for processing the input file Input.
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
StringRef getCurrentFileOrBufferName() const
virtual bool isModelParsingAction() const
Is this action invoked on a model file?
bool isCurrentFileAST() const
virtual bool usesPreprocessorOnly() const =0
Does this action only use the preprocessor?
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
friend class WrapperFrontendAction
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
virtual bool hasPCHSupport() const
Does this action support use with PCH?
Describes a module or submodule.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override=0
Create the AST consumer object for this action, if supported.
virtual bool ParseArgs(const CompilerInstance &CI, const std::vector< std::string > &arg)=0
Parse the given plugin command line arguments.
@ AddAfterMainAction
Execute the action after the main action.
@ ReplaceAction
Replace the main action.
@ AddBeforeMainAction
Execute the action before the main action.
@ CmdlineBeforeMainAction
Execute the action before the main action if on the command line.
@ CmdlineAfterMainAction
Execute the action after the main action if on the command line.
virtual ActionType getActionType()
Get the action type for this plugin.
Abstract base class to use for preprocessor-based frontend actions.
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 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 hasIRSupport() const override
Does this action support use with IR files?
bool PrepareToExecuteAction(CompilerInstance &CI) override
Prepare to execute the action on the given CompilerInstance.
bool hasASTFileSupport() const override
Does this action support use with AST files?
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.
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
WrapperFrontendAction(std::unique_ptr< FrontendAction > WrappedAction)
Construct a WrapperFrontendAction from an existing action, taking ownership of it.
TranslationUnitKind getTranslationUnitKind() override
For AST-based actions, the kind of translation unit we're handling.
void EndSourceFileAction() override
Callback at the end of processing a single input.
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
bool hasPCHSupport() const override
Does this action support use with PCH?
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
std::unique_ptr< FrontendAction > WrappedAction
void EndSourceFile() override
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
Top level wrappers for InstallAPI frontend operations.
TranslationUnitKind
Describes the kind of translation unit being processed.