diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-29 15:47:24 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-29 15:47:24 +0000 |
commit | ee30546c007d26d9c0c6f15b0e291a8bb0e651f9 (patch) | |
tree | 127c41bf128e0471a021a6fa65ab20ea5918b7c2 /clang/unittests/Basic/FileManagerTest.cpp | |
parent | aa5aa98eaba633f693a9ad0d1f781e432bd2fe7d (diff) | |
download | bcm5719-llvm-ee30546c007d26d9c0c6f15b0e291a8bb0e651f9.tar.gz bcm5719-llvm-ee30546c007d26d9c0c6f15b0e291a8bb0e651f9.zip |
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!
llvm-svn: 187359
Diffstat (limited to 'clang/unittests/Basic/FileManagerTest.cpp')
-rw-r--r-- | clang/unittests/Basic/FileManagerTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index a55fcbf76cf..d86c96f5a2c 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/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. |