aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 19:28:12 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 19:28:12 +0000
commit74e976ba4b0d407bb798ea26476f618e256fc8c7 (patch)
tree57aba6b267132c96e7e313d3400c93e97db6ce26
parent10e286aa8d39fb51a21412850265d9dae74613ee (diff)
PCH files only cache successful stats. Remove the code that reads/writes
the result code of the stat to/from the PCH file since it is always 0. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120031 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/FileSystemStatCache.h13
-rw-r--r--lib/Basic/FileSystemStatCache.cpp2
-rw-r--r--lib/Serialization/ASTReader.cpp18
-rw-r--r--lib/Serialization/ASTWriter.cpp25
4 files changed, 16 insertions, 42 deletions
diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h
index fdeceb34c0..bcfa52dd86 100644
--- a/include/clang/Basic/FileSystemStatCache.h
+++ b/include/clang/Basic/FileSystemStatCache.h
@@ -67,17 +67,10 @@ protected:
/// execution of the front end.
class MemorizeStatCalls : public FileSystemStatCache {
public:
- /// \brief The result of a stat() call.
- ///
- /// The first member is the result of calling stat(). If stat()
- /// found something, the second member is a copy of the stat
- /// structure.
- typedef std::pair<int, struct stat> StatResult;
+ /// \brief The set of stat() calls that have been seen.
+ llvm::StringMap<struct stat, llvm::BumpPtrAllocator> StatCalls;
- /// \brief The set of stat() calls that have been
- llvm::StringMap<StatResult, llvm::BumpPtrAllocator> StatCalls;
-
- typedef llvm::StringMap<StatResult, llvm::BumpPtrAllocator>::const_iterator
+ typedef llvm::StringMap<struct stat, llvm::BumpPtrAllocator>::const_iterator
iterator;
iterator begin() const { return StatCalls.begin(); }
diff --git a/lib/Basic/FileSystemStatCache.cpp b/lib/Basic/FileSystemStatCache.cpp
index 8fd31d5dfc..3e13740cab 100644
--- a/lib/Basic/FileSystemStatCache.cpp
+++ b/lib/Basic/FileSystemStatCache.cpp
@@ -34,7 +34,7 @@ MemorizeStatCalls::getStat(const char *Path, struct stat &StatBuf) {
// Cache file 'stat' results and directories with absolutely paths.
if (!S_ISDIR(StatBuf.st_mode) || llvm::sys::Path(Path).isAbsolute())
- StatCalls[Path] = StatResult(Result, StatBuf);
+ StatCalls[Path] = StatBuf;
return Result;
}
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 9fe6aac22e..0c0e4fffc0 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1005,7 +1005,6 @@ namespace {
class ASTStatData {
public:
- const bool hasStat;
const ino_t ino;
const dev_t dev;
const mode_t mode;
@@ -1013,10 +1012,7 @@ public:
const off_t size;
ASTStatData(ino_t i, dev_t d, mode_t mo, time_t m, off_t s)
- : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {}
-
- ASTStatData()
- : hasStat(false), ino(0), dev(0), mode(0), mtime(0), size(0) {}
+ : ino(i), dev(d), mode(mo), mtime(m), size(s) {}
};
class ASTStatLookupTrait {
@@ -1051,9 +1047,6 @@ class ASTStatLookupTrait {
unsigned /*DataLen*/) {
using namespace clang::io;
- if (*d++ == 1)
- return data_type();
-
ino_t ino = (ino_t) ReadUnalignedLE32(d);
dev_t dev = (dev_t) ReadUnalignedLE32(d);
mode_t mode = (mode_t) ReadUnalignedLE16(d);
@@ -1073,10 +1066,8 @@ class ASTStatCache : public FileSystemStatCache {
unsigned &NumStatHits, &NumStatMisses;
public:
- ASTStatCache(const unsigned char *Buckets,
- const unsigned char *Base,
- unsigned &NumStatHits,
- unsigned &NumStatMisses)
+ ASTStatCache(const unsigned char *Buckets, const unsigned char *Base,
+ unsigned &NumStatHits, unsigned &NumStatMisses)
: Cache(0), NumStatHits(NumStatHits), NumStatMisses(NumStatMisses) {
Cache = CacheTy::Create(Buckets, Base);
}
@@ -1096,9 +1087,6 @@ public:
++NumStatHits;
ASTStatData Data = *I;
- if (!Data.hasStat)
- return CacheHitMissing;
-
StatBuf.st_ino = Data.ino;
StatBuf.st_dev = Data.dev;
StatBuf.st_mtime = Data.mtime;
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index f3852af00f..468729a371 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -904,8 +904,8 @@ public:
typedef const char * key_type;
typedef key_type key_type_ref;
- typedef std::pair<int, struct stat> data_type;
- typedef const data_type& data_type_ref;
+ typedef struct stat data_type;
+ typedef const data_type &data_type_ref;
static unsigned ComputeHash(const char *path) {
return llvm::HashString(path);
@@ -916,9 +916,7 @@ public:
data_type_ref Data) {
unsigned StrLen = strlen(path);
clang::io::Emit16(Out, StrLen);
- unsigned DataLen = 1; // result value
- if (Data.first == 0)
- DataLen += 4 + 4 + 2 + 8 + 8;
+ unsigned DataLen = 4 + 4 + 2 + 8 + 8;
clang::io::Emit8(Out, DataLen);
return std::make_pair(StrLen + 1, DataLen);
}
@@ -927,21 +925,16 @@ public:
Out.write(path, KeyLen);
}
- void EmitData(llvm::raw_ostream& Out, key_type_ref,
+ void EmitData(llvm::raw_ostream &Out, key_type_ref,
data_type_ref Data, unsigned DataLen) {
using namespace clang::io;
uint64_t Start = Out.tell(); (void)Start;
- // Result of stat()
- Emit8(Out, Data.first? 1 : 0);
-
- if (Data.first == 0) {
- Emit32(Out, (uint32_t) Data.second.st_ino);
- Emit32(Out, (uint32_t) Data.second.st_dev);
- Emit16(Out, (uint16_t) Data.second.st_mode);
- Emit64(Out, (uint64_t) Data.second.st_mtime);
- Emit64(Out, (uint64_t) Data.second.st_size);
- }
+ Emit32(Out, (uint32_t) Data.st_ino);
+ Emit32(Out, (uint32_t) Data.st_dev);
+ Emit16(Out, (uint16_t) Data.st_mode);
+ Emit64(Out, (uint64_t) Data.st_mtime);
+ Emit64(Out, (uint64_t) Data.st_size);
assert(Out.tell() - Start == DataLen && "Wrong data length");
}