[clang-tools-extra] r272152 - [include-fixer] Keep dot dot in SymbolInfo file paths.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 8 08:10:18 PDT 2016
Author: hokein
Date: Wed Jun 8 10:10:18 2016
New Revision: 272152
URL: http://llvm.org/viewvc/llvm-project?rev=272152&view=rev
Log:
[include-fixer] Keep dot dot in SymbolInfo file paths.
Summary:
Currently, removing dot dot in header's path doesn't make include-fixer
minimize path correctly in some cases, for example, specify a relative search
path based on the build directory("-I../include/").
Besides, removing dot dot can break symbolic link directories. So don't
removing it for now.
Reviewers: ioeric, bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D21132
Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
clang-tools-extra/trunk/test/include-fixer/include_path.cpp
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp?rev=272152&r1=272151&r2=272152&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp Wed Jun 8 10:10:18 2016
@@ -33,7 +33,7 @@ std::string getIncludePath(const SourceM
if (Collector)
FilePath = Collector->getMappedHeader(FilePath);
SmallString<256> CleanedFilePath = FilePath;
- llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/true);
+ llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/false);
return CleanedFilePath.str();
}
Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp?rev=272152&r1=272151&r2=272152&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp Wed Jun 8 10:10:18 2016
@@ -158,6 +158,5 @@ int main(int argc, const char **argv) {
auto Factory =
llvm::make_unique<clang::find_all_symbols::FindAllSymbolsActionFactory>(
&Reporter, clang::find_all_symbols::getSTLPostfixHeaderMap());
- Tool.run(Factory.get());
- return 0;
+ return Tool.run(Factory.get());
}
Modified: clang-tools-extra/trunk/test/include-fixer/include_path.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/include_path.cpp?rev=272152&r1=272151&r2=272152&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/include-fixer/include_path.cpp (original)
+++ clang-tools-extra/trunk/test/include-fixer/include_path.cpp Wed Jun 8 10:10:18 2016
@@ -1,14 +1,20 @@
// REQUIRES: shell
// RUN: mkdir -p %T/include-fixer/include
+// RUN: mkdir -p %T/include-fixer/symbols
// RUN: mkdir -p %T/include-fixer/build
// RUN: mkdir -p %T/include-fixer/src
// RUN: sed 's|test_dir|%T/include-fixer|g' %S/Inputs/database_template.json > %T/include-fixer/build/compile_commands.json
-// RUN: cp %S/Inputs/fake_yaml_db.yaml %T/include-fixer/build/fake_yaml_db.yaml
-// RUN: echo 'b::a::bar f;' > %T/include-fixer/src/bar.cpp
-// RUN: touch %T/include-fixer/include/bar.h
+// RUN: echo -e '#include "bar.h"\nb::a::bar f;' > %T/include-fixer/src/bar.cpp
+// RUN: echo 'namespace b { namespace a { class bar {}; } }' > %T/include-fixer/include/bar.h
// RUN: cd %T/include-fixer/build
-// RUN: clang-include-fixer -db=yaml -input=fake_yaml_db.yaml -minimize-paths=true -p=. %T/include-fixer/src/bar.cpp
+// RUN: find-all-symbols -output-dir=%T/include-fixer/symbols -p=. %T/include-fixer/src/bar.cpp
+// RUN: find-all-symbols -merge-dir=%T/include-fixer/symbols %T/include-fixer/build/find_all_symbols.yaml
+// RUN: FileCheck -input-file=%T/include-fixer/build/find_all_symbols.yaml -check-prefix=CHECK-YAML %s
+//
+// RUN: echo 'b::a::bar f;' > %T/include-fixer/src/bar.cpp
+// RUN: clang-include-fixer -db=yaml -input=%T/include-fixer/build/find_all_symbols.yaml -minimize-paths=true -p=. %T/include-fixer/src/bar.cpp
// RUN: FileCheck -input-file=%T/include-fixer/src/bar.cpp %s
+// CHECK-YAML: ../include/bar.h
// CHECK: #include "bar.h"
// CHECK: b::a::bar f;
Modified: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=272152&r1=272151&r2=272152&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Wed Jun 8 10:10:18 2016
@@ -105,7 +105,7 @@ public:
"#include \"internal/internal.h\"";
#if !defined(_MSC_VER) && !defined(__MINGW32__)
// Test path cleaning for both decls and macros.
- const std::string DirtyHeader = "./internal/../internal/./a/b.h";
+ const std::string DirtyHeader = "./internal/./a/b.h";
Content += "\n#include \"" + DirtyHeader + "\"";
const std::string CleanHeader = "internal/a/b.h";
const std::string DirtyHeaderContent =
More information about the cfe-commits
mailing list