clang  7.0.0svn
Classes | Public Types | Public Member Functions | List of all members
clang::driver::Compilation Class Reference

Compilation - A set of tasks to perform for a single driver invocation. More...

#include "clang/Driver/Compilation.h"

Public Types

using const_offload_toolchains_iterator = const std::multimap< Action::OffloadKind, const ToolChain * >::const_iterator
 Iterator that visits device toolchains of a given kind. More...
 
using const_offload_toolchains_range = std::pair< const_offload_toolchains_iterator, const_offload_toolchains_iterator >
 

Public Member Functions

 Compilation (const Driver &D, const ToolChain &DefaultToolChain, llvm::opt::InputArgList *Args, llvm::opt::DerivedArgList *TranslatedArgs, bool ContainsError)
 
 ~Compilation ()
 
const DrivergetDriver () const
 
const ToolChaingetDefaultToolChain () const
 
unsigned isOffloadingHostKind (Action::OffloadKind Kind) const
 
template<Action::OffloadKind Kind>
const_offload_toolchains_range getOffloadToolChains () const
 
template<Action::OffloadKind Kind>
bool hasOffloadToolChain () const
 Return true if an offloading tool chain of a given kind exists. More...
 
template<Action::OffloadKind Kind>
const ToolChaingetSingleOffloadToolChain () const
 Return an offload toolchain of the provided kind. More...
 
void addOffloadDeviceToolChain (const ToolChain *DeviceToolChain, Action::OffloadKind OffloadKind)
 
const llvm::opt::InputArgList & getInputArgs () const
 
const llvm::opt::DerivedArgList & getArgs () const
 
llvm::opt::DerivedArgList & getArgs ()
 
ActionListgetActions ()
 
const ActionListgetActions () const
 
template<typename T , typename... Args>
TMakeAction (Args &&... Arg)
 Creates a new Action owned by this Compilation. More...
 
JobListgetJobs ()
 
const JobListgetJobs () const
 
void addCommand (std::unique_ptr< Command > C)
 
const llvm::opt::ArgStringList & getTempFiles () const
 
const ArgStringMapgetResultFiles () const
 
const ArgStringMapgetFailureResultFiles () const
 
StringRef getSysRoot () const
 Returns the sysroot path. More...
 
const llvm::opt::DerivedArgList & getArgsForToolChain (const ToolChain *TC, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind)
 getArgsForToolChain - Return the derived argument list for the tool chain TC (or the default tool chain, if TC is not specified). More...
 
const char * addTempFile (const char *Name)
 addTempFile - Add a file to remove on exit, and returns its argument. More...
 
const char * addResultFile (const char *Name, const JobAction *JA)
 addResultFile - Add a file to remove on failure, and returns its argument. More...
 
const char * addFailureResultFile (const char *Name, const JobAction *JA)
 addFailureResultFile - Add a file to remove if we crash, and returns its argument. More...
 
bool CleanupFile (const char *File, bool IssueErrors=false) const
 CleanupFile - Delete a given file. More...
 
bool CleanupFileList (const llvm::opt::ArgStringList &Files, bool IssueErrors=false) const
 CleanupFileList - Remove the files in the given list. More...
 
bool CleanupFileMap (const ArgStringMap &Files, const JobAction *JA, bool IssueErrors=false) const
 CleanupFileMap - Remove the files in the given map. More...
 
int ExecuteCommand (const Command &C, const Command *&FailingCommand) const
 ExecuteCommand - Execute an actual command. More...
 
void ExecuteJobs (const JobList &Jobs, SmallVectorImpl< std::pair< int, const Command *>> &FailingCommands) const
 ExecuteJob - Execute a single job. More...
 
void initCompilationForDiagnostics ()
 initCompilationForDiagnostics - Remove stale state and suppress output so compilation can be reexecuted to generate additional diagnostic information (e.g., preprocessed source(s)). More...
 
bool isForDiagnostics () const
 Return true if we're compiling for diagnostics. More...
 
bool containsError () const
 Return whether an error during the parsing of the input args. More...
 
void Redirect (ArrayRef< Optional< StringRef >> Redirects)
 Redirect - Redirect output of this compilation. More...
 

Detailed Description

Compilation - A set of tasks to perform for a single driver invocation.

Definition at line 46 of file Compilation.h.

Member Typedef Documentation

◆ const_offload_toolchains_iterator

Iterator that visits device toolchains of a given kind.

Definition at line 145 of file Compilation.h.

◆ const_offload_toolchains_range

Definition at line 148 of file Compilation.h.

Constructor & Destructor Documentation

◆ Compilation()

Compilation::Compilation ( const Driver D,
const ToolChain DefaultToolChain,
llvm::opt::InputArgList *  Args,
llvm::opt::DerivedArgList *  TranslatedArgs,
bool  ContainsError 
)

Definition at line 37 of file Compilation.cpp.

References clang::driver::Action::OFK_Host.

◆ ~Compilation()

Compilation::~Compilation ( )

Member Function Documentation

◆ addCommand()

void clang::driver::Compilation::addCommand ( std::unique_ptr< Command C)
inline

Definition at line 206 of file Compilation.h.

References clang::driver::JobList::addJob().

Referenced by ConstructGoldLinkJob(), clang::driver::tools::wasm::Linker::ConstructJob(), clang::driver::tools::fuchsia::Linker::ConstructJob(), clang::driver::tools::amdgpu::Linker::ConstructJob(), clang::driver::tools::XCore::Assembler::ConstructJob(), clang::driver::tools::CrossWindows::Assembler::ConstructJob(), clang::driver::tools::minix::Assembler::ConstructJob(), clang::driver::tools::SHAVE::Compiler::ConstructJob(), clang::driver::tools::dragonfly::Assembler::ConstructJob(), clang::driver::tools::MinGW::Assembler::ConstructJob(), clang::driver::tools::cloudabi::Linker::ConstructJob(), clang::driver::tools::ananas::Assembler::ConstructJob(), clang::driver::tools::netbsd::Assembler::ConstructJob(), clang::driver::tools::openbsd::Assembler::ConstructJob(), clang::driver::tools::freebsd::Assembler::ConstructJob(), clang::driver::tools::solaris::Assembler::ConstructJob(), clang::driver::tools::visualstudio::Linker::ConstructJob(), clang::driver::tools::hexagon::Assembler::ConstructJob(), clang::driver::tools::PS4cpu::Assemble::ConstructJob(), clang::driver::tools::nacltools::Linker::ConstructJob(), clang::driver::tools::AVR::Linker::ConstructJob(), clang::driver::tools::SHAVE::Assembler::ConstructJob(), clang::driver::tools::XCore::Linker::ConstructJob(), clang::driver::tools::minix::Linker::ConstructJob(), clang::driver::tools::dragonfly::Linker::ConstructJob(), clang::driver::tools::MinGW::Linker::ConstructJob(), clang::driver::tools::openbsd::Linker::ConstructJob(), clang::driver::tools::CrossWindows::Linker::ConstructJob(), clang::driver::tools::netbsd::Linker::ConstructJob(), clang::driver::tools::ananas::Linker::ConstructJob(), clang::driver::tools::freebsd::Linker::ConstructJob(), clang::driver::tools::solaris::Linker::ConstructJob(), clang::driver::tools::hexagon::Linker::ConstructJob(), clang::driver::tools::visualstudio::Compiler::ConstructJob(), clang::driver::tools::gnutools::Assembler::ConstructJob(), clang::driver::tools::darwin::Assembler::ConstructJob(), clang::driver::tools::Myriad::Linker::ConstructJob(), clang::driver::tools::gnutools::Linker::ConstructJob(), clang::driver::tools::baremetal::Linker::ConstructJob(), clang::driver::tools::darwin::Linker::ConstructJob(), clang::driver::tools::gcc::Common::ConstructJob(), clang::driver::tools::darwin::Lipo::ConstructJob(), clang::driver::tools::NVPTX::Assembler::ConstructJob(), clang::driver::tools::darwin::Dsymutil::ConstructJob(), clang::driver::tools::Clang::ConstructJob(), clang::driver::tools::NVPTX::Linker::ConstructJob(), clang::driver::tools::darwin::VerifyDebug::ConstructJob(), clang::driver::tools::NVPTX::OpenMPLinker::ConstructJob(), clang::driver::tools::ClangAs::ConstructJob(), and ConstructPS4LinkJob().

◆ addFailureResultFile()

const char* clang::driver::Compilation::addFailureResultFile ( const char *  Name,
const JobAction JA 
)
inline

addFailureResultFile - Add a file to remove if we crash, and returns its argument.

Definition at line 247 of file Compilation.h.

Referenced by RelocationModelName().

◆ addOffloadDeviceToolChain()

void clang::driver::Compilation::addOffloadDeviceToolChain ( const ToolChain DeviceToolChain,
Action::OffloadKind  OffloadKind 
)
inline

Definition at line 174 of file Compilation.h.

◆ addResultFile()

const char* clang::driver::Compilation::addResultFile ( const char *  Name,
const JobAction JA 
)
inline

addResultFile - Add a file to remove on failure, and returns its argument.

Definition at line 240 of file Compilation.h.

Referenced by clang::driver::Driver::GetNamedOutputPath().

◆ addTempFile()

const char* clang::driver::Compilation::addTempFile ( const char *  Name)
inline

◆ CleanupFile()

bool Compilation::CleanupFile ( const char *  File,
bool  IssueErrors = false 
) const

CleanupFile - Delete a given file.

Parameters
IssueErrors- Report failures as errors.
Returns
Whether the file was removed successfully.

Definition at line 100 of file Compilation.cpp.

References clang::driver::Driver::Diag(), and getDriver().

Referenced by CleanupFileList(), and CleanupFileMap().

◆ CleanupFileList()

bool Compilation::CleanupFileList ( const llvm::opt::ArgStringList &  Files,
bool  IssueErrors = false 
) const

CleanupFileList - Remove the files in the given list.

Parameters
IssueErrors- Report failures as errors.
Returns
Whether all files were removed successfully.

Definition at line 130 of file Compilation.cpp.

References CleanupFile().

Referenced by initCompilationForDiagnostics(), and ~Compilation().

◆ CleanupFileMap()

bool Compilation::CleanupFileMap ( const ArgStringMap Files,
const JobAction JA,
bool  IssueErrors = false 
) const

CleanupFileMap - Remove the files in the given map.

Parameters
JA- If specified, only delete the files associated with this JobAction. Otherwise, delete all files in the map.
IssueErrors- Report failures as errors.
Returns
Whether all files were removed successfully.

Definition at line 138 of file Compilation.cpp.

References CleanupFile().

Referenced by clang::driver::Driver::ExecuteCompilation().

◆ containsError()

bool clang::driver::Compilation::containsError ( ) const
inline

Return whether an error during the parsing of the input args.

Definition at line 299 of file Compilation.h.

◆ ExecuteCommand()

int Compilation::ExecuteCommand ( const Command C,
const Command *&  FailingCommand 
) const

ExecuteCommand - Execute an actual command.

Parameters
FailingCommand- For non-zero results, this will be set to the Command which failed, if any.
Returns
The result code of the subprocess.

Definition at line 152 of file Compilation.cpp.

References clang::driver::Driver::Diag(), clang::driver::Command::Execute(), getArgs(), getDriver(), and clang::driver::Command::Print().

Referenced by ExecuteJobs().

◆ ExecuteJobs()

void Compilation::ExecuteJobs ( const JobList Jobs,
SmallVectorImpl< std::pair< int, const Command *>> &  FailingCommands 
) const

ExecuteJob - Execute a single job.

Parameters
FailingCommands- For non-zero results, this will be a vector of failing commands and their associated result code.

Definition at line 226 of file Compilation.cpp.

References ExecuteCommand(), InputsOk(), and clang::driver::Driver::IsCLMode().

Referenced by clang::driver::Driver::ExecuteCompilation(), and clang::driver::Driver::generateCompilationDiagnostics().

◆ getActions() [1/2]

ActionList& clang::driver::Compilation::getActions ( )
inline

◆ getActions() [2/2]

const ActionList& clang::driver::Compilation::getActions ( ) const
inline

Definition at line 192 of file Compilation.h.

◆ getArgs() [1/2]

const llvm::opt::DerivedArgList& clang::driver::Compilation::getArgs ( ) const
inline

◆ getArgs() [2/2]

llvm::opt::DerivedArgList& clang::driver::Compilation::getArgs ( )
inline

Definition at line 189 of file Compilation.h.

◆ getArgsForToolChain()

const DerivedArgList & Compilation::getArgsForToolChain ( const ToolChain TC,
StringRef  BoundArch,
Action::OffloadKind  DeviceOffloadKind 
)

getArgsForToolChain - Return the derived argument list for the tool chain TC (or the default tool chain, if TC is not specified).

If a device offloading kind is specified, a translation specific for that kind is performed, if any.

Parameters
BoundArch- The bound architecture name, or 0.
DeviceOffloadKind- The offload device kind that should be used in the translation, if any.

Definition at line 63 of file Compilation.cpp.

References clang::driver::ToolChain::getTriple(), clang::driver::Action::OFK_OpenMP, clang::driver::ToolChain::TranslateArgs(), and clang::driver::ToolChain::TranslateOpenMPTargetArgs().

Referenced by clang::driver::Driver::BuildJobsForAction().

◆ getDefaultToolChain()

const ToolChain& clang::driver::Compilation::getDefaultToolChain ( ) const
inline

◆ getDriver()

const Driver& clang::driver::Compilation::getDriver ( ) const
inline

◆ getFailureResultFiles()

const ArgStringMap& clang::driver::Compilation::getFailureResultFiles ( ) const
inline

Definition at line 212 of file Compilation.h.

Referenced by clang::driver::Driver::ExecuteCompilation().

◆ getInputArgs()

const llvm::opt::InputArgList& clang::driver::Compilation::getInputArgs ( ) const
inline

◆ getJobs() [1/2]

JobList& clang::driver::Compilation::getJobs ( )
inline

◆ getJobs() [2/2]

const JobList& clang::driver::Compilation::getJobs ( ) const
inline

Definition at line 204 of file Compilation.h.

◆ getOffloadToolChains()

template<Action::OffloadKind Kind>
const_offload_toolchains_range clang::driver::Compilation::getOffloadToolChains ( ) const
inline

Definition at line 151 of file Compilation.h.

Referenced by forAllAssociatedToolChains().

◆ getResultFiles()

const ArgStringMap& clang::driver::Compilation::getResultFiles ( ) const
inline

Definition at line 210 of file Compilation.h.

Referenced by clang::driver::Driver::ExecuteCompilation().

◆ getSingleOffloadToolChain()

template<Action::OffloadKind Kind>
const ToolChain* clang::driver::Compilation::getSingleOffloadToolChain ( ) const
inline

Return an offload toolchain of the provided kind.

Only one is expected to exist.

Definition at line 164 of file Compilation.h.

Referenced by clang::driver::tools::Clang::ConstructJob(), and forAllAssociatedToolChains().

◆ getSysRoot()

StringRef Compilation::getSysRoot ( ) const

Returns the sysroot path.

Definition at line 279 of file Compilation.cpp.

References getDriver(), and clang::driver::Driver::SysRoot.

Referenced by clang::driver::Driver::HandleImmediateArgs(), RelocationModelName(), and shouldLinkerNotDedup().

◆ getTempFiles()

const llvm::opt::ArgStringList& clang::driver::Compilation::getTempFiles ( ) const
inline

◆ hasOffloadToolChain()

template<Action::OffloadKind Kind>
bool clang::driver::Compilation::hasOffloadToolChain ( ) const
inline

Return true if an offloading tool chain of a given kind exists.

Definition at line 156 of file Compilation.h.

◆ initCompilationForDiagnostics()

void Compilation::initCompilationForDiagnostics ( )

initCompilationForDiagnostics - Remove stale state and suppress output so compilation can be reexecuted to generate additional diagnostic information (e.g., preprocessed source(s)).

Definition at line 245 of file Compilation.cpp.

References CleanupFileList(), clang::driver::JobList::clear(), and clang::driver::Driver::isSaveTempsEnabled().

Referenced by clang::driver::Driver::generateCompilationDiagnostics().

◆ isForDiagnostics()

bool clang::driver::Compilation::isForDiagnostics ( ) const
inline

Return true if we're compiling for diagnostics.

Definition at line 296 of file Compilation.h.

Referenced by clang::driver::tools::Clang::ConstructJob(), and RenderModulesOptions().

◆ isOffloadingHostKind()

unsigned clang::driver::Compilation::isOffloadingHostKind ( Action::OffloadKind  Kind) const
inline

Definition at line 138 of file Compilation.h.

◆ MakeAction()

template<typename T , typename... Args>
T* clang::driver::Compilation::MakeAction ( Args &&...  Arg)
inline

Creates a new Action owned by this Compilation.

The new Action is not added to the list returned by getActions().

Definition at line 197 of file Compilation.h.

References clang::T.

Referenced by clang::driver::Driver::BuildUniversalActions(), and clang::driver::Driver::ConstructPhaseAction().

◆ Redirect()

void Compilation::Redirect ( ArrayRef< Optional< StringRef >>  Redirects)

Redirect - Redirect output of this compilation.

Can only be done once.

Parameters
Redirects- array of optional paths. The array should have a size of three. The inferior process's stdin(0), stdout(1), and stderr(2) will be redirected to the corresponding paths, if provided (not llvm::None).

Definition at line 283 of file Compilation.cpp.


The documentation for this class was generated from the following files: