[llvm] r183940 - Avoid using PathV1.h in Program.h.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 13 13:25:38 PDT 2013
Author: rafael
Date: Thu Jun 13 15:25:38 2013
New Revision: 183940
URL: http://llvm.org/viewvc/llvm-project?rev=183940&view=rev
Log:
Avoid using PathV1.h in Program.h.
Modified:
llvm/trunk/include/llvm/Support/Program.h
llvm/trunk/lib/Support/GraphWriter.cpp
llvm/trunk/lib/Support/Program.cpp
llvm/trunk/lib/Support/SystemUtils.cpp
llvm/trunk/tools/bugpoint/OptimizerDriver.cpp
llvm/trunk/tools/bugpoint/ToolRunner.cpp
llvm/trunk/tools/gold/gold-plugin.cpp
llvm/trunk/unittests/Support/ProgramTest.cpp
llvm/trunk/utils/not/not.cpp
Modified: llvm/trunk/include/llvm/Support/Program.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Program.h?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Program.h (original)
+++ llvm/trunk/include/llvm/Support/Program.h Thu Jun 13 15:25:38 2013
@@ -16,7 +16,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/PathV1.h"
#include "llvm/Support/system_error.h"
namespace llvm {
@@ -48,21 +47,20 @@ namespace sys {
/// -1 indicates failure to execute
/// -2 indicates a crash during execution or timeout
int ExecuteAndWait(
- const Path &path, ///< sys::Path object providing the path of the
- ///< program to be executed. It is presumed this is the result of
- ///< the FindProgramByName method.
+ StringRef Program, ///< Path of the program to be executed. It is
+ /// presumed this is the result of the FindProgramByName method.
const char **args, ///< A vector of strings that are passed to the
///< program. The first element should be the name of the program.
///< The list *must* be terminated by a null char* entry.
const char **env = 0, ///< An optional vector of strings to use for
///< the program's environment. If not provided, the current program's
///< environment will be used.
- const sys::Path **redirects = 0, ///< An optional array of pointers to
- ///< Paths. If the array is null, no redirection is done. The array
- ///< should have a size of at least three. If the pointer in the array
- ///< are not null, then the inferior process's stdin(0), stdout(1),
- ///< and stderr(2) will be redirected to the corresponding Paths.
- ///< When an empty Path is passed in, the corresponding file
+ const StringRef **redirects = 0, ///< An optional array of pointers to
+ ///< paths. If the array is null, no redirection is done. The array
+ ///< should have a size of at least three. The inferior process's
+ ///< stdin(0), stdout(1), and stderr(2) will be redirected to the
+ ///< corresponding paths.
+ ///< When an empty path is passed in, the corresponding file
///< descriptor will be disconnected (ie, /dev/null'd) in a portable
///< way.
unsigned secondsToWait = 0, ///< If non-zero, this specifies the amount
@@ -80,14 +78,9 @@ namespace sys {
///< program.
bool *ExecutionFailed = 0);
- int ExecuteAndWait(StringRef path, const char **args, const char **env = 0,
- const StringRef **redirects = 0,
- unsigned secondsToWait = 0, unsigned memoryLimit = 0,
- std::string *ErrMsg = 0, bool *ExecutionFailed = 0);
-
/// Similar to ExecuteAndWait, but return immediately.
- void ExecuteNoWait(const Path &path, const char **args, const char **env = 0,
- const sys::Path **redirects = 0, unsigned memoryLimit = 0,
+ void ExecuteNoWait(StringRef Program, const char **args, const char **env = 0,
+ const StringRef **redirects = 0, unsigned memoryLimit = 0,
std::string *ErrMsg = 0);
// Return true if the given arguments fit within system-specific
Modified: llvm/trunk/lib/Support/GraphWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/GraphWriter.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/lib/Support/GraphWriter.cpp (original)
+++ llvm/trunk/lib/Support/GraphWriter.cpp Thu Jun 13 15:25:38 2013
@@ -16,6 +16,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/PathV1.h"
#include "llvm/Support/Program.h"
using namespace llvm;
@@ -85,7 +86,7 @@ static bool LLVM_ATTRIBUTE_UNUSED
ExecGraphViewer(StringRef ExecPath, std::vector<const char*> &args,
StringRef Filename, bool wait, std::string &ErrMsg) {
if (wait) {
- if (sys::ExecuteAndWait(sys::Path(ExecPath), &args[0],0,0,0,0,&ErrMsg)) {
+ if (sys::ExecuteAndWait(ExecPath, &args[0],0,0,0,0,&ErrMsg)) {
errs() << "Error: " << ErrMsg << "\n";
return false;
}
@@ -94,7 +95,7 @@ ExecGraphViewer(StringRef ExecPath, std:
errs() << " done. \n";
}
else {
- sys::ExecuteNoWait(sys::Path(ExecPath), &args[0],0,0,0,&ErrMsg);
+ sys::ExecuteNoWait(ExecPath, &args[0],0,0,0,&ErrMsg);
errs() << "Remember to erase graph file: " << Filename.str() << "\n";
}
return true;
Modified: llvm/trunk/lib/Support/Program.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Program.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Program.cpp (original)
+++ llvm/trunk/lib/Support/Program.cpp Thu Jun 13 15:25:38 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Program.h"
+#include "llvm/Support/PathV1.h"
#include "llvm/Config/config.h"
#include "llvm/Support/system_error.h"
using namespace llvm;
@@ -29,46 +30,50 @@ static bool Execute(void **Data, const P
static int Wait(void *&Data, const Path &path, unsigned secondsToWait,
std::string *ErrMsg);
-int sys::ExecuteAndWait(StringRef path, const char **args, const char **env,
- const StringRef **redirects, unsigned secondsToWait,
- unsigned memoryLimit, std::string *ErrMsg,
- bool *ExecutionFailed) {
- Path P(path);
- if (!redirects)
- return ExecuteAndWait(P, args, env, 0, secondsToWait, memoryLimit, ErrMsg,
- ExecutionFailed);
+
+static bool Execute(void **Data, StringRef Program, const char **args,
+ const char **env, const StringRef **Redirects,
+ unsigned memoryLimit, std::string *ErrMsg) {
+ Path P(Program);
+ if (!Redirects)
+ return Execute(Data, P, args, env, 0, memoryLimit, ErrMsg);
Path IO[3];
const Path *IOP[3];
for (int I = 0; I < 3; ++I) {
- if (redirects[I]) {
- IO[I] = *redirects[I];
+ if (Redirects[I]) {
+ IO[I] = *Redirects[I];
IOP[I] = &IO[I];
} else {
IOP[I] = 0;
- }
+ }
}
- return ExecuteAndWait(P, args, env, IOP, secondsToWait, memoryLimit, ErrMsg,
- ExecutionFailed);
+ return Execute(Data, P, args, env, IOP, memoryLimit, ErrMsg);
}
-int sys::ExecuteAndWait(const Path &path, const char **args, const char **envp,
- const Path **redirects, unsigned secondsToWait,
+static int Wait(void *&Data, StringRef Program, unsigned secondsToWait,
+ std::string *ErrMsg) {
+ Path P(Program);
+ return Wait(Data, P, secondsToWait, ErrMsg);
+}
+
+int sys::ExecuteAndWait(StringRef Program, const char **args, const char **envp,
+ const StringRef **redirects, unsigned secondsToWait,
unsigned memoryLimit, std::string *ErrMsg,
bool *ExecutionFailed) {
void *Data = 0;
- if (Execute(&Data, path, args, envp, redirects, memoryLimit, ErrMsg)) {
+ if (Execute(&Data, Program, args, envp, redirects, memoryLimit, ErrMsg)) {
if (ExecutionFailed) *ExecutionFailed = false;
- return Wait(Data, path, secondsToWait, ErrMsg);
+ return Wait(Data, Program, secondsToWait, ErrMsg);
}
if (ExecutionFailed) *ExecutionFailed = true;
return -1;
}
-void sys::ExecuteNoWait(const Path &path, const char **args, const char **envp,
- const Path **redirects, unsigned memoryLimit,
+void sys::ExecuteNoWait(StringRef Program, const char **args, const char **envp,
+ const StringRef **redirects, unsigned memoryLimit,
std::string *ErrMsg) {
- Execute(/*Data*/ 0, path, args, envp, redirects, memoryLimit, ErrMsg);
+ Execute(/*Data*/ 0, Program, args, envp, redirects, memoryLimit, ErrMsg);
}
// Include the platform-specific parts of this class.
Modified: llvm/trunk/lib/Support/SystemUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SystemUtils.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SystemUtils.cpp (original)
+++ llvm/trunk/lib/Support/SystemUtils.cpp Thu Jun 13 15:25:38 2013
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/SystemUtils.h"
+#include "llvm/Support/PathV1.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
Modified: llvm/trunk/tools/bugpoint/OptimizerDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/OptimizerDriver.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/OptimizerDriver.cpp (original)
+++ llvm/trunk/tools/bugpoint/OptimizerDriver.cpp Thu Jun 13 15:25:38 2013
@@ -200,12 +200,12 @@ bool BugDriver::runPasses(Module *Progra
prog = tool;
// Redirect stdout and stderr to nowhere if SilencePasses is given
- sys::Path Nowhere;
- const sys::Path *Redirects[3] = {0, &Nowhere, &Nowhere};
+ StringRef Nowhere;
+ const StringRef *Redirects[3] = {0, &Nowhere, &Nowhere};
- int result =
- sys::ExecuteAndWait(prog, Args.data(), 0, (SilencePasses ? Redirects : 0),
- Timeout, MemoryLimit, &ErrMsg);
+ int result = sys::ExecuteAndWait(prog.str(), Args.data(), 0,
+ (SilencePasses ? Redirects : 0), Timeout,
+ MemoryLimit, &ErrMsg);
// If we are supposed to delete the bitcode file or if the passes crashed,
// remove it now. This may fail if the file was never created, but that's ok.
Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original)
+++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Thu Jun 13 15:25:38 2013
@@ -61,11 +61,7 @@ static int RunProgramWithTimeout(StringR
unsigned NumSeconds = 0,
unsigned MemoryLimit = 0,
std::string *ErrMsg = 0) {
- const sys::Path P[3] = { sys::Path(StdInFile), sys::Path(StdOutFile),
- sys::Path(StdErrFile) };
- const sys::Path* redirects[3];
- for (int I = 0; I < 3; ++I)
- redirects[I] = &P[I];
+ const StringRef *Redirects[3] = { &StdInFile, &StdOutFile, &StdErrFile };
#if 0 // For debug purposes
{
@@ -76,7 +72,7 @@ static int RunProgramWithTimeout(StringR
}
#endif
- return sys::ExecuteAndWait(sys::Path(ProgramPath), Args, 0, redirects,
+ return sys::ExecuteAndWait(ProgramPath, Args, 0, Redirects,
NumSeconds, MemoryLimit, ErrMsg);
}
@@ -93,11 +89,7 @@ static int RunProgramRemotelyWithTimeout
StringRef StdErrFile,
unsigned NumSeconds = 0,
unsigned MemoryLimit = 0) {
- const sys::Path P[3] = { sys::Path(StdInFile), sys::Path(StdOutFile),
- sys::Path(StdErrFile) };
- const sys::Path* redirects[3];
- for (int I = 0; I < 3; ++I)
- redirects[I] = &P[I];
+ const StringRef *Redirects[3] = { &StdInFile, &StdOutFile, &StdErrFile };
#if 0 // For debug purposes
{
@@ -109,8 +101,8 @@ static int RunProgramRemotelyWithTimeout
#endif
// Run the program remotely with the remote client
- int ReturnCode = sys::ExecuteAndWait(sys::Path(RemoteClientPath), Args, 0,
- redirects, NumSeconds, MemoryLimit);
+ int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, 0,
+ Redirects, NumSeconds, MemoryLimit);
// Has the remote client fail?
if (255 == ReturnCode) {
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Thu Jun 13 15:25:38 2013
@@ -19,6 +19,7 @@
#include "llvm/Support/Errno.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/PathV1.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/system_error.h"
Modified: llvm/trunk/unittests/Support/ProgramTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ProgramTest.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ProgramTest.cpp (original)
+++ llvm/trunk/unittests/Support/ProgramTest.cpp Thu Jun 13 15:25:38 2013
@@ -9,6 +9,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/PathV1.h"
#include "llvm/Support/Program.h"
#include "gtest/gtest.h"
@@ -74,14 +75,14 @@ TEST(ProgramTest, CreateProcessTrailingS
bool ExecutionFailed;
// Redirect stdout and stdin to NUL, but let stderr through.
#ifdef LLVM_ON_WIN32
- Path nul("NUL");
+ StringRef nul("NUL");
#else
- Path nul("/dev/null");
+ StringRef nul("/dev/null");
#endif
- const Path *redirects[] = { &nul, &nul, 0 };
- int rc =
- ExecuteAndWait(my_exe, argv, &envp[0], redirects, /*secondsToWait=*/ 10,
- /*memoryLimit=*/ 0, &error, &ExecutionFailed);
+ const StringRef *redirects[] = { &nul, &nul, 0 };
+ int rc = ExecuteAndWait(my_exe.str(), argv, &envp[0], redirects,
+ /*secondsToWait=*/ 10, /*memoryLimit=*/ 0, &error,
+ &ExecutionFailed);
EXPECT_FALSE(ExecutionFailed) << error;
EXPECT_EQ(0, rc);
}
Modified: llvm/trunk/utils/not/not.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/not/not.cpp?rev=183940&r1=183939&r2=183940&view=diff
==============================================================================
--- llvm/trunk/utils/not/not.cpp (original)
+++ llvm/trunk/utils/not/not.cpp Thu Jun 13 15:25:38 2013
@@ -16,8 +16,7 @@ int main(int argc, const char **argv) {
std::string Program = sys::FindProgramByName(argv[1]);
std::string ErrMsg;
- int Result =
- sys::ExecuteAndWait(sys::Path(Program), argv + 1, 0, 0, 0, 0, &ErrMsg);
+ int Result = sys::ExecuteAndWait(Program, argv + 1, 0, 0, 0, 0, &ErrMsg);
if (Result < 0) {
errs() << "Error: " << ErrMsg << "\n";
return 1;
More information about the llvm-commits
mailing list