llvm-project/llvm/lib/Support/Windows
Markus Böck c6047101ad [Support][Windows] Make sure only executables are found by sys::findProgramByName
The function utilizes Windows' SearchPathW function, which as I found out today, may also return directories. After looking at the Unix implementation of the file I found that it contains a check whether the found path is also executable. While fixing the Windows implementation, I also learned that sys::fs::access returns successfully when querying whether directories are executable, which the Unix version does not.

This patch makes both of these functions equivalent to their Unix implementation and insures that any path returned by sys::findProgramByName on Windows may only be executable, just like the Unix implementation.

The equivalent additions I have made to the Windows implementation, in the Unix implementation are here:
sys::findProgramByName: 39ecfe6143/llvm/lib/Support/Unix/Program.inc (L90)
sys::fs::access: c2a84771bb/llvm/lib/Support/Unix/Path.inc (L608)

I encountered this issue when running the LLVM testsuite. Commands of the form not test ... would fail to correctly execute test.exe, which is part of GnuWin32, as it actually tried to execute a folder called test, which happened to be in a directory on my PATH.

Differential Revision: https://reviews.llvm.org/D99357
2021-03-25 20:29:43 +01:00
..
COM.inc
DynamicLibrary.inc llvm-ar: Fix MinGW compilation 2020-02-28 09:59:24 +01:00
Host.inc llvm-ar: Fix MinGW compilation 2020-02-28 09:59:24 +01:00
Memory.inc llvm-ar: Fix MinGW compilation 2020-02-28 09:59:24 +01:00
Path.inc [Support][Windows] Make sure only executables are found by sys::findProgramByName 2021-03-25 20:29:43 +01:00
Process.inc Support: Avoid SmallVector::assign with a range from to-be-replaced vector in Windows GetExecutableName 2020-11-18 17:55:49 -08:00
Program.inc [Support][Windows] Make sure only executables are found by sys::findProgramByName 2021-03-25 20:29:43 +01:00
Signals.inc [Support] On Unix, let the CrashRecoveryContext return the signal code 2020-09-24 08:21:43 -04:00
ThreadLocal.inc llvm-ar: Fix MinGW compilation 2020-02-28 09:59:24 +01:00
Threading.inc Re-land [Support] On Windows, take the affinity mask into account 2021-01-14 17:03:22 -05:00
Watchdog.inc
explicit_symbols.inc