summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 19:19:34 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 19:19:34 +0000
commit226efd356c6c98a4de2880e6090aa2f05b459fc5 (patch)
tree10f7d47ea7136c139ac252d3b9f7e0215c766b61 /clang/lib/Serialization
parente5cb2787667ffd67f831dac78abe8c3acd046f9e (diff)
downloadbcm5719-llvm-226efd356c6c98a4de2880e6090aa2f05b459fc5.tar.gz
bcm5719-llvm-226efd356c6c98a4de2880e6090aa2f05b459fc5.zip
rework the stat cache, pulling it out of FileManager.h into
its own header and giving it some more structure. No functionality change. llvm-svn: 120030
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp25
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp1
-rw-r--r--clang/lib/Serialization/GeneratePCH.cpp3
3 files changed, 16 insertions, 13 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 81907d022e5..9fe6aac22ea 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -33,6 +33,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManagerInternals.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemStatCache.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "llvm/ADT/StringExtras.h"
@@ -1066,7 +1067,7 @@ class ASTStatLookupTrait {
///
/// This cache is very similar to the stat cache used by pretokenized
/// headers.
-class ASTStatCache : public StatSysCallCache {
+class ASTStatCache : public FileSystemStatCache {
typedef OnDiskChainedHashTable<ASTStatLookupTrait> CacheTy;
CacheTy *Cache;
@@ -1082,28 +1083,28 @@ public:
~ASTStatCache() { delete Cache; }
- int stat(const char *path, struct stat *buf) {
+ LookupResult getStat(const char *Path, struct stat &StatBuf) {
// Do the lookup for the file's data in the AST file.
- CacheTy::iterator I = Cache->find(path);
+ CacheTy::iterator I = Cache->find(Path);
// If we don't get a hit in the AST file just forward to 'stat'.
if (I == Cache->end()) {
++NumStatMisses;
- return StatSysCallCache::stat(path, buf);
+ return statChained(Path, StatBuf);
}
++NumStatHits;
ASTStatData Data = *I;
if (!Data.hasStat)
- return 1;
-
- buf->st_ino = Data.ino;
- buf->st_dev = Data.dev;
- buf->st_mtime = Data.mtime;
- buf->st_mode = Data.mode;
- buf->st_size = Data.size;
- return 0;
+ return CacheHitMissing;
+
+ StatBuf.st_ino = Data.ino;
+ StatBuf.st_dev = Data.dev;
+ StatBuf.st_mtime = Data.mtime;
+ StatBuf.st_mode = Data.mode;
+ StatBuf.st_size = Data.size;
+ return CacheHitExists;
}
};
} // end anonymous namespace
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 27862ae59cb..f3852af00ff 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -30,6 +30,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemStatCache.h"
#include "clang/Basic/OnDiskHashTable.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManagerInternals.h"
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 0d8ec736b6a..4f6f5cae426 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -19,6 +19,7 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemStatCache.h"
#include "llvm/Bitcode/BitstreamWriter.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
@@ -34,7 +35,7 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP,
// Install a stat() listener to keep track of all of the stat()
// calls.
- StatCalls = new MemorizeStatCalls;
+ StatCalls = new MemorizeStatCalls();
// If we have a chain, we want new stat calls only, so install the memorizer
// *after* the already installed ASTReader's stat cache.
PP.getFileManager().addStatCache(StatCalls,
OpenPOWER on IntegriCloud