clang API Documentation
#include <CodeGenAction.h>
Public Member Functions | |
~CodeGenAction () | |
void | setLinkModule (llvm::Module *Mod) |
std::unique_ptr< llvm::Module > | takeModule () |
llvm::LLVMContext * | takeLLVMContext () |
Take the LLVM context used by this action. | |
Public Attributes | |
BackendConsumer * | BEConsumer |
Protected Member Functions | |
CodeGenAction (unsigned _Act, llvm::LLVMContext *_VMContext=nullptr) | |
bool | hasIRSupport () const override |
Does this action support use with IR files? | |
std::unique_ptr< ASTConsumer > | CreateASTConsumer (CompilerInstance &CI, StringRef InFile) override |
Create the AST consumer object for this action, if supported. | |
void | ExecuteAction () override |
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer. | |
void | EndSourceFileAction () override |
Callback at the end of processing a single input. |
Definition at line 24 of file CodeGenAction.h.
CodeGenAction::CodeGenAction | ( | unsigned | _Act, |
llvm::LLVMContext * | _VMContext = nullptr |
||
) | [protected] |
Create a new code generation action. If the optional _VMContext
parameter is supplied, the action uses it without taking ownership, otherwise it creates a fresh LLVM context and takes ownership.
Definition at line 570 of file CodeGenAction.cpp.
Definition at line 575 of file CodeGenAction.cpp.
std::unique_ptr< ASTConsumer > CodeGenAction::CreateASTConsumer | ( | CompilerInstance & | CI, |
StringRef | InFile | ||
) | [override, protected, virtual] |
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.
CI | - The current compiler instance, provided as a convenience, see getCompilerInstance(). |
InFile | - The current input file, provided as a convenience, see getCurrentFile(). |
Implements clang::FrontendAction.
Definition at line 627 of file CodeGenAction.cpp.
References clang::Preprocessor::addPPCallbacks(), clang::Backend_EmitNothing, BEConsumer, clang::FileManager::getBufferForFile(), clang::CompilerInstance::getCodeGenOpts(), clang::CompilerInstance::getDiagnostics(), clang::CompilerInstance::getFileManager(), clang::CompilerInstance::getFrontendOpts(), clang::CompilerInstance::getLangOpts(), GetOutputStream(), clang::CompilerInstance::getPreprocessor(), clang::CompilerInstance::getTargetOpts(), clang::CodeGenOptions::LinkBitcodeFile, clang::DiagnosticsEngine::Report(), and clang::FrontendOptions::ShowTimers.
void CodeGenAction::EndSourceFileAction | ( | ) | [override, protected, virtual] |
Callback at the end of processing a single input.
This is guaranteed to only be called following a successful call to BeginSourceFileAction (and BeginSourceFile).
Reimplemented from clang::FrontendAction.
Definition at line 583 of file CodeGenAction.cpp.
References BEConsumer, clang::FrontendAction::getCompilerInstance(), clang::BackendConsumer::takeLinkModule(), and clang::BackendConsumer::takeModule().
void CodeGenAction::ExecuteAction | ( | ) | [override, protected, virtual] |
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
This will also take care of instantiating a code completion consumer if the user requested it and the action supports it.
Reimplemented from clang::ASTFrontendAction.
Definition at line 671 of file CodeGenAction.cpp.
References clang::Backend_EmitNothing, clang::EmitBackendOutput(), clang::DiagnosticsEngine::Error, clang::SourceManager::getBuffer(), clang::CompilerInstance::getCodeGenOpts(), clang::FrontendAction::getCompilerInstance(), clang::FrontendAction::getCurrentFile(), clang::FrontendAction::getCurrentFileKind(), clang::DiagnosticsEngine::getCustomDiagID(), clang::CompilerInstance::getDiagnostics(), clang::SourceManager::getFileEntryForID(), clang::CompilerInstance::getLangOpts(), clang::SourceManager::getMainFileID(), GetOutputStream(), clang::CompilerInstance::getSourceManager(), clang::CompilerInstance::getTarget(), clang::TargetInfo::getTargetDescription(), clang::CompilerInstance::getTargetOpts(), clang::IK_LLVM_IR, clang::DiagnosticsEngine::Report(), SM, clang::SourceManager::translateFileLineCol(), clang::TargetOptions::Triple, and clang::DiagnosticsEngine::Warning.
bool CodeGenAction::hasIRSupport | ( | ) | const [override, protected, virtual] |
Does this action support use with IR files?
Reimplemented from clang::FrontendAction.
Definition at line 581 of file CodeGenAction.cpp.
void clang::CodeGenAction::setLinkModule | ( | llvm::Module * | Mod | ) | [inline] |
setLinkModule - Set the link module to be used by this action. If a link module is not provided, and CodeGenOptions::LinkBitcodeFile is non-empty, the action will load it from the specified file.
Definition at line 53 of file CodeGenAction.h.
llvm::LLVMContext * CodeGenAction::takeLLVMContext | ( | ) |
Take the LLVM context used by this action.
Definition at line 600 of file CodeGenAction.cpp.
std::unique_ptr< llvm::Module > CodeGenAction::takeModule | ( | ) |
Take the generated LLVM module, for use after the action has been run. The result may be null on failure.
Definition at line 596 of file CodeGenAction.cpp.
Definition at line 62 of file CodeGenAction.h.
Referenced by CreateASTConsumer(), and EndSourceFileAction().