[PATCH] D48951: [clang-move] ClangMoveTests: Remove dots in output paths

Simon Marchi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 4 13:46:32 PDT 2018


simark created this revision.
Herald added subscribers: cfe-commits, ioeric.

Following https://reviews.llvm.org/D48903 ([VirtualFileSystem] InMemoryFileSystem::status: Return
a Status with the requested name), the paths output by clang-move in the
FileToReplacements map may contain leading "./".  For example, where we
would get "foo.h", we'll now get "./foo.h".  This breaks the tests,
because we are doing exact string lookups in the FileToFileID and
Results maps (they contain "foo.h", but we search for "./foo.h").

To mitigate this, try to normalize a little bit the paths output by
clang-move to remove that leading "./".

This patch should be safe to merge before https://reviews.llvm.org/D48903, remove_dots will just
be a no-op.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48951

Files:
  unittests/clang-move/ClangMoveTests.cpp


Index: unittests/clang-move/ClangMoveTests.cpp
===================================================================
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -239,8 +239,10 @@
   // The Key is file name, value is the new code after moving the class.
   std::map<std::string, std::string> Results;
   for (const auto &It : FileToReplacements) {
-    StringRef FilePath = It.first;
-    Results[FilePath] = Context.getRewrittenText(FileToFileID[FilePath]);
+    // The path may come out as "./foo.h", normalize to "foo.h".
+    SmallString<32> FilePath (It.first);
+    llvm::sys::path::remove_dots(FilePath);
+    Results[FilePath.str().str()] = Context.getRewrittenText(FileToFileID[FilePath]);
   }
   return Results;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48951.154149.patch
Type: text/x-patch
Size: 770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180704/653fe891/attachment.bin>


More information about the cfe-commits mailing list