avoid temporary std::string in non posix_spawn path.
authorChris Lattner <sabre@nondot.org>
Sun, 18 Apr 2010 17:34:10 +0000 (17:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 18 Apr 2010 17:34:10 +0000 (17:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101723 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Program.inc

index 6b5dc233aa343940d2b2c3cca5dd444e282a3e59..47afe52f51d756c2c8351b8cf52d14ac29b6f600 100644 (file)
@@ -104,17 +104,17 @@ Program::FindProgramByName(const std::string& progName) {
 static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) {
   if (Path == 0) // Noop
     return false;
-  std::string File;
+  const char *File;
   if (Path->isEmpty())
     // Redirect empty paths to /dev/null
     File = "/dev/null";
   else
-    File = Path->str();
+    File = Path->c_str();
 
   // Open the file
-  int InFD = open(File.c_str(), FD == 0 ? O_RDONLY : O_WRONLY|O_CREAT, 0666);
+  int InFD = open(File, FD == 0 ? O_RDONLY : O_WRONLY|O_CREAT, 0666);
   if (InFD == -1) {
-    MakeErrMsg(ErrMsg, "Cannot open file '" + File + "' for "
+    MakeErrMsg(ErrMsg, "Cannot open file '" + std::string(File) + "' for "
               + (FD == 0 ? "input" : "output"));
     return true;
   }