summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/FileSystemStatCache.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerdim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit173a4f43a911175643bda81ee675e8d9269056ea (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /include/clang/Basic/FileSystemStatCache.h
parent88f7a7d5251a2d813460274c92decc143a11569b (diff)
downloadFreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip
FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'include/clang/Basic/FileSystemStatCache.h')
-rw-r--r--include/clang/Basic/FileSystemStatCache.h48
1 files changed, 31 insertions, 17 deletions
diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h
index 23d8256..9be8b10 100644
--- a/include/clang/Basic/FileSystemStatCache.h
+++ b/include/clang/Basic/FileSystemStatCache.h
@@ -16,21 +16,30 @@
#define LLVM_CLANG_FILESYSTEMSTATCACHE_H
#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/FileSystem.h"
-#include <sys/stat.h>
-#include <sys/types.h>
+#include <memory>
namespace clang {
+namespace vfs {
+class File;
+class FileSystem;
+}
+
+// FIXME: should probably replace this with vfs::Status
struct FileData {
+ std::string Name;
uint64_t Size;
time_t ModTime;
llvm::sys::fs::UniqueID UniqueID;
bool IsDirectory;
bool IsNamedPipe;
bool InPCH;
+ bool IsVFSMapped; // FIXME: remove this when files support multiple names
+ FileData()
+ : Size(0), ModTime(0), IsDirectory(false), IsNamedPipe(false),
+ InPCH(false), IsVFSMapped(false) {}
};
/// \brief Abstract interface for introducing a FileManager cache for 'stat'
@@ -39,8 +48,8 @@ struct FileData {
class FileSystemStatCache {
virtual void anchor();
protected:
- OwningPtr<FileSystemStatCache> NextStatCache;
-
+ std::unique_ptr<FileSystemStatCache> NextStatCache;
+
public:
virtual ~FileSystemStatCache() {}
@@ -57,10 +66,11 @@ public:
/// If isFile is true, then this lookup should only return success for files
/// (not directories). If it is false this lookup should only return
/// success for directories (not files). On a successful file lookup, the
- /// implementation can optionally fill in FileDescriptor with a valid
- /// descriptor and the client guarantees that it will close it.
+ /// implementation can optionally fill in \p F with a valid \p File object and
+ /// the client guarantees that it will close it.
static bool get(const char *Path, FileData &Data, bool isFile,
- int *FileDescriptor, FileSystemStatCache *Cache);
+ std::unique_ptr<vfs::File> *F, FileSystemStatCache *Cache,
+ vfs::FileSystem &FS);
/// \brief Sets the next stat call cache in the chain of stat caches.
/// Takes ownership of the given stat cache.
@@ -74,21 +84,24 @@ public:
/// \brief Retrieve the next stat call cache in the chain, transferring
/// ownership of this cache (and, transitively, all of the remaining caches)
/// to the caller.
- FileSystemStatCache *takeNextStatCache() { return NextStatCache.take(); }
-
+ FileSystemStatCache *takeNextStatCache() { return NextStatCache.release(); }
+
protected:
+ // FIXME: The pointer here is a non-owning/optional reference to the
+ // unique_ptr. Optional<unique_ptr<vfs::File>&> might be nicer, but
+ // Optional needs some work to support references so this isn't possible yet.
virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile,
- int *FileDescriptor) = 0;
+ std::unique_ptr<vfs::File> *F,
+ vfs::FileSystem &FS) = 0;
LookupResult statChained(const char *Path, FileData &Data, bool isFile,
- int *FileDescriptor) {
+ std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) {
if (FileSystemStatCache *Next = getNextStatCache())
- return Next->getStat(Path, Data, isFile, FileDescriptor);
+ return Next->getStat(Path, Data, isFile, F, FS);
// If we hit the end of the list of stat caches to try, just compute and
// return it without a cache.
- return get(Path, Data, isFile, FileDescriptor, 0) ? CacheMissing
- : CacheExists;
+ return get(Path, Data, isFile, F, nullptr, FS) ? CacheMissing : CacheExists;
}
};
@@ -106,8 +119,9 @@ public:
iterator begin() const { return StatCalls.begin(); }
iterator end() const { return StatCalls.end(); }
- virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile,
- int *FileDescriptor);
+ LookupResult getStat(const char *Path, FileData &Data, bool isFile,
+ std::unique_ptr<vfs::File> *F,
+ vfs::FileSystem &FS) override;
};
} // end namespace clang
OpenPOWER on IntegriCloud