Add .exe check to Execute to fix clang-modernize tests broken in r247358
authorReid Kleckner <rnk@google.com>
Thu, 10 Sep 2015 23:59:45 +0000 (23:59 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 10 Sep 2015 23:59:45 +0000 (23:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247361 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Windows/Program.inc

index c29d8729b1de7ff474655ca754226a0f35e79238..fe83118b0647d2108b15b12f03b8fb9975fa2097 100644 (file)
@@ -251,6 +251,14 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
     return false;
   }
 
+  // can_execute may succeed by looking at Program + ".exe". CreateProcessW
+  // will implicitly add the .exe if we provide a command line without an
+  // executable path, but since we use an explicit executable, we have to add
+  // ".exe" ourselves.
+  SmallString<64> ProgramStorage;
+  if (!sys::fs::exists(Program))
+    Program = Twine(Program + ".exe").toStringRef(ProgramStorage);
+
   // Windows wants a command line, not an array of args, to pass to the new
   // process.  We have to concatenate them all, while quoting the args that
   // have embedded spaces (or are empty).