llvm-project/llvm/lib/Support/Windows
Simon Tatham 32814df442 [Windows] Fix handling of \" in program name on cmd line.
Bugzilla #47579: if you invoke clang on Windows via a pathname in
which a quoted section closes just after a backslash, e.g.

  "C:\Program Files\Whatever\"clang.exe

then cmd.exe and CreateProcess will correctly find the binary, because
when they parse the program name at the start of the command line,
they don't regard the \ before the " as having any kind of escaping
effect. This is different from the behaviour of the Windows standard C
library when it parses the rest of the command line, which would
consider that \" not to close the quoted string.

But this confuses windows::GetCommandLineArguments, because the
Windows API function GetCommandLineW() will return a command line
containing that \" sequence, and cl::TokenizeWindowsCommandLine will
tokenize the whole string according to the C library's rules. So it
will misidentify where the program name stops and the arguments start.

To fix this, I've introduced a new variant function
cl::TokenizeWindowsCommandLineFull(), intended to be applied to the
string returned from GetCommandLineW(). It parses the first word of
the command line according to CreateProcess's rules, considering \ to
never be an escaping character; thereafter, it switches over to the C
library rules for the rest of the command line.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D122914
2022-05-03 11:57:50 +01:00
..
COM.inc
DynamicLibrary.inc
Host.inc [NFC] Fix build when LLVM_DEFAULT_TARGET_TRIPLE="" 2022-01-31 13:31:55 -06:00
Memory.inc
Path.inc Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17" 2022-01-26 16:55:53 +01:00
Process.inc [Windows] Fix handling of \" in program name on cmd line. 2022-05-03 11:57:50 +01:00
Program.inc Cleanup include: TableGen 2022-03-11 11:41:32 +01:00
Signals.inc [Support] Don't print stacktrace if DbgHelp.dll hasn't been loaded yet 2022-02-08 16:37:36 +00:00
ThreadLocal.inc
Threading.inc [Support] reorder Threading includes to avoid conflict with FreeBSD headers 2021-07-09 10:39:52 +01:00
Watchdog.inc
explicit_symbols.inc