Apply "Win32's Hybrid path separator in argv[0] should be accepted to bugpoint",
authorChris Lattner <sabre@nondot.org>
Tue, 24 Aug 2010 17:44:07 +0000 (17:44 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 24 Aug 2010 17:44:07 +0000 (17:44 +0000)
patch by NAKAMURA Takumi!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111929 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/OptimizerDriver.cpp

index 6d37761bcdeae47cd6165d7ee584fa0808ba40b1..8f5ab722f02525a16d822ac76774101e48316c6b 100644 (file)
@@ -27,6 +27,7 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
@@ -150,16 +151,8 @@ bool BugDriver::runPasses(Module *Program,
 
   // setup the child process' arguments
   SmallVector<const char*, 8> Args;
-  std::string Opt;
-  llvm::StringRef TN(ToolName);
-  if (TN.find('/') == llvm::StringRef::npos) {
-    Opt = "opt";
-  } else {
-    std::pair<llvm::StringRef, llvm::StringRef> P = TN.rsplit('/');
-    Opt = P.first.str() + "/" + "opt";
-  }
-
-  sys::Path tool = sys::Program::FindProgramByName(Opt);
+  sys::Path tool = FindExecutable("opt", getToolName(), (void*)"opt");
+  std::string Opt = tool.str();
   if (UseValgrind) {
     Args.push_back("valgrind");
     Args.push_back("--error-exitcode=1");