[clang][Tooling] Delete dots and dotdots when generating absolute paths
Summary: GetAllFiles interface returns absolute paths, but keeps dots and dot dots. This patch makes those paths canonical by deleting them. Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59079 llvm-svn: 355678
This commit is contained in:
parent
f334231176
commit
7ec1ec10c9
|
@ -370,6 +370,7 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) {
|
|||
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);
|
||||
|
|
|
@ -88,12 +88,17 @@ TEST(JSONCompilationDatabase, GetAllFiles) {
|
|||
expected_files.push_back(PathStorage.str());
|
||||
llvm::sys::path::native("//net/dir/file2", PathStorage);
|
||||
expected_files.push_back(PathStorage.str());
|
||||
llvm::sys::path::native("//net/file1", PathStorage);
|
||||
expected_files.push_back(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\"}]",
|
||||
ErrorMessage, JSONCommandLineSyntax::Gnu))
|
||||
<< ErrorMessage;
|
||||
|
|
Loading…
Reference in New Issue