class FrontendAction

Declaration

class FrontendAction { /* full declaration omitted */ };

Description

Abstract base class for actions which can be performed by the frontend.

Declared at: clang/include/clang/Frontend/FrontendAction.h:36

Member Variables

private clang::FrontendInputFile CurrentInput
private std::unique_ptr<ASTUnit> CurrentASTUnit
private clang::CompilerInstance* Instance

Method Overview

Methods

virtual bool BeginInvocation(
    clang::CompilerInstance& CI)

Description

Callback before starting processing a single input, giving the opportunity to modify the CompilerInvocation or do some other action before BeginSourceFileAction is called.

Declared at: clang/include/clang/Frontend/FrontendAction.h:79

Parameters

clang::CompilerInstance& CI

Returns

True on success; on failure BeginSourceFileAction(), ExecuteAction() and EndSourceFileAction() will not be called.

bool BeginSourceFile(
    clang::CompilerInstance& CI,
    const clang::FrontendInputFile& Input)

Description

Prepare the action for processing the input file \p Input. This is run after the options and frontend have been initialized, but prior to executing any per-file processing.

Declared at: clang/include/clang/Frontend/FrontendAction.h:230

Parameters

clang::CompilerInstance& CI
- The compiler instance this action is being run from. The action may store and use this object up until the matching EndSourceFile action.
const clang::FrontendInputFile& Input
- The input filename and kind. Some input kinds are handled specially, for example AST inputs, since the AST file itself contains several objects which would normally be owned by the CompilerInstance. When processing AST input files, these objects should generally not be initialized in the CompilerInstance -- they will automatically be shared with the AST file in between BeginSourceFile() and EndSourceFile().

Returns

True on success; on failure the compilation of this file should be aborted and neither Execute() nor EndSourceFile() should be called.

virtual bool BeginSourceFileAction(
    clang::CompilerInstance& CI)

Description

Callback at the start of processing a single input.

Declared at: clang/include/clang/Frontend/FrontendAction.h:85

Parameters

clang::CompilerInstance& CI

Returns

True on success; on failure ExecutionAction() and EndSourceFileAction() will not be called.

virtual std::unique_ptr<ASTConsumer>
CreateASTConsumer(clang::CompilerInstance& CI,
                  llvm::StringRef InFile)

Description

Create the AST consumer object for this action, if supported. This routine is called as part of BeginSourceFile(), which will fail if the AST consumer cannot be created. This will not be called if the action has indicated that it only uses the preprocessor.

Declared at: clang/include/clang/Frontend/FrontendAction.h:70

Parameters

clang::CompilerInstance& CI
- The current compiler instance, provided as a convenience, see getCompilerInstance().
llvm::StringRef InFile
- The current input file, provided as a convenience, see getCurrentFile().

Returns

The new AST consumer, or null on failure.

std::unique_ptr<ASTConsumer>
CreateWrappedASTConsumer(
    clang::CompilerInstance& CI,
    llvm::StringRef InFile)

Declared at: clang/include/clang/Frontend/FrontendAction.h:44

Parameters

clang::CompilerInstance& CI
llvm::StringRef InFile

virtual void EndSourceFile()

Description

Perform any per-file post processing, deallocate per-file objects, and run statistics and output file cleanup code.

Declared at: clang/include/clang/Frontend/FrontendAction.h:237

virtual void EndSourceFileAction()

Description

Callback at the end of processing a single input. This is guaranteed to only be called following a successful call to BeginSourceFileAction (and BeginSourceFile).

Declared at: clang/include/clang/Frontend/FrontendAction.h:100

llvm::Error Execute()

Description

Set the source manager's main input file, and run the action.

Declared at: clang/include/clang/Frontend/FrontendAction.h:233

virtual void ExecuteAction()

Description

Callback to run the program action, using the initialized compiler instance. This is guaranteed to only be called between BeginSourceFileAction() and EndSourceFileAction().

Declared at: clang/include/clang/Frontend/FrontendAction.h:94

FrontendAction()

Description

@ }

Declared at: clang/include/clang/Frontend/FrontendAction.h:113

bool PrepareToExecute(clang::CompilerInstance& CI)

Description

Prepare the action to execute on the given compiler instance.

Declared at: clang/include/clang/Frontend/FrontendAction.h:207

Parameters

clang::CompilerInstance& CI

virtual bool PrepareToExecuteAction(
    clang::CompilerInstance& CI)

Description

Prepare to execute the action on the given CompilerInstance. This is called before executing the action on any inputs, and can modify the configuration as needed (including adjusting the input list).

Declared at: clang/include/clang/Frontend/FrontendAction.h:55

Parameters

clang::CompilerInstance& CI

clang::CompilerInstance& getCompilerInstance()
    const

Description

@ {

Declared at: clang/include/clang/Frontend/FrontendAction.h:119

clang::ASTUnit& getCurrentASTUnit() const

Declared at: clang/include/clang/Frontend/FrontendAction.h:156

llvm::StringRef getCurrentFile() const

Declared at: clang/include/clang/Frontend/FrontendAction.h:139

clang::InputKind getCurrentFileKind() const

Declared at: clang/include/clang/Frontend/FrontendAction.h:151

llvm::StringRef getCurrentFileOrBufferName() const

Declared at: clang/include/clang/Frontend/FrontendAction.h:144

const clang::FrontendInputFile& getCurrentInput()
    const

Declared at: clang/include/clang/Frontend/FrontendAction.h:135

clang::Module* getCurrentModule() const

Declared at: clang/include/clang/Frontend/FrontendAction.h:161

virtual clang::TranslationUnitKind
getTranslationUnitKind()

Description

For AST-based actions, the kind of translation unit we're handling.

Declared at: clang/include/clang/Frontend/FrontendAction.h:188

virtual bool hasASTFileSupport() const

Description

Does this action support use with AST files?

Declared at: clang/include/clang/Frontend/FrontendAction.h:194

virtual bool hasCodeCompletionSupport() const

Description

Does this action support use with code completion?

Declared at: clang/include/clang/Frontend/FrontendAction.h:200

virtual bool hasIRSupport() const

Description

Does this action support use with IR files?

Declared at: clang/include/clang/Frontend/FrontendAction.h:197

virtual bool hasPCHSupport() const

Description

Does this action support use with PCH?

Declared at: clang/include/clang/Frontend/FrontendAction.h:191

bool isCurrentFileAST() const

Description

@ } @ {

Declared at: clang/include/clang/Frontend/FrontendAction.h:130

virtual bool isModelParsingAction() const

Description

Is this action invoked on a model file? Model files are incomplete translation units that relies on type information from another translation unit. Check ParseModelFileAction for details.

Declared at: clang/include/clang/Frontend/FrontendAction.h:179

void setCompilerInstance(
    clang::CompilerInstance* Value)

Declared at: clang/include/clang/Frontend/FrontendAction.h:124

Parameters

clang::CompilerInstance* Value

void setCurrentInput(
    const clang::FrontendInputFile& CurrentInput,
    std::unique_ptr<ASTUnit> AST = nullptr)

Declared at: clang/include/clang/Frontend/FrontendAction.h:167

Parameters

const clang::FrontendInputFile& CurrentInput
std::unique_ptr<ASTUnit> AST = nullptr

virtual bool shouldEraseOutputFiles()

Description

Callback at the end of processing a single input, to determine if the output files should be erased or not. By default it returns true if a compiler error occurred. This is guaranteed to only be called following a successful call to BeginSourceFileAction (and BeginSourceFile).

Declared at: clang/include/clang/Frontend/FrontendAction.h:108

std::unique_ptr<ASTUnit> takeCurrentASTUnit()

Declared at: clang/include/clang/Frontend/FrontendAction.h:163

virtual bool usesPreprocessorOnly() const

Description

Does this action only use the preprocessor? If so no AST context will be created and this action will be invalid with AST file inputs.

Declared at: clang/include/clang/Frontend/FrontendAction.h:185

virtual ~FrontendAction()

Declared at: clang/include/clang/Frontend/FrontendAction.h:114