Index: source/Utility/FileSpec.cpp =================================================================== --- source/Utility/FileSpec.cpp +++ source/Utility/FileSpec.cpp @@ -340,6 +340,13 @@ std::replace(resolved.begin(), resolved.end(), '\\', '/'); llvm::StringRef resolve_path_ref(resolved.c_str()); + if (!pathname.empty() && resolve_path_ref.empty()) { + // We have a non empty specified that resulted in an empty normalized path + // so this resolved to the current working directory. Don't let m_directory + // or m_filename be empty. + m_filename.SetString("."); + return; + } size_t dir_end = ParentPathEnd(resolve_path_ref, m_syntax); if (dir_end == 0) { m_filename.SetString(resolve_path_ref); Index: unittests/Utility/FileSpecTest.cpp =================================================================== --- unittests/Utility/FileSpecTest.cpp +++ unittests/Utility/FileSpecTest.cpp @@ -201,9 +201,9 @@ {"/..", "/"}, {"/.", "/"}, {"..", ".."}, - {".", ""}, + {".", "."}, {"../..", "../.."}, - {"foo/..", ""}, + {"foo/..", "."}, {"foo/../bar", "bar"}, {"../foo/..", ".."}, {"./foo", "foo"}, @@ -232,11 +232,11 @@ {R"(\..)", R"(\..)"}, // {R"(c:..)", R"(c:..)"}, {R"(..)", R"(..)"}, - {R"(.)", R"()"}, + {R"(.)", R"(.)"}, // TODO: fix llvm::sys::path::remove_dots() to return "c:\" below. {R"(c:..\..)", R"(c:\..\..)"}, {R"(..\..)", R"(..\..)"}, - {R"(foo\..)", R"()"}, + {R"(foo\..)", R"(.)"}, {R"(foo\..\bar)", R"(bar)"}, {R"(..\foo\..)", R"(..)"}, {R"(.\foo)", R"(foo)"},