Index: lib/Support/Windows/Path.inc =================================================================== --- lib/Support/Windows/Path.inc +++ lib/Support/Windows/Path.inc @@ -94,13 +94,16 @@ return EC; FullPath.append(CurPath); } - // Traverse the requested path, canonicalizing . and .. as we go (because - // the \\?\ prefix is documented to treat them as real components). - // The iterators don't report separators and append() always attaches - // preferred_separator so we don't need to call native() on the result. + // Traverse the requested path, canonicalizing . and .. (because the \\?\ + // prefix is documented to treat them as real components). Ignore + // separators, which can be returned from the iterator if the path has a + // drive name. We don't need to call native() on the result since append() + // always attaches preferred_separator. for (llvm::sys::path::const_iterator I = llvm::sys::path::begin(Path8Str), E = llvm::sys::path::end(Path8Str); I != E; ++I) { + if (I->size() == 1 && is_separator((*I)[0])) + continue; if (I->size() == 1 && *I == ".") continue; if (I->size() == 2 && *I == "..") Index: unittests/Support/Path.cpp =================================================================== --- unittests/Support/Path.cpp +++ unittests/Support/Path.cpp @@ -699,6 +699,13 @@ ThisDir = path::parent_path(ThisDir); } + // Also verify that paths with Unix separators are handled correctly. + SmallString<270> LongPathWithUnixSeparators("C:"); + while (LongPathWithUnixSeparators.size() < 260) { + LongPathWithUnixSeparators.append("/DirNameWith19Charss"); + } + ASSERT_NO_ERROR(fs::create_directories(Twine(LongPathWithUnixSeparators))); + // Similarly for a relative pathname. Need to set the current directory to // TestDirectory so that the one we create ends up in the right place. char PreviousDir[260];