[clang-tools-extra] r336358 - [clang-move] ClangMoveTests: Remove dots in output paths

Simon Marchi via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 5 07:53:17 PDT 2018

Author: simark
Date: Thu Jul  5 07:53:17 2018
New Revision: 336358

URL: http://llvm.org/viewvc/llvm-project?rev=336358&view=rev
[clang-move] ClangMoveTests: Remove dots in output paths

Following 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 D48903, remove_dots will just
be a no-op.

Reviewers: ilya-biryukov, hokein

Reviewed By: hokein

Subscribers: ioeric, cfe-commits

Differential Revision: https://reviews.llvm.org/D48951


Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=336358&r1=336357&r2=336358&view=diff
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Thu Jul  5 07:53:17 2018
@@ -239,8 +239,10 @@ runClangMoveOnCode(const move::MoveDefin
   // 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;

More information about the cfe-commits mailing list