summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-18 07:06:02 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-18 07:06:02 +0000
commit871adcf4e41285e3f4c3b62eaa1b2e05b60b92da (patch)
tree779a51cca6bd05510c46bdaeb56219ac2725ad16
parentaa469f62f2b3ba6f560ccadfc379f8f4c45e3d51 (diff)
Driver: ConstructJob also needs to know the destination (where to put
its commands). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67179 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/Job.h5
-rw-r--r--include/clang/Driver/Tool.h3
-rw-r--r--lib/Driver/Driver.cpp3
-rw-r--r--lib/Driver/InputInfo.h2
-rw-r--r--lib/Driver/Job.cpp8
-rw-r--r--lib/Driver/Tools.cpp27
-rw-r--r--lib/Driver/Tools.h6
7 files changed, 47 insertions, 7 deletions
diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h
index d8737393aa..f60f514641 100644
--- a/include/clang/Driver/Job.h
+++ b/include/clang/Driver/Job.h
@@ -22,6 +22,7 @@ using llvm::dyn_cast_or_null;
namespace clang {
namespace driver {
+ class Command;
class Job {
public:
@@ -41,6 +42,10 @@ public:
JobClass getKind() const { return Kind; }
+ /// addCommand - Append a command to the current job, which must be
+ /// either a piped job or a job list.
+ void addCommand(Command *C);
+
static bool classof(const Job *) { return true; }
};
diff --git a/include/clang/Driver/Tool.h b/include/clang/Driver/Tool.h
index 070a162957..d8b37e9ead 100644
--- a/include/clang/Driver/Tool.h
+++ b/include/clang/Driver/Tool.h
@@ -19,6 +19,7 @@ namespace driver {
class ArgList;
class Compilation;
class InputInfo;
+ class Job;
class JobAction;
class ToolChain;
@@ -49,11 +50,13 @@ public:
/// ConstructJob - Construct jobs to perform the action \arg JA,
/// writing to \arg Output and with \arg Inputs.
///
+ /// \param Dest - Where to put the resulting commands.
/// \param TCArgs - The argument list for this toolchain, with any
/// tool chain specific translations applied.
/// \param LinkingOutput - If this output will eventually feed the
/// linker, then this is the final output name of the linked image.
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 1e4cd7f478..f06166e930 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -751,6 +751,7 @@ void Driver::BuildJobsForAction(Compilation &C,
if (!PJ) {
PJ = new PipedJob();
cast<JobList>(Dest)->addJob(PJ);
+ Dest = PJ;
}
Result = InputInfo(PJ, A->getType(), BaseInput);
} else {
@@ -768,7 +769,7 @@ void Driver::BuildJobsForAction(Compilation &C,
llvm::errs() << "], output: " << Result.getAsString() << "\n";
} else {
const ArgList &TCArgs = C.getArgsForToolChain(TC);
- T.ConstructJob(C, *JA, Result, InputInfos, TCArgs, LinkingOutput);
+ T.ConstructJob(C, *JA, *Dest, Result, InputInfos, TCArgs, LinkingOutput);
}
}
diff --git a/lib/Driver/InputInfo.h b/lib/Driver/InputInfo.h
index 6cef821e39..617e70365d 100644
--- a/lib/Driver/InputInfo.h
+++ b/lib/Driver/InputInfo.h
@@ -10,6 +10,8 @@
#ifndef CLANG_LIB_DRIVER_INPUTINFO_H_
#define CLANG_LIB_DRIVER_INPUTINFO_H_
+#include "clang/Driver/Types.h"
+
#include <cassert>
#include <string>
diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp
index 1efc38a8e8..222cf15db6 100644
--- a/lib/Driver/Job.cpp
+++ b/lib/Driver/Job.cpp
@@ -21,3 +21,11 @@ Command::Command(const char *_Executable, const ArgStringList &_Arguments)
PipedJob::PipedJob() : Job(PipedJobClass) {}
JobList::JobList() : Job(JobListClass) {}
+
+void Job::addCommand(Command *C) {
+ if (PipedJob *PJ = dyn_cast<PipedJob>(this))
+ PJ->addCommand(C);
+ else
+ cast<JobList>(this)->addJob(C);
+}
+
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 25023c16ef..20c307417c 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -9,18 +9,29 @@
#include "Tools.h"
+#include "clang/Driver/Arg.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Job.h"
+#include "clang/Driver/Util.h"
+
+#include "llvm/ADT/SmallVector.h"
+
+#include "InputInfo.h"
+
using namespace clang::driver;
using namespace clang::driver::tools;
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
+ Job &Dest,
+ const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
const char *LinkingOutput) const {
}
void gcc::Preprocess::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
+ Job &Dest,
+ const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
const char *LinkingOutput) const {
@@ -28,7 +39,8 @@ void gcc::Preprocess::ConstructJob(Compilation &C, const JobAction &JA,
}
void gcc::Precompile::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
+ Job &Dest,
+ const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
const char *LinkingOutput) const {
@@ -36,7 +48,8 @@ void gcc::Precompile::ConstructJob(Compilation &C, const JobAction &JA,
}
void gcc::Compile::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
+ Job &Dest,
+ const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
const char *LinkingOutput) const {
@@ -44,7 +57,8 @@ void gcc::Compile::ConstructJob(Compilation &C, const JobAction &JA,
}
void gcc::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
+ Job &Dest,
+ const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
const char *LinkingOutput) const {
@@ -52,7 +66,8 @@ void gcc::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
}
void gcc::Link::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
+ Job &Dest,
+ const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
const char *LinkingOutput) const {
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index d774e02ff0..83dab0604e 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -27,6 +27,7 @@ namespace tools {
virtual bool hasIntegratedCPP() const { return true; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@@ -44,6 +45,7 @@ namespace gcc {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@@ -59,6 +61,7 @@ namespace gcc {
virtual bool hasIntegratedCPP() const { return true; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@@ -74,6 +77,7 @@ namespace gcc {
virtual bool hasIntegratedCPP() const { return true; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@@ -89,6 +93,7 @@ namespace gcc {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@@ -104,6 +109,7 @@ namespace gcc {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,