summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Compilation.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/Compilation.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/Compilation.cpp')
-rw-r--r--clang/lib/Driver/Compilation.cpp12
1 files changed, 1 insertions, 11 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index 5e7babef0da..f077fd68cc4 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -16,7 +16,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
#include <errno.h>
#include <sys/stat.h>
@@ -129,12 +128,6 @@ bool Compilation::CleanupFileMap(const ArgStringMap &Files,
int Compilation::ExecuteCommand(const Command &C,
const Command *&FailingCommand) const {
- std::string Prog(C.getExecutable());
- const char **Argv = new const char*[C.getArguments().size() + 2];
- Argv[0] = C.getExecutable();
- std::copy(C.getArguments().begin(), C.getArguments().end(), Argv+1);
- Argv[C.getArguments().size() + 1] = 0;
-
if ((getDriver().CCPrintOptions ||
getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) {
raw_ostream *OS = &llvm::errs();
@@ -165,9 +158,7 @@ int Compilation::ExecuteCommand(const Command &C,
std::string Error;
bool ExecutionFailed;
- int Res = llvm::sys::ExecuteAndWait(Prog, Argv, /*env*/ 0, Redirects,
- /*secondsToWait*/ 0, /*memoryLimit*/ 0,
- &Error, &ExecutionFailed);
+ int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
if (!Error.empty()) {
assert(Res && "Error string set with 0 result code!");
getDriver().Diag(clang::diag::err_drv_command_failure) << Error;
@@ -176,7 +167,6 @@ int Compilation::ExecuteCommand(const Command &C,
if (Res)
FailingCommand = &C;
- delete[] Argv;
return ExecutionFailed ? 1 : Res;
}
OpenPOWER on IntegriCloud