diff options
author | Dan Gohman <gohman@apple.com> | 2010-09-02 22:32:38 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-09-02 22:32:38 +0000 |
commit | 2adf2f27147218379fd31e2ec5e9539602cd0d7e (patch) | |
tree | afbae4611db79a67b4aa34a310d0c0679aa26bfb /llvm/lib/Support/SystemUtils.cpp | |
parent | a18d7ec4fbf49248a6ad8fe839abab9248bf1c96 (diff) | |
download | bcm5719-llvm-2adf2f27147218379fd31e2ec5e9539602cd0d7e.tar.gz bcm5719-llvm-2adf2f27147218379fd31e2ec5e9539602cd0d7e.zip |
Use the FindProgramByName fallback only with known absolute paths.
I wasn't able to convince myself that all GetMainExecutable
implementations always return absolute paths; this prevents
unexpected behavior in case they ever don't.
llvm-svn: 112888
Diffstat (limited to 'llvm/lib/Support/SystemUtils.cpp')
-rw-r--r-- | llvm/lib/Support/SystemUtils.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Support/SystemUtils.cpp b/llvm/lib/Support/SystemUtils.cpp index 421b38111e0..c8b260c2e3d 100644 --- a/llvm/lib/Support/SystemUtils.cpp +++ b/llvm/lib/Support/SystemUtils.cpp @@ -49,10 +49,16 @@ sys::Path llvm::FindExecutable(const std::string &ExeName, Result.appendComponent(ExeName); if (Result.canExecute()) return Result; - // Expect to retrieve the pathname with suffix .exe. - Result = sys::Program::FindProgramByName(Result.str()); - if (!Result.empty()) - return Result; + // If the path is absolute (and it usually is), call FindProgramByName to + // allow it to try platform-specific logic, such as appending a .exe suffix + // on Windows. Don't do this if we somehow have a relative path, because + // we don't want to go searching the PATH and accidentally find an unrelated + // version of the program. + if (Result.isAbsolute()) { + Result = sys::Program::FindProgramByName(Result.str()); + if (!Result.empty()) + return Result; + } } return sys::Path(); |