summaryrefslogtreecommitdiff
path: root/unittests/Basic
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-29 15:47:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-29 15:47:24 +0000
commit146d57fd5135a134bcdaaf402157c070cde9e4a1 (patch)
tree6f3a8b4b6699c9fa8e384bf66815e81e1c9ba29a /unittests/Basic
parentbbe759cf95a5df5497549abadb56282939868da1 (diff)
downloadclang-146d57fd5135a134bcdaaf402157c070cde9e4a1.tar.gz
clang-146d57fd5135a134bcdaaf402157c070cde9e4a1.tar.bz2
clang-146d57fd5135a134bcdaaf402157c070cde9e4a1.tar.xz
Fix handling of "clang c:foo"
On windows, c:foo is a valid file path, but stat fails on just "c:". This causes a problem for clang since its file manager wants to cache data about the parent directory. There are refactorings to be done in here, but this gives clang the correct behavior and testing first. Patch by Yunzhong Gao! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Basic')
-rw-r--r--unittests/Basic/FileManagerTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/Basic/FileManagerTest.cpp b/unittests/Basic/FileManagerTest.cpp
index a55fcbf76c..d86c96f5a2 100644
--- a/unittests/Basic/FileManagerTest.cpp
+++ b/unittests/Basic/FileManagerTest.cpp
@@ -125,6 +125,14 @@ TEST_F(FileManagerTest, getFileReturnsValidFileEntryForExistingRealFile) {
FakeStatCache *statCache = new FakeStatCache;
statCache->InjectDirectory("/tmp", 42);
statCache->InjectFile("/tmp/test", 43);
+
+#ifdef _WIN32
+ const char *DirName = "C:.";
+ const char *FileName = "C:test";
+ statCache->InjectDirectory(DirName, 44);
+ statCache->InjectFile(FileName, 45);
+#endif
+
manager.addStatCache(statCache);
const FileEntry *file = manager.getFile("/tmp/test");
@@ -134,6 +142,15 @@ TEST_F(FileManagerTest, getFileReturnsValidFileEntryForExistingRealFile) {
const DirectoryEntry *dir = file->getDir();
ASSERT_TRUE(dir != NULL);
EXPECT_STREQ("/tmp", dir->getName());
+
+#ifdef _WIN32
+ file = manager.getFile(FileName);
+ ASSERT_TRUE(file != NULL);
+
+ dir = file->getDir();
+ ASSERT_TRUE(dir != NULL);
+ EXPECT_STREQ(DirName, dir->getName());
+#endif
}
// getFile() returns non-NULL if a virtual file exists at the given path.