diff options
author | Ed Schouten <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | ec2b103c267a06a66e926f62cd96767b280f5cf5 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /include/clang/Driver/Compilation.h | |
download | src-ec2b103c267a06a66e926f62cd96767b280f5cf5.tar.gz src-ec2b103c267a06a66e926f62cd96767b280f5cf5.zip |
Import Clang, at r72732.vendor/clang/clang-r72732
Notes
Notes:
svn path=/vendor/clang/dist/; revision=193326
svn path=/vendor/clang/clang-r72732/; revision=193327; tag=vendor/clang/clang-r72732
Diffstat (limited to 'include/clang/Driver/Compilation.h')
-rw-r--r-- | include/clang/Driver/Compilation.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/include/clang/Driver/Compilation.h b/include/clang/Driver/Compilation.h new file mode 100644 index 000000000000..4985f30ad553 --- /dev/null +++ b/include/clang/Driver/Compilation.h @@ -0,0 +1,127 @@ +//===--- Compilation.h - Compilation Task Data Structure --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_DRIVER_COMPILATION_H_ +#define CLANG_DRIVER_COMPILATION_H_ + +#include "clang/Driver/Job.h" +#include "clang/Driver/Util.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" + +namespace llvm { + class raw_ostream; +} + +namespace clang { +namespace driver { + class DerivedArgList; + class Driver; + class InputArgList; + class JobList; + class ToolChain; + +/// Compilation - A set of tasks to perform for a single driver +/// invocation. +class Compilation { + /// The driver we were created by. + Driver &TheDriver; + + /// The default tool chain. + ToolChain &DefaultToolChain; + + /// The original (untranslated) input argument list. + InputArgList *Args; + + /// The list of actions. + ActionList Actions; + + /// The root list of jobs. + JobList Jobs; + + /// Cache of translated arguments for a particular tool chain. + llvm::DenseMap<const ToolChain*, DerivedArgList*> TCArgs; + + /// Temporary files which should be removed on exit. + ArgStringList TempFiles; + + /// Result files which should be removed on failure. + ArgStringList ResultFiles; + +public: + Compilation(Driver &D, ToolChain &DefaultToolChain, InputArgList *Args); + ~Compilation(); + + const Driver &getDriver() const { return TheDriver; } + + const ToolChain &getDefaultToolChain() const { return DefaultToolChain; } + + const InputArgList &getArgs() const { return *Args; } + + ActionList &getActions() { return Actions; } + const ActionList &getActions() const { return Actions; } + + JobList &getJobs() { return Jobs; } + + /// getArgsForToolChain - Return the derived argument list for the + /// tool chain \arg TC (or the default tool chain, if TC is not + /// specified). + const DerivedArgList &getArgsForToolChain(const ToolChain *TC = 0); + + /// addTempFile - Add a file to remove on exit, and returns its + /// argument. + const char *addTempFile(const char *Name) { + TempFiles.push_back(Name); + return Name; + } + + /// addResultFile - Add a file to remove on failure, and returns its + /// argument. + const char *addResultFile(const char *Name) { + ResultFiles.push_back(Name); + return Name; + } + + /// Execute - Execute the compilation jobs and return an + /// appropriate exit code. + int Execute() const; + +private: + /// CleanupFileList - Remove the files in the given list. + /// + /// \param IssueErrors - Report failures as errors. + /// \return Whether all files were removed successfully. + bool CleanupFileList(const ArgStringList &Files, + bool IssueErrors=false) const; + + /// PrintJob - Print one job in -### format. + /// + /// OS - The stream to print on. + /// J - The job to print. + /// Terminator - A string to print at the end of the line. + /// Quote - Should separate arguments be quoted. + void PrintJob(llvm::raw_ostream &OS, const Job &J, + const char *Terminator, bool Quote) const; + + /// ExecuteCommand - Execute an actual command. + /// + /// \return The result code of the subprocess. + int ExecuteCommand(const Command &C) const; + + /// ExecuteJob - Execute a single job. + /// + /// \return The accumulated result code of the job. + int ExecuteJob(const Job &J) const; +}; + +} // end namespace driver +} // end namespace clang + +#endif |