[PATCH] D126675: [Windows] Don't try to wildcard expand paths starting with \\?\

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 30 13:22:44 PDT 2022


mstorsjo created this revision.
mstorsjo added reviewers: rnk, hans, thakis.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

Paths that start with `\\?\` are absolute paths, and aren't expected
to be used with wildcard expressions.

Previously, the `?` at the start of the path triggered the condition
for a potential wildcard, which caused the path to be split and
reassembled. In builds with `LLVM_WINDOWS_PREFER_FORWARD_SLASH=ON`,
this caused a path like e.g. `\\?\D:\tmp\hello.cpp` to be reassembled
into `\\?\D:\tmp/hello.cpp` which isn't a valid path (as such
absolute paths must use backslashes consistently).

This fixes https://github.com/mstorsjo/llvm-mingw/issues/280.

I'm not sure if there's any straightforward way to add a test
for this case, unfortunately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126675

Files:
  llvm/lib/Support/Windows/Process.inc


Index: llvm/lib/Support/Windows/Process.inc
===================================================================
--- llvm/lib/Support/Windows/Process.inc
+++ llvm/lib/Support/Windows/Process.inc
@@ -158,7 +158,7 @@
   // the common case. Also don't wildcard expand /?. Always treat it as an
   // option.
   if (Arg.find_first_of("*?") == StringRef::npos || Arg == "/?" ||
-      Arg == "-?") {
+      Arg == "-?" || Arg.startswith("\\\\?\\")) {
     Args.push_back(Arg.data());
     return EC;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126675.432977.patch
Type: text/x-patch
Size: 499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220530/c48365fa/attachment.bin>


More information about the llvm-commits mailing list