summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-05-17 12:40:50 +0000
committerEric Liu <ioeric@google.com>2018-05-17 12:40:50 +0000
commit5e721378eb6f5100685d260d8955ec1ac9384fe0 (patch)
tree0f156325b6ecc3d418f841a9295f7275efe1a773 /clang-tools-extra
parent650b5fc6cb55a6e6d39f5d8e7750b34cf0a426b0 (diff)
downloadbcm5719-llvm-5e721378eb6f5100685d260d8955ec1ac9384fe0.tar.gz
bcm5719-llvm-5e721378eb6f5100685d260d8955ec1ac9384fe0.zip
Attempt to fix clang-move tests broken by r332590 on windows
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007 llvm-svn: 332603
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clang-move/ClangMove.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang-tools-extra/clang-move/ClangMove.cpp b/clang-tools-extra/clang-move/ClangMove.cpp
index 7626d1ccedf..3381ab5c82e 100644
--- a/clang-tools-extra/clang-move/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/ClangMove.cpp
@@ -61,6 +61,12 @@ AST_MATCHER_P(CXXMethodDecl, ofOutermostEnclosingClass,
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 CurrentDir, StringRef Path) {
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 SourceManager &SM, StringRef Path) {
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.
OpenPOWER on IntegriCloud