summaryrefslogtreecommitdiff
path: root/include/clang/Driver/Job.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-01-18 16:23:48 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-01-18 16:23:48 +0000
commit06d4ba388873e6d1cfa9cd715a8935ecc8cd2097 (patch)
tree3eb853da77d46cc77c4b017525a422f9ddb1385b /include/clang/Driver/Job.h
parent30d791273d07fac9c0c1641a0731191bca6e8606 (diff)
downloadsrc-test2-06d4ba388873e6d1cfa9cd715a8935ecc8cd2097.tar.gz
src-test2-06d4ba388873e6d1cfa9cd715a8935ecc8cd2097.zip
Notes
Diffstat (limited to 'include/clang/Driver/Job.h')
-rw-r--r--include/clang/Driver/Job.h70
1 files changed, 56 insertions, 14 deletions
diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h
index 5b19efeddeea..b510676c09a7 100644
--- a/include/clang/Driver/Job.h
+++ b/include/clang/Driver/Job.h
@@ -7,11 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef CLANG_DRIVER_JOB_H_
-#define CLANG_DRIVER_JOB_H_
+#ifndef LLVM_CLANG_DRIVER_JOB_H
+#define LLVM_CLANG_DRIVER_JOB_H
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator.h"
#include "llvm/Option/Option.h"
#include <memory>
@@ -28,6 +29,14 @@ class Tool;
// Re-export this as clang::driver::ArgStringList.
using llvm::opt::ArgStringList;
+struct CrashReportInfo {
+ StringRef Filename;
+ StringRef VFSPath;
+
+ CrashReportInfo(StringRef Filename, StringRef VFSPath)
+ : Filename(Filename), VFSPath(VFSPath) {}
+};
+
class Job {
public:
enum JobClass {
@@ -51,9 +60,9 @@ public:
/// \param OS - The stream to print on.
/// \param Terminator - A string to print at the end of the line.
/// \param Quote - Should separate arguments be quoted.
- /// \param CrashReport - Whether to print for inclusion in a crash report.
- virtual void Print(llvm::raw_ostream &OS, const char *Terminator,
- bool Quote, bool CrashReport = false) const = 0;
+ /// \param CrashInfo - Details for inclusion in a crash report.
+ virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
+ CrashReportInfo *CrashInfo = nullptr) const = 0;
};
/// Command - An executable path/name and argument vector to
@@ -72,12 +81,36 @@ class Command : public Job {
/// argument, which will be the executable).
llvm::opt::ArgStringList Arguments;
+ /// Response file name, if this command is set to use one, or nullptr
+ /// otherwise
+ const char *ResponseFile;
+
+ /// The input file list in case we need to emit a file list instead of a
+ /// proper response file
+ llvm::opt::ArgStringList InputFileList;
+
+ /// String storage if we need to create a new argument to specify a response
+ /// file
+ std::string ResponseFileFlag;
+
+ /// When a response file is needed, we try to put most arguments in an
+ /// exclusive file, while others remains as regular command line arguments.
+ /// This functions fills a vector with the regular command line arguments,
+ /// argv, excluding the ones passed in a response file.
+ void buildArgvForResponseFile(llvm::SmallVectorImpl<const char *> &Out) const;
+
+ /// Encodes an array of C strings into a single string separated by whitespace.
+ /// This function will also put in quotes arguments that have whitespaces and
+ /// will escape the regular backslashes (used in Windows paths) and quotes.
+ /// The results are the contents of a response file, written into a raw_ostream.
+ void writeResponseFile(raw_ostream &OS) const;
+
public:
Command(const Action &_Source, const Tool &_Creator, const char *_Executable,
const llvm::opt::ArgStringList &_Arguments);
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
- bool CrashReport = false) const override;
+ CrashReportInfo *CrashInfo = nullptr) const override;
virtual int Execute(const StringRef **Redirects, std::string *ErrMsg,
bool *ExecutionFailed) const;
@@ -88,6 +121,15 @@ public:
/// getCreator - Return the Tool which caused the creation of this job.
const Tool &getCreator() const { return Creator; }
+ /// Set to pass arguments via a response file when launching the command
+ void setResponseFile(const char *FileName);
+
+ /// Set an input file list, necessary if we need to use a response file but
+ /// the tool being called only supports input files lists.
+ void setInputFileList(llvm::opt::ArgStringList List) {
+ InputFileList = std::move(List);
+ }
+
const char *getExecutable() const { return Executable; }
const llvm::opt::ArgStringList &getArguments() const { return Arguments; }
@@ -104,10 +146,10 @@ class FallbackCommand : public Command {
public:
FallbackCommand(const Action &Source_, const Tool &Creator_,
const char *Executable_, const ArgStringList &Arguments_,
- Command *Fallback_);
+ std::unique_ptr<Command> Fallback_);
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
- bool CrashReport = false) const override;
+ CrashReportInfo *CrashInfo = nullptr) const override;
int Execute(const StringRef **Redirects, std::string *ErrMsg,
bool *ExecutionFailed) const override;
@@ -123,23 +165,23 @@ private:
/// JobList - A sequence of jobs to perform.
class JobList : public Job {
public:
- typedef SmallVector<Job*, 4> list_type;
+ typedef SmallVector<std::unique_ptr<Job>, 4> list_type;
typedef list_type::size_type size_type;
- typedef list_type::iterator iterator;
- typedef list_type::const_iterator const_iterator;
+ typedef llvm::pointee_iterator<list_type::iterator> iterator;
+ typedef llvm::pointee_iterator<list_type::const_iterator> const_iterator;
private:
list_type Jobs;
public:
JobList();
- virtual ~JobList();
+ virtual ~JobList() {}
void Print(llvm::raw_ostream &OS, const char *Terminator,
- bool Quote, bool CrashReport = false) const override;
+ bool Quote, CrashReportInfo *CrashInfo = nullptr) const override;
/// Add a job to the list (taking ownership).
- void addJob(Job *J) { Jobs.push_back(J); }
+ void addJob(std::unique_ptr<Job> J) { Jobs.push_back(std::move(J)); }
/// Clear the job list.
void clear();