aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/unittests/Basic/FileManagerTest.cpp2
-rw-r--r--clang/unittests/Frontend/PCHPreambleTest.cpp14
2 files changed, 10 insertions, 6 deletions
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp
index b8b12a9..535d4d9 100644
--- a/clang/unittests/Basic/FileManagerTest.cpp
+++ b/clang/unittests/Basic/FileManagerTest.cpp
@@ -411,7 +411,7 @@ TEST_F(FileManagerTest, getVirtualFileWithDifferentName) {
#endif // !_WIN32
static StringRef getSystemRoot() {
- return is_style_windows(llvm::sys::path::Style::native) ? "C:/" : "/";
+ return is_style_windows(llvm::sys::path::Style::native) ? "C:\\" : "/";
}
TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
diff --git a/clang/unittests/Frontend/PCHPreambleTest.cpp b/clang/unittests/Frontend/PCHPreambleTest.cpp
index d253d93..2ce24c9 100644
--- a/clang/unittests/Frontend/PCHPreambleTest.cpp
+++ b/clang/unittests/Frontend/PCHPreambleTest.cpp
@@ -24,6 +24,13 @@ using namespace clang;
namespace {
+std::string Canonicalize(const Twine &Path) {
+ SmallVector<char, 128> PathVec;
+ Path.toVector(PathVec);
+ llvm::sys::path::remove_dots(PathVec, true);
+ return std::string(PathVec.begin(), PathVec.end());
+}
+
class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
{
std::map<std::string, unsigned> ReadCounts;
@@ -31,16 +38,13 @@ class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
public:
ErrorOr<std::unique_ptr<vfs::File>> openFileForRead(const Twine &Path) override
{
- SmallVector<char, 128> PathVec;
- Path.toVector(PathVec);
- llvm::sys::path::remove_dots(PathVec, true);
- ++ReadCounts[std::string(PathVec.begin(), PathVec.end())];
+ ++ReadCounts[Canonicalize(Path)];
return InMemoryFileSystem::openFileForRead(Path);
}
unsigned GetReadCount(const Twine &Path) const
{
- auto it = ReadCounts.find(Path.str());
+ auto it = ReadCounts.find(Canonicalize(Path));
return it == ReadCounts.end() ? 0 : it->second;
}
};