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"
33class 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;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Abstract base class to use for AST consumer-based frontend actions.
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.
Abstract base class for actions which can be performed by the frontend.
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 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?
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
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
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
std::unique_ptr< ASTUnit > takeCurrentASTUnit()
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
void setCompilerInstance(CompilerInstance *Value)
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
virtual ~FrontendAction()
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?
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?
A frontend action which simply wraps some other runtime-specified frontend action.
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...
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...
The JSON file list parser is used to communicate input to InstallAPI.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_Complete
The translation unit is a complete translation unit.