diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-11 07:48:23 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-11 07:48:23 +0000 |
commit | e5d30e3b403539b10aaa52f03875a2243bf88904 (patch) | |
tree | 02565c9c01affb5bf2bda49e218c151a46d1b1e6 /include/clang/Basic/FileSystemStatCache.h | |
parent | f64d25c633fc093528177c2e0fdd096d2f8706d2 (diff) |
Extend stat query APIs to explicitly specify if the query is for
a file or directory, allowing just a stat call if a file descriptor
is not needed.
Doing just 'stat' is faster than 'open/fstat/close'.
This has the effect of cutting down system time for validating the input files of a PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileSystemStatCache.h')
-rw-r--r-- | include/clang/Basic/FileSystemStatCache.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h index 932ef5f99a..ff70373ffb 100644 --- a/include/clang/Basic/FileSystemStatCache.h +++ b/include/clang/Basic/FileSystemStatCache.h @@ -44,13 +44,13 @@ public: /// /// \returns \c true if the path does not exist or \c false if it exists. /// - /// If FileDescriptor is non-null, then this lookup should only return success - /// for files (not directories). If it is null this lookup should only return + /// 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. - static bool get(const char *Path, struct stat &StatBuf, int *FileDescriptor, - FileSystemStatCache *Cache); + static bool get(const char *Path, struct stat &StatBuf, + bool isFile, int *FileDescriptor, FileSystemStatCache *Cache); /// \brief Sets the next stat call cache in the chain of stat caches. @@ -69,16 +69,17 @@ public: protected: virtual LookupResult getStat(const char *Path, struct stat &StatBuf, - int *FileDescriptor) = 0; + bool isFile, int *FileDescriptor) = 0; LookupResult statChained(const char *Path, struct stat &StatBuf, - int *FileDescriptor) { + bool isFile, int *FileDescriptor) { if (FileSystemStatCache *Next = getNextStatCache()) - return Next->getStat(Path, StatBuf, FileDescriptor); + return Next->getStat(Path, StatBuf, isFile, FileDescriptor); // If we hit the end of the list of stat caches to try, just compute and // return it without a cache. - return get(Path, StatBuf, FileDescriptor, 0) ? CacheMissing : CacheExists; + return get(Path, StatBuf, + isFile, FileDescriptor, 0) ? CacheMissing : CacheExists; } }; @@ -97,7 +98,7 @@ public: iterator end() const { return StatCalls.end(); } virtual LookupResult getStat(const char *Path, struct stat &StatBuf, - int *FileDescriptor); + bool isFile, int *FileDescriptor); }; } // end namespace clang |