summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Job.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-09-12 18:35:08 +0000
committerHans Wennborg <hans@hanshq.net>2013-09-12 18:35:08 +0000
commite8677ef5ca51560e223377da7cb686614749a5e7 (patch)
tree4249b5b88dc9118098ac2ed8301d4aa9b2e426a6 /clang/lib/Driver/Job.cpp
parentb212b34f19472469c1d20ada3161c3523268d5be (diff)
downloadbcm5719-llvm-e8677ef5ca51560e223377da7cb686614749a5e7.tar.gz
bcm5719-llvm-e8677ef5ca51560e223377da7cb686614749a5e7.zip
Move the execution code from Compilation::ExecuteCommand to Command::Execute
I think it makes sense that a Command knows how to execute itself. There's no functionality change but i rewrote the code to avoid the manual memory management of Argv. My motivation for this is that I plan to subclass Command to build fall-back functionality into clang-cl. Differential Revision: http://llvm-reviews.chandlerc.com/D1654 llvm-svn: 190621
Diffstat (limited to 'clang/lib/Driver/Job.cpp')
-rw-r--r--clang/lib/Driver/Job.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 116fbd0541f..0a783eb93b1 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
using namespace clang::driver;
@@ -112,6 +113,19 @@ void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
OS << Terminator;
}
+int Command::Execute(const llvm::StringRef **Redirects, std::string *ErrMsg,
+ bool *ExecutionFailed) const {
+ SmallVector<const char*, 128> Argv;
+ Argv.push_back(Executable);
+ for (size_t i = 0, e = Arguments.size(); i != e; ++i)
+ Argv.push_back(Arguments[i]);
+ Argv.push_back(0);
+
+ return llvm::sys::ExecuteAndWait(Executable, Argv.data(), /*env*/ 0,
+ Redirects, /*secondsToWait*/ 0,
+ /*memoryLimit*/ 0, ErrMsg, ExecutionFailed);
+}
+
JobList::JobList() : Job(JobListClass) {}
JobList::~JobList() {
OpenPOWER on IntegriCloud