[clang-tools-extra] r332603 - Attempt to fix clang-move tests broken by r332590 on windows

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Thu May 17 05:40:50 PDT 2018


Author: ioeric
Date: Thu May 17 05:40:50 2018
New Revision: 332603

URL: http://llvm.org/viewvc/llvm-project?rev=332603&view=rev
Log:
Attempt to fix clang-move tests broken by r332590 on windows

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007

Modified:
    clang-tools-extra/trunk/clang-move/ClangMove.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=332603&r1=332602&r2=332603&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu May 17 05:40:50 2018
@@ -61,6 +61,12 @@ AST_MATCHER_P(CXXMethodDecl, ofOutermost
   return InnerMatcher.matches(*Parent, Finder, Builder);
 }
 
+std::string CleanPath(StringRef PathRef) {
+  llvm::SmallString<128> Path(PathRef);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  return Path.str();
+}
+
 // Make the Path absolute using the CurrentDir if the Path is not an absolute
 // path. An empty Path will result in an empty string.
 std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
@@ -72,9 +78,7 @@ std::string MakeAbsolutePath(StringRef C
           llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
     llvm::errs() << "Warning: could not make absolute file: '" << EC.message()
                  << '\n';
-  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
-  llvm::sys::path::native(AbsolutePath);
-  return AbsolutePath.str();
+  return CleanPath(std::move(AbsolutePath));
 }
 
 // Make the Path absolute using the current working directory of the given
@@ -97,15 +101,13 @@ std::string MakeAbsolutePath(const Sourc
     StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
     // FIXME: getCanonicalName might fail to get real path on VFS.
     if (llvm::sys::path::is_absolute(DirName)) {
-      SmallVector<char, 128> AbsoluteFilename;
+      SmallString<128> AbsoluteFilename;
       llvm::sys::path::append(AbsoluteFilename, DirName,
                               llvm::sys::path::filename(AbsolutePath.str()));
-      return llvm::StringRef(AbsoluteFilename.data(), AbsoluteFilename.size())
-          .str();
+      return CleanPath(AbsoluteFilename);
     }
   }
-  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
-  return AbsolutePath.str();
+  return CleanPath(AbsolutePath);
 }
 
 // Matches AST nodes that are expanded within the given AbsoluteFilePath.




More information about the cfe-commits mailing list