diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -555,6 +555,11 @@ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (FromHandle) break; + + // We don't want to loop if the file doesn't exist. + auto EC = mapWindowsError(GetLastError()); + if (EC == errc::no_such_file_or_directory) + return EC; } if (!FromHandle) return mapWindowsError(GetLastError());