aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/FileManager.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-27 18:38:38 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-27 18:38:38 +0000
commit4fed3f47f6b9e31d603c5c2d1f6d8ec2e1241e57 (patch)
treeab4ae9d7fb8680b1c9633cc71c00fea57210b705 /include/clang/Basic/FileManager.h
parent8e03444e924665d4d90f5cfc0624c815256e0309 (diff)
Implement caching of stat() calls for precompiled headers, which is
essentially the same thing we do with pretokenized headers. stat() caching improves performance of the Cocoa-prefixed "Hello, World" by 45%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70223 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileManager.h')
-rw-r--r--include/clang/Basic/FileManager.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index ebd2812ece..d6a0cf34d9 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -81,7 +81,31 @@ public:
virtual ~StatSysCallCache() {}
virtual int stat(const char *path, struct stat *buf) = 0;
};
-
+
+/// \brief A stat listener that can be used by FileManager to keep
+/// track of the results of stat() calls that occur throughout the
+/// execution of the front end.
+class MemorizeStatCalls : public StatSysCallCache {
+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
+ llvm::StringMap<StatResult, llvm::BumpPtrAllocator> StatCalls;
+
+ typedef llvm::StringMap<StatResult, llvm::BumpPtrAllocator>::const_iterator
+ iterator;
+
+ iterator begin() const { return StatCalls.begin(); }
+ iterator end() const { return StatCalls.end(); }
+
+ virtual int stat(const char *path, struct stat *buf);
+};
+
/// FileManager - Implements support for file system lookup, file system
/// caching, and directory search management. This also handles more advanced
/// properties, such as uniquing files based on "inode", so that a file with two