mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 21:31:03 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112888 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
514ca3a021
commit
776339ee27
@ -49,10 +49,16 @@ sys::Path llvm::FindExecutable(const std::string &ExeName,
|
|||||||
Result.appendComponent(ExeName);
|
Result.appendComponent(ExeName);
|
||||||
if (Result.canExecute())
|
if (Result.canExecute())
|
||||||
return Result;
|
return Result;
|
||||||
// Expect to retrieve the pathname with suffix .exe.
|
// If the path is absolute (and it usually is), call FindProgramByName to
|
||||||
Result = sys::Program::FindProgramByName(Result.str());
|
// allow it to try platform-specific logic, such as appending a .exe suffix
|
||||||
if (!Result.empty())
|
// on Windows. Don't do this if we somehow have a relative path, because
|
||||||
return Result;
|
// 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();
|
return sys::Path();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user