Re: [PATCH] D21132: [include-fixer] Keep dot dot in SymbolInfo file paths.

2016-06-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 60041.
hokein added a comment.

Rebase.


http://reviews.llvm.org/D21132

Files:
  include-fixer/find-all-symbols/PathConfig.cpp
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  test/include-fixer/include_path.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -105,7 +105,7 @@
   "#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 =
Index: test/include-fixer/include_path.cpp
===
--- test/include-fixer/include_path.cpp
+++ test/include-fixer/include_path.cpp
@@ -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;
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -158,6 +158,5 @@
   auto Factory =
   llvm::make_unique(
   &Reporter, clang::find_all_symbols::getSTLPostfixHeaderMap());
-  Tool.run(Factory.get());
-  return 0;
+  return Tool.run(Factory.get());
 }
Index: include-fixer/find-all-symbols/PathConfig.cpp
===
--- include-fixer/find-all-symbols/PathConfig.cpp
+++ include-fixer/find-all-symbols/PathConfig.cpp
@@ -33,7 +33,7 @@
   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();
 }


Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -105,7 +105,7 @@
   "#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 =
Index: test/include-fixer/include_path.cpp
===
--- test/include-fixer/include_path.cpp
+++ test/include-fixer/include_path.cpp
@@ -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-fix

Re: [PATCH] D21132: [include-fixer] Keep dot dot in SymbolInfo file paths.

2016-06-08 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272152: [include-fixer] Keep dot dot in SymbolInfo file 
paths. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D21132?vs=60041&id=60042#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21132

Files:
  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

Index: clang-tools-extra/trunk/test/include-fixer/include_path.cpp
===
--- clang-tools-extra/trunk/test/include-fixer/include_path.cpp
+++ clang-tools-extra/trunk/test/include-fixer/include_path.cpp
@@ -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;
Index: 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -105,7 +105,7 @@
   "#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 =
Index: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -158,6 +158,5 @@
   auto Factory =
   llvm::make_unique(
   &Reporter, clang::find_all_symbols::getSTLPostfixHeaderMap());
-  Tool.run(Factory.get());
-  return 0;
+  return Tool.run(Factory.get());
 }
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/PathConfig.cpp
@@ -33,7 +33,7 @@
   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();
 }


Index: clang-tools-extra/trunk/test/include-fixer/include_path.cpp
===
--- clang-tools-extra/trunk/test/include-fixer/include_path.cpp
+++ clang-tools-extra/trunk/test/include-fixer/include_path.cpp
@@ -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_comman

Re: [PATCH] D21132: [include-fixer] Keep dot dot in SymbolInfo file paths.

2016-06-08 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Ok, let's try this. Maybe it will solve our path problems once and for all. 
ONCE AND FOR ALL.


http://reviews.llvm.org/D21132



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21132: [include-fixer] Keep dot dot in SymbolInfo file paths.

2016-06-08 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added reviewers: bkramer, ioeric.
hokein added a subscriber: cfe-commits.

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.

http://reviews.llvm.org/D21132

Files:
  include-fixer/find-all-symbols/PathConfig.cpp
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  test/include-fixer/include_path.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -105,7 +105,7 @@
   "#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 =
Index: test/include-fixer/include_path.cpp
===
--- test/include-fixer/include_path.cpp
+++ test/include-fixer/include_path.cpp
@@ -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 -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 -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;
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -158,6 +158,5 @@
   auto Factory =
   llvm::make_unique(
   &Reporter, clang::find_all_symbols::getSTLPostfixHeaderMap());
-  Tool.run(Factory.get());
-  return 0;
+  return Tool.run(Factory.get());
 }
Index: include-fixer/find-all-symbols/PathConfig.cpp
===
--- include-fixer/find-all-symbols/PathConfig.cpp
+++ include-fixer/find-all-symbols/PathConfig.cpp
@@ -33,7 +33,7 @@
   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();
 }


Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -105,7 +105,7 @@
   "#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 =
Index: test/include-fixer/include_path.cpp
===
--- test/include-fixer/include_path