Index: llvm/lib/Support/Path.cpp =================================================================== --- llvm/lib/Support/Path.cpp +++ llvm/lib/Support/Path.cpp @@ -885,13 +885,13 @@ } if (rootName && !rootDirectory) { - StringRef pRootName = path::root_name(p); + StringRef bRootName = path::root_name(current_dir); StringRef bRootDirectory = path::root_directory(current_dir); StringRef bRelativePath = path::relative_path(current_dir); StringRef pRelativePath = path::relative_path(p); SmallString<128> res; - path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath); + path::append(res, bRootName, bRootDirectory, bRelativePath, pRelativePath); path.swap(res); return; } Index: llvm/unittests/Support/Path.cpp =================================================================== --- llvm/unittests/Support/Path.cpp +++ llvm/unittests/Support/Path.cpp @@ -185,10 +185,19 @@ path::native(*i, temp_store); } - SmallString<32> Relative("foo.cpp"); - sys::fs::make_absolute("/root", Relative); - Relative[5] = '/'; // Fix up windows paths. - ASSERT_EQ("/root/foo.cpp", Relative); + { + SmallString<32> Relative("foo.cpp"); + sys::fs::make_absolute("/root", Relative); + Relative[5] = '/'; // Fix up windows paths. + ASSERT_EQ("/root/foo.cpp", Relative); + } + + { + SmallString<32> Relative("foo.cpp"); + sys::fs::make_absolute("//root", Relative); + Relative[6] = '/'; // Fix up windows paths. + ASSERT_EQ("//root/foo.cpp", Relative); + } } TEST(Support, FilenameParent) {