aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/RefactoringTest.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-10-21 18:33:24 -0700
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-10-29 12:09:41 -0700
commit99023627010bbfefb71e25a2b4d056de1cbd354e (patch)
treea7ad434f3071922aac052bf9eb23c29c577cb885 /clang/unittests/Tooling/RefactoringTest.cpp
parent51ce567b38ec92163ec05c9bef0bd0e2bd53c667 (diff)
downloadllvm-99023627010bbfefb71e25a2b4d056de1cbd354e.zip
llvm-99023627010bbfefb71e25a2b4d056de1cbd354e.tar.gz
llvm-99023627010bbfefb71e25a2b4d056de1cbd354e.tar.bz2
Support: Use sys::path::is_style_{posix,windows}() in a few places
Use the new sys::path::is_style_posix() and is_style_windows() in a few places that need to detect the system's native path style. In llvm/lib/Support/Path.cpp, this patch removes most uses of the private `real_style()`, where is_style_posix() and is_style_windows() are just a little tidier. Elsewhere, this removes `_WIN32` macro checks. Added a FIXME to a FileManagerTest that seemed fishy, but maintained the existing behaviour. Differential Revision: https://reviews.llvm.org/D112289
Diffstat (limited to 'clang/unittests/Tooling/RefactoringTest.cpp')
-rw-r--r--clang/unittests/Tooling/RefactoringTest.cpp31
1 files changed, 10 insertions, 21 deletions
diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp
index d239aba..c71a724 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -1031,18 +1031,17 @@ TEST_F(MergeReplacementsTest, OverlappingRanges) {
toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
}
+static constexpr bool usesWindowsPaths() {
+ return is_style_windows(llvm::sys::path::Style::native);
+}
+
TEST(DeduplicateByFileTest, PathsWithDots) {
std::map<std::string, Replacements> FileToReplaces;
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
new llvm::vfs::InMemoryFileSystem());
FileManager FileMgr(FileSystemOptions(), VFS);
-#if !defined(_WIN32)
- StringRef Path1 = "a/b/.././c.h";
- StringRef Path2 = "a/c.h";
-#else
- StringRef Path1 = "a\\b\\..\\.\\c.h";
- StringRef Path2 = "a\\c.h";
-#endif
+ StringRef Path1 = usesWindowsPaths() ? "a\\b\\..\\.\\c.h" : "a/b/.././c.h";
+ StringRef Path2 = usesWindowsPaths() ? "a\\c.h" : "a/c.h";
EXPECT_TRUE(VFS->addFile(Path1, 0, llvm::MemoryBuffer::getMemBuffer("")));
EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
FileToReplaces[std::string(Path1)] = Replacements();
@@ -1057,13 +1056,8 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) {
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
new llvm::vfs::InMemoryFileSystem());
FileManager FileMgr(FileSystemOptions(), VFS);
-#if !defined(_WIN32)
- StringRef Path1 = "./a/b/c.h";
- StringRef Path2 = "a/b/c.h";
-#else
- StringRef Path1 = ".\\a\\b\\c.h";
- StringRef Path2 = "a\\b\\c.h";
-#endif
+ StringRef Path1 = usesWindowsPaths() ? ".\\a\\b\\c.h" : "./a/b/c.h";
+ StringRef Path2 = usesWindowsPaths() ? "a\\b\\c.h" : "a/b/c.h";
EXPECT_TRUE(VFS->addFile(Path1, 0, llvm::MemoryBuffer::getMemBuffer("")));
EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
FileToReplaces[std::string(Path1)] = Replacements();
@@ -1078,13 +1072,8 @@ TEST(DeduplicateByFileTest, NonExistingFilePath) {
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
new llvm::vfs::InMemoryFileSystem());
FileManager FileMgr(FileSystemOptions(), VFS);
-#if !defined(_WIN32)
- StringRef Path1 = "./a/b/c.h";
- StringRef Path2 = "a/b/c.h";
-#else
- StringRef Path1 = ".\\a\\b\\c.h";
- StringRef Path2 = "a\\b\\c.h";
-#endif
+ StringRef Path1 = usesWindowsPaths() ? ".\\a\\b\\c.h" : "./a/b/c.h";
+ StringRef Path2 = usesWindowsPaths() ? "a\\b\\c.h" : "a/b/c.h";
FileToReplaces[std::string(Path1)] = Replacements();
FileToReplaces[std::string(Path2)] = Replacements();
FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);