amaiorano updated this revision to Diff 82185. amaiorano added a comment. As agreed, modified getStyle to make use of vfs::FileSystem::makeAbsolute. I would modify the body of the commit as follows:
Modify getStyle to use vfs::FileSystem::makeAbsolute just like FS.addFile does, rather than sys::fs::make_absolute. The latter gets the CWD from the platform, while the former expects it to be set by the client, causing a mismatch when converting relative paths to absolute. (not sure if I should have just modified the Summary section of this Phabricator review) https://reviews.llvm.org/D27971 Files: lib/Format/Format.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -10907,10 +10907,6 @@ format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces)); } -// Since this test case uses UNIX-style file path. We disable it for MS -// compiler. -#if !defined(_MSC_VER) && !defined(__MINGW32__) - TEST(FormatStyle, GetStyleOfFile) { vfs::InMemoryFileSystem FS; // Test 1: format file in the same directory. @@ -10938,8 +10934,6 @@ ASSERT_EQ(Style3, getGoogleStyle()); } -#endif // _MSC_VER - TEST_F(ReplacementTest, FormatCodeAfterReplacements) { // Column limit is 20. std::string Code = "Type *a =\n" Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1917,7 +1917,10 @@ // Look for .clang-format/_clang-format file in the file's parent directories. SmallString<128> UnsuitableConfigFiles; SmallString<128> Path(FileName); - llvm::sys::fs::make_absolute(Path); + std::error_code EC = FS->makeAbsolute(Path); + assert(!EC); + (void)EC; + for (StringRef Directory = Path; !Directory.empty(); Directory = llvm::sys::path::parent_path(Directory)) {
Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -10907,10 +10907,6 @@ format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces)); } -// Since this test case uses UNIX-style file path. We disable it for MS -// compiler. -#if !defined(_MSC_VER) && !defined(__MINGW32__) - TEST(FormatStyle, GetStyleOfFile) { vfs::InMemoryFileSystem FS; // Test 1: format file in the same directory. @@ -10938,8 +10934,6 @@ ASSERT_EQ(Style3, getGoogleStyle()); } -#endif // _MSC_VER - TEST_F(ReplacementTest, FormatCodeAfterReplacements) { // Column limit is 20. std::string Code = "Type *a =\n" Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1917,7 +1917,10 @@ // Look for .clang-format/_clang-format file in the file's parent directories. SmallString<128> UnsuitableConfigFiles; SmallString<128> Path(FileName); - llvm::sys::fs::make_absolute(Path); + std::error_code EC = FS->makeAbsolute(Path); + assert(!EC); + (void)EC; + for (StringRef Directory = Path; !Directory.empty(); Directory = llvm::sys::path::parent_path(Directory)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits