diff options
author | Kadir Cetinkaya <kadircet@google.com> | 2022-11-14 18:55:19 +0100 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2022-11-15 10:47:52 +0100 |
commit | ae59131d3ef311fb4b1e50627c6457be00e60dc9 (patch) | |
tree | d297f7791080bc07e989b3f483b464bb4c1b74db /clang/lib/Tooling/JSONCompilationDatabase.cpp | |
parent | a853c42a6a5e5af8eedde3d54e9f02beb857be88 (diff) | |
download | llvm-ae59131d3ef311fb4b1e50627c6457be00e60dc9.zip llvm-ae59131d3ef311fb4b1e50627c6457be00e60dc9.tar.gz llvm-ae59131d3ef311fb4b1e50627c6457be00e60dc9.tar.bz2 |
[clang][Tooling] Make the filename behaviour consistent
Dotdots were removed only when converting a relative path to absolute
one. This patch makes the behaviour consistent for absolute file paths by
removing them in that case as well. Also updates the documentation to mention
the behaviour.
Fixes https://github.com/clangd/clangd/issues/1317
Differential Revision: https://reviews.llvm.org/D137962
Diffstat (limited to 'clang/lib/Tooling/JSONCompilationDatabase.cpp')
-rw-r--r-- | clang/lib/Tooling/JSONCompilationDatabase.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index 5e18d7a..158b9a5 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -419,14 +419,13 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) { 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); |