[PATCH] D122914: [Windows] Fix handling of \" in program name on cmd line.

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 13:19:08 PDT 2022


rnk added a comment.

I would really like to avoid adding another tokenization variant function. We tried to write this code exactly following the rules the CRT uses to produce the `argv[]` array supplied to `main`. How does the CRT startup code handle that? Does it have special handling for the first token to match CreateProcess here?

Is the idea that Windows paths are not allowed to contain quotes, so backslash is not allowed to have any escaping power? In other words, double quotes in the first token are treated similarly to bash single quote, they have no escape mechanism.



================
Comment at: llvm/lib/Support/CommandLine.cpp:1027-1028
 
   if (State == UNQUOTED)
     AddToken(Saver.save(Token.str()));
 }
----------------
This seems like it could be a bug when the command line ends with an open quoted string. We should match the CRT logic. In the original example, the entire command line would become argv[0].


================
Comment at: llvm/lib/Support/Windows/Process.inc:258
 
+  if (Args.size() == 0)
+    return std::make_error_code(std::errc::invalid_argument);
----------------
Seems reasonable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122914/new/

https://reviews.llvm.org/D122914



More information about the llvm-commits mailing list