summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-11-02 20:32:39 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-11-02 20:32:39 +0000
commita581d8a27aa6c7d582ee73136e888821493f31bb (patch)
tree785608408c3c7ed03dba97acf9fe41c1f5b0788a
parentb4921a035e0142b270ece4b574a4ea06ed20aa72 (diff)
downloadbcm5719-llvm-a581d8a27aa6c7d582ee73136e888821493f31bb.tar.gz
bcm5719-llvm-a581d8a27aa6c7d582ee73136e888821493f31bb.zip
Make FindProgramByName return paths with slashes unmodified on Windows.
This makes its behaviour more consistent across platforms. llvm-svn: 118048
-rw-r--r--llvm/include/llvm/System/Program.h3
-rw-r--r--llvm/lib/System/Unix/Program.inc4
-rw-r--r--llvm/lib/System/Win32/Program.inc6
3 files changed, 8 insertions, 5 deletions
diff --git a/llvm/include/llvm/System/Program.h b/llvm/include/llvm/System/Program.h
index 0c14076e309..c595082e8ba 100644
--- a/llvm/include/llvm/System/Program.h
+++ b/llvm/include/llvm/System/Program.h
@@ -114,7 +114,8 @@ namespace sys {
/// This static constructor (factory) will attempt to locate a program in
/// the operating system's file system using some pre-determined set of
- /// locations to search (e.g. the PATH on Unix).
+ /// locations to search (e.g. the PATH on Unix). Paths with slashes are
+ /// returned unmodified.
/// @returns A Path object initialized to the path of the program or a
/// Path object that is empty (invalid) if the program could not be found.
/// @brief Construct a Program by finding it by name.
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc
index 86d9b2a1d9a..e06f80ba833 100644
--- a/llvm/lib/System/Unix/Program.inc
+++ b/llvm/lib/System/Unix/Program.inc
@@ -66,8 +66,8 @@ Program::FindProgramByName(const std::string& progName) {
if (progName.find('/') != std::string::npos)
return temp;
- // At this point, the file name does not contain slashes. Search for it
- // through the directories specified in the PATH environment variable.
+ // At this point, the file name is valid and does not contain slashes. Search
+ // for it through the directories specified in the PATH environment variable.
// Get the path. If its empty, we can't do anything to find it.
const char *PathStr = getenv("PATH");
diff --git a/llvm/lib/System/Win32/Program.inc b/llvm/lib/System/Win32/Program.inc
index b55aa2fa80f..2d6e665377e 100644
--- a/llvm/lib/System/Win32/Program.inc
+++ b/llvm/lib/System/Win32/Program.inc
@@ -67,10 +67,12 @@ Program::FindProgramByName(const std::string& progName) {
Path temp;
if (!temp.set(progName)) // invalid name
return Path();
- if (temp.canExecute()) // already executable as is
+ // Return paths with slashes verbatim.
+ if (progName.find('\\') != std::string::npos ||
+ progName.find('/') != std::string::npos)
return temp;
- // At this point, the file name is valid and its not executable.
+ // At this point, the file name is valid and does not contain slashes.
// Let Windows search for it.
char buffer[MAX_PATH];
char *dummy = NULL;
OpenPOWER on IntegriCloud