This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGae59131d3ef3: [clang][Tooling] Make the filename behaviour consistent (authored by kadircet).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137962/new/ https://reviews.llvm.org/D137962 Files: clang/lib/Tooling/JSONCompilationDatabase.cpp clang/unittests/Tooling/CompilationDatabaseTest.cpp Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp =================================================================== --- clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -92,16 +92,32 @@ expected_files.push_back(std::string(PathStorage.str())); llvm::sys::path::native("//net/file1", PathStorage); expected_files.push_back(std::string(PathStorage.str())); + llvm::sys::path::native("//net/dir/file3", PathStorage); + expected_files.push_back(std::string(PathStorage.str())); EXPECT_EQ(expected_files, - getAllFiles("[{\"directory\":\"//net/dir\"," - "\"command\":\"command\"," - "\"file\":\"file1\"}," - " {\"directory\":\"//net/dir\"," - "\"command\":\"command\"," - "\"file\":\"../file1\"}," - " {\"directory\":\"//net/dir\"," - "\"command\":\"command\"," - "\"file\":\"file2\"}]", + getAllFiles(R"json( + [ + { + "directory": "//net/dir", + "command": "command", + "file": "file1" + }, + { + "directory": "//net/dir", + "command": "command", + "file": "../file1" + }, + { + "directory": "//net/dir", + "command": "command", + "file": "file2" + }, + { + "directory": "//net/dir", + "command": "command", + "file": "//net/dir/foo/../file3" + } + ])json", ErrorMessage, JSONCommandLineSyntax::Gnu)) << ErrorMessage; } Index: clang/lib/Tooling/JSONCompilationDatabase.cpp =================================================================== --- clang/lib/Tooling/JSONCompilationDatabase.cpp +++ clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -419,14 +419,13 @@ SmallString<128> NativeFilePath; if (llvm::sys::path::is_relative(FileName)) { SmallString<8> DirectoryStorage; - SmallString<128> AbsolutePath( - Directory->getValue(DirectoryStorage)); + SmallString<128> AbsolutePath(Directory->getValue(DirectoryStorage)); llvm::sys::path::append(AbsolutePath, FileName); - llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/ true); llvm::sys::path::native(AbsolutePath, NativeFilePath); } else { llvm::sys::path::native(FileName, NativeFilePath); } + llvm::sys::path::remove_dots(NativeFilePath, /*remove_dot_dot=*/true); auto Cmd = CompileCommandRef(Directory, File, *Command, Output); IndexByFile[NativeFilePath].push_back(Cmd); AllCommands.push_back(Cmd);
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp =================================================================== --- clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -92,16 +92,32 @@ expected_files.push_back(std::string(PathStorage.str())); llvm::sys::path::native("//net/file1", PathStorage); expected_files.push_back(std::string(PathStorage.str())); + llvm::sys::path::native("//net/dir/file3", PathStorage); + expected_files.push_back(std::string(PathStorage.str())); EXPECT_EQ(expected_files, - getAllFiles("[{\"directory\":\"//net/dir\"," - "\"command\":\"command\"," - "\"file\":\"file1\"}," - " {\"directory\":\"//net/dir\"," - "\"command\":\"command\"," - "\"file\":\"../file1\"}," - " {\"directory\":\"//net/dir\"," - "\"command\":\"command\"," - "\"file\":\"file2\"}]", + getAllFiles(R"json( + [ + { + "directory": "//net/dir", + "command": "command", + "file": "file1" + }, + { + "directory": "//net/dir", + "command": "command", + "file": "../file1" + }, + { + "directory": "//net/dir", + "command": "command", + "file": "file2" + }, + { + "directory": "//net/dir", + "command": "command", + "file": "//net/dir/foo/../file3" + } + ])json", ErrorMessage, JSONCommandLineSyntax::Gnu)) << ErrorMessage; } Index: clang/lib/Tooling/JSONCompilationDatabase.cpp =================================================================== --- clang/lib/Tooling/JSONCompilationDatabase.cpp +++ clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -419,14 +419,13 @@ SmallString<128> NativeFilePath; if (llvm::sys::path::is_relative(FileName)) { SmallString<8> DirectoryStorage; - SmallString<128> AbsolutePath( - Directory->getValue(DirectoryStorage)); + SmallString<128> AbsolutePath(Directory->getValue(DirectoryStorage)); llvm::sys::path::append(AbsolutePath, FileName); - llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/ true); llvm::sys::path::native(AbsolutePath, NativeFilePath); } else { llvm::sys::path::native(FileName, NativeFilePath); } + llvm::sys::path::remove_dots(NativeFilePath, /*remove_dot_dot=*/true); auto Cmd = CompileCommandRef(Directory, File, *Command, Output); IndexByFile[NativeFilePath].push_back(Cmd); AllCommands.push_back(Cmd);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits