diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-08-01 21:42:11 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-08-01 21:42:11 +0000 |
commit | f8f91b897627773d5ecd484918e02d992c0d0c15 (patch) | |
tree | 0103868083f454067f6812051ce73eee5dc4dc1e /clang/unittests/Basic/FileManagerTest.cpp | |
parent | a5c536e1ee25daef4567e1e2a24b74f373b82011 (diff) | |
download | bcm5719-llvm-f8f91b897627773d5ecd484918e02d992c0d0c15.tar.gz bcm5719-llvm-f8f91b897627773d5ecd484918e02d992c0d0c15.zip |
Use llvm::sys::fs::UniqueID for windows and unix.
This unifies the unix and windows versions of FileManager::UniqueDirContainer
and FileManager::UniqueFileContainer by using UniqueID.
We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we
want to be able to construct fake ones, and file_status has different members
on unix and windows.
What the patch does is:
* Record only the information that clang is actually using.
* Use llvm::sys::fs::status instead of stat and fstat.
* Use llvm::sys::fs::UniqueID
* Delete the old windows versions of UniqueDirContainer and
UniqueFileContainer since the "unix" one now works on windows too.
llvm-svn: 187619
Diffstat (limited to 'clang/unittests/Basic/FileManagerTest.cpp')
-rw-r--r-- | clang/unittests/Basic/FileManagerTest.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index d86c96f5a2c..f8ce50d531e 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -24,18 +24,15 @@ class FakeStatCache : public FileSystemStatCache { private: // Maps a file/directory path to its desired stat result. Anything // not in this map is considered to not exist in the file system. - llvm::StringMap<struct stat, llvm::BumpPtrAllocator> StatCalls; + llvm::StringMap<FileData, llvm::BumpPtrAllocator> StatCalls; void InjectFileOrDirectory(const char *Path, ino_t INode, bool IsFile) { - struct stat statBuf; - memset(&statBuf, 0, sizeof(statBuf)); - statBuf.st_dev = 1; -#ifndef _WIN32 // struct stat has no st_ino field on Windows. - statBuf.st_ino = INode; -#endif - statBuf.st_mode = IsFile ? (0777 | S_IFREG) // a regular file - : (0777 | S_IFDIR); // a directory - StatCalls[Path] = statBuf; + FileData Data; + memset(&Data, 0, sizeof(FileData)); + llvm::sys::fs::UniqueID ID(1, INode); + Data.UniqueID = ID; + Data.IsDirectory = !IsFile; + StatCalls[Path] = Data; } public: @@ -50,10 +47,10 @@ public: } // Implement FileSystemStatCache::getStat(). - virtual LookupResult getStat(const char *Path, struct stat &StatBuf, - bool isFile, int *FileDescriptor) { + virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile, + int *FileDescriptor) { if (StatCalls.count(Path) != 0) { - StatBuf = StatCalls[Path]; + Data = StatCalls[Path]; return CacheExists; } |