class Compilation

Declaration

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

Description

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

Declared at: clang/include/clang/Driver/Compilation.h:45

Member Variables

private const clang::driver::Driver& TheDriver
The driver we were created by.
private const clang::driver::ToolChain& DefaultToolChain
The default tool chain.
private unsigned int ActiveOffloadMask = 0
A mask of all the programming models the host has to support in the current compilation.
private std::multimap<Action::OffloadKind, const ToolChain*> OrderedOffloadingToolchains
Array with the toolchains of offloading host and devices in the order they were requested by the user. We are preserving that order in case the code generation needs to derive a programming-model-specific semantic out of it.
private llvm::opt::InputArgList* Args
The original (untranslated) input argument list.
private llvm::opt::DerivedArgList* TranslatedArgs
The driver translated arguments. Note that toolchains may perform their own argument translation.
private std::vector<std::unique_ptr<Action>> AllActions
The list of actions we've created via MakeAction. This is not accessible to consumers; it's here just to manage ownership.
private clang::driver::ActionList Actions
The list of actions. This is maintained and modified by consumers, via getActions().
private clang::driver::JobList Jobs
The root list of jobs.
private std::map<TCArgsKey, llvm::opt::DerivedArgList*> TCArgs
private llvm::opt::ArgStringList TempFiles
Temporary files which should be removed on exit.
private clang::driver::ArgStringMap ResultFiles
Result files which should be removed on failure.
private clang::driver::ArgStringMap FailureResultFiles
Result files which are generated correctly on failure, and which should only be removed if we crash.
private std::vector<Optional<StringRef>> Redirects
Optional redirection for stdin, stdout, stderr.
private std::function<void(const Command&, int)> PostCallback
Callback called after compilation job has been finished. Arguments of the callback are the compilation job as an instance of class Command and the exit status of the corresponding child process.
private bool ForDiagnostics = false
Whether we're compiling for diagnostic purposes.
private bool ContainsError
Whether an error during the parsing of the input args.
private bool ForceKeepTempFiles = false
Whether to keep temporary files regardless of -save-temps.

Method Overview

  • public bool CleanupFile(const char * File, bool IssueErrors = false) const
  • public bool CleanupFileList(const llvm::opt::ArgStringList & Files, bool IssueErrors = false) const
  • public bool CleanupFileMap(const clang::driver::ArgStringMap & Files, const clang::driver::JobAction * JA, bool IssueErrors = false) const
  • public Compilation(const clang::driver::Driver & D, const clang::driver::ToolChain & DefaultToolChain, llvm::opt::InputArgList * Args, llvm::opt::DerivedArgList * TranslatedArgs, bool ContainsError)
  • public int ExecuteCommand(const clang::driver::Command & C, const clang::driver::Command *& FailingCommand, bool LogOnly = false) const
  • public void ExecuteJobs(const clang::driver::JobList & Jobs, SmallVectorImpl<std::pair<int, const Command *>> & FailingCommands, bool LogOnly = false) const
  • public template <typename T, typename... Args>T * MakeAction(Args &&... Arg)
  • public void Redirect(ArrayRef<Optional<llvm::StringRef>> Redirects)
  • public void addCommand(std::unique_ptr<Command> C)
  • public const char * addFailureResultFile(const char * Name, const clang::driver::JobAction * JA)
  • public void addOffloadDeviceToolChain(const clang::driver::ToolChain * DeviceToolChain, Action::OffloadKind OffloadKind)
  • public const char * addResultFile(const char * Name, const clang::driver::JobAction * JA)
  • public const char * addTempFile(const char * Name)
  • public bool containsError() const
  • public clang::driver::ActionList & getActions()
  • public const clang::driver::ActionList & getActions() const
  • public unsigned int getActiveOffloadKinds() const
  • public llvm::opt::DerivedArgList & getArgs()
  • public const llvm::opt::DerivedArgList & getArgs() const
  • public const llvm::opt::DerivedArgList & getArgsForToolChain(const clang::driver::ToolChain * TC, llvm::StringRef BoundArch, Action::OffloadKind DeviceOffloadKind)
  • public const clang::driver::ToolChain & getDefaultToolChain() const
  • public const clang::driver::Driver & getDriver() const
  • public const clang::driver::ArgStringMap & getFailureResultFiles() const
  • public const llvm::opt::InputArgList & getInputArgs() const
  • public const clang::driver::JobList & getJobs() const
  • public clang::driver::JobList & getJobs()
  • public clang::driver::Compilation::const_offload_toolchains_range getOffloadToolChains(Action::OffloadKind Kind) const
  • public template <Action::OffloadKind Kind>clang::driver::Compilation::const_offload_toolchains_range getOffloadToolChains() const
  • public const clang::driver::ArgStringMap & getResultFiles() const
  • public template <Action::OffloadKind Kind>const clang::driver::ToolChain * getSingleOffloadToolChain() const
  • public llvm::StringRef getSysRoot() const
  • public const llvm::opt::ArgStringList & getTempFiles() const
  • public template <Action::OffloadKind Kind>bool hasOffloadToolChain() const
  • public void initCompilationForDiagnostics()
  • public bool isForDiagnostics() const
  • public unsigned int isOffloadingHostKind(Action::OffloadKind Kind) const
  • public void setContainsError()
  • public void setPostCallback(const std::function<void (const Command &, int)> & CB)
  • public ~Compilation()

Methods

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

Description

CleanupFile - Delete a given file.

Declared at: clang/include/clang/Driver/Compilation.h:275

Parameters

const char* File
bool IssueErrors = false
- Report failures as errors.

Returns

Whether the file was removed successfully.

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

Description

CleanupFileList - Remove the files in the given list.

Declared at: clang/include/clang/Driver/Compilation.h:281

Parameters

const llvm::opt::ArgStringList& Files
bool IssueErrors = false
- Report failures as errors.

Returns

Whether all files were removed successfully.

bool CleanupFileMap(
    const clang::driver::ArgStringMap& Files,
    const clang::driver::JobAction* JA,
    bool IssueErrors = false) const

Description

CleanupFileMap - Remove the files in the given map.

Declared at: clang/include/clang/Driver/Compilation.h:290

Parameters

const clang::driver::ArgStringMap& Files
const clang::driver::JobAction* JA
- If specified, only delete the files associated with this JobAction. Otherwise, delete all files in the map.
bool IssueErrors = false
- Report failures as errors.

Returns

Whether all files were removed successfully.

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

Declared at: clang/include/clang/Driver/Compilation.h:133

Parameters

const clang::driver::Driver& D
const clang::driver::ToolChain& DefaultToolChain
llvm::opt::InputArgList* Args
llvm::opt::DerivedArgList* TranslatedArgs
bool ContainsError

int ExecuteCommand(
    const clang::driver::Command& C,
    const clang::driver::Command*& FailingCommand,
    bool LogOnly = false) const

Description

ExecuteCommand - Execute an actual command.

Declared at: clang/include/clang/Driver/Compilation.h:301

Parameters

const clang::driver::Command& C
const clang::driver::Command*& FailingCommand
- For non-zero results, this will be set to the Command which failed, if any.
bool LogOnly = false
- When true, only tries to log the command, not actually execute it.

Returns

The result code of the subprocess.

void ExecuteJobs(
    const clang::driver::JobList& Jobs,
    SmallVectorImpl<
        std::pair<int, const Command*>>&
        FailingCommands,
    bool LogOnly = false) const

Description

ExecuteJob - Execute a single job.

Declared at: clang/include/clang/Driver/Compilation.h:311

Parameters

const clang::driver::JobList& Jobs
SmallVectorImpl<std::pair<int, const Command*>>& FailingCommands
- For non-zero results, this will be a vector of failing commands and their associated result code.
bool LogOnly = false
- When true, only tries to log the command, not actually execute it.

template <typename T, typename... Args>
T* MakeAction(Args&&... Arg)

Description

Creates a new Action owned by this Compilation. The new Action is *not* added to the list returned by getActions().

Declared at: clang/include/clang/Driver/Compilation.h:208

Templates

T
Args

Parameters

Args&&... Arg

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

Description

Redirect - Redirect output of this compilation. Can only be done once.

Declared at: clang/include/clang/Driver/Compilation.h:335

Parameters

ArrayRef<Optional<llvm::StringRef>> 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).

void addCommand(std::unique_ptr<Command> C)

Declared at: clang/include/clang/Driver/Compilation.h:217

Parameters

std::unique_ptr<Command> C

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

Description

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

Declared at: clang/include/clang/Driver/Compilation.h:266

Parameters

const char* Name
const clang::driver::JobAction* JA

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

Declared at: clang/include/clang/Driver/Compilation.h:185

Parameters

const clang::driver::ToolChain* DeviceToolChain
Action::OffloadKind OffloadKind

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

Description

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

Declared at: clang/include/clang/Driver/Compilation.h:259

Parameters

const char* Name
const clang::driver::JobAction* JA

const char* addTempFile(const char* Name)

Description

addTempFile - Add a file to remove on exit, and returns its argument.

Declared at: clang/include/clang/Driver/Compilation.h:252

Parameters

const char* Name

bool containsError() const

Description

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

Declared at: clang/include/clang/Driver/Compilation.h:324

clang::driver::ActionList& getActions()

Declared at: clang/include/clang/Driver/Compilation.h:202

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

Declared at: clang/include/clang/Driver/Compilation.h:203

unsigned int getActiveOffloadKinds() const

Declared at: clang/include/clang/Driver/Compilation.h:146

llvm::opt::DerivedArgList& getArgs()

Declared at: clang/include/clang/Driver/Compilation.h:200

const llvm::opt::DerivedArgList& getArgs() const

Declared at: clang/include/clang/Driver/Compilation.h:198

const llvm::opt::DerivedArgList&
getArgsForToolChain(
    const clang::driver::ToolChain* TC,
    llvm::StringRef BoundArch,
    Action::OffloadKind DeviceOffloadKind)

Description

getArgsForToolChain - Return the derived argument list for the tool chain \p 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.

Declared at: clang/include/clang/Driver/Compilation.h:247

Parameters

const clang::driver::ToolChain* TC
llvm::StringRef BoundArch
- The bound architecture name, or 0.
Action::OffloadKind DeviceOffloadKind
- The offload device kind that should be used in the translation, if any.

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

Declared at: clang/include/clang/Driver/Compilation.h:140

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

Declared at: clang/include/clang/Driver/Compilation.h:138

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

Declared at: clang/include/clang/Driver/Compilation.h:223

const llvm::opt::InputArgList& getInputArgs()
    const

Declared at: clang/include/clang/Driver/Compilation.h:196

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

Declared at: clang/include/clang/Driver/Compilation.h:215

clang::driver::JobList& getJobs()

Declared at: clang/include/clang/Driver/Compilation.h:214

clang::driver::Compilation::
    const_offload_toolchains_range
    getOffloadToolChains(
        Action::OffloadKind Kind) const

Declared at: clang/include/clang/Driver/Compilation.h:162

Parameters

Action::OffloadKind Kind

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

Declared at: clang/include/clang/Driver/Compilation.h:157

Templates

Action::OffloadKind Kind

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

Declared at: clang/include/clang/Driver/Compilation.h:221

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

Description

Return an offload toolchain of the provided kind. Only one is expected to exist.

Declared at: clang/include/clang/Driver/Compilation.h:175

Templates

Action::OffloadKind Kind

llvm::StringRef getSysRoot() const

Description

Returns the sysroot path.

Declared at: clang/include/clang/Driver/Compilation.h:236

const llvm::opt::ArgStringList& getTempFiles()
    const

Declared at: clang/include/clang/Driver/Compilation.h:219

template <Action::OffloadKind Kind>
bool hasOffloadToolChain() const

Description

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

Declared at: clang/include/clang/Driver/Compilation.h:167

Templates

Action::OffloadKind Kind

void initCompilationForDiagnostics()

Description

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

Declared at: clang/include/clang/Driver/Compilation.h:318

bool isForDiagnostics() const

Description

Return true if we're compiling for diagnostics.

Declared at: clang/include/clang/Driver/Compilation.h:321

unsigned int isOffloadingHostKind(
    Action::OffloadKind Kind) const

Declared at: clang/include/clang/Driver/Compilation.h:142

Parameters

Action::OffloadKind Kind

void setContainsError()

Description

Force driver to fail before toolchain is created. This is necessary when error happens in action builder.

Declared at: clang/include/clang/Driver/Compilation.h:328

void setPostCallback(
    const std::function<void(const Command&,
                             int)>& CB)

Description

Installs a handler that is executed when a compilation job is finished. The arguments of the callback specify the compilation job as an instance of class Command and the exit status of the child process executed that job.

Declared at: clang/include/clang/Driver/Compilation.h:231

Parameters

const std::function<void(const Command&, int)>& CB

~Compilation()

Declared at: clang/include/clang/Driver/Compilation.h:136