[PATCH] D67166: Win: handle \\?\UNC\ prefix in realPathFromHandle (PR43204)

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 11:07:57 PDT 2019


rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



================
Comment at: llvm/lib/Support/Windows/Path.inc:378
   DWORD CountChars = Buffer.size();
-  if (CountChars >= 4) {
-    if (0 == ::memcmp(Data, L"\\\\?\\", 8)) {
-      CountChars -= 4;
-      Data += 4;
-    }
+  if (CountChars >= 8 && ::memcmp(Data, L"\\\\?\\UNC\\", 16) == 0) {
+    // Convert \\?\UNC\foo\bar to \\foo\bar
----------------
The mix of byte counts and character counts here is making me feel like this is too clever. You could do something like this:
```
template <size_t N>
static size_t wideStartsWith(const wchar_t *Str, const wchar_t (&Prefix)[N]) {
  return wcsncmp(Str, Prefix, N) == 0;
}
```
Alternatively it could take an `ArrayRef<wchar_t>` and use this memcmp pattern here.


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

https://reviews.llvm.org/D67166





More information about the llvm-commits mailing list