aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Serialization/ModuleManager.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-01-25 23:32:03 +0000
committerDouglas Gregor <dgregor@apple.com>2013-01-25 23:32:03 +0000
commit188bdcd1aaf5e9f457cec6851707d7dc3e7bbb15 (patch)
treea8e2e900703a72777120af069406272457e5073c /include/clang/Serialization/ModuleManager.h
parent59273eb5263006c96b03cfc90db2dadf354ea4ce (diff)
Improve coordination between the module manager and the global module
index, optimizing the operation that skips lookup in modules where we know the identifier will not be found. This makes the global module index optimization actually useful, providing an 8.5% speedup over modules without the global module index for -fsyntax-only. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization/ModuleManager.h')
-rw-r--r--include/clang/Serialization/ModuleManager.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h
index 465da76787..05d702664e 100644
--- a/include/clang/Serialization/ModuleManager.h
+++ b/include/clang/Serialization/ModuleManager.h
@@ -21,6 +21,8 @@
namespace clang {
+class GlobalModuleIndex;
+
namespace serialization {
/// \brief Manages the set of modules loaded by an AST reader.
@@ -42,6 +44,25 @@ class ModuleManager {
/// \brief The visitation order.
SmallVector<ModuleFile *, 4> VisitOrder;
+ /// \brief The list of module files that both we and the global module index
+ /// know about.
+ ///
+ /// Either the global index or the module manager may have modules that the
+ /// other does not know about, because the global index can be out-of-date
+ /// (in which case the module manager could have modules it does not) and
+ /// this particular translation unit might not have loaded all of the modules
+ /// known to the global index.
+ SmallVector<ModuleFile *, 4> ModulesInCommonWithGlobalIndex;
+
+ /// \brief The global module index, if one is attached.
+ ///
+ /// The global module index will actually be owned by the ASTReader; this is
+ /// just an non-owning pointer.
+ GlobalModuleIndex *GlobalIndex;
+
+ /// \brief Update the set of modules files we know about known to the global index.
+ void updateModulesInCommonWithGlobalIndex();
+
public:
typedef SmallVector<ModuleFile*, 2>::iterator ModuleIterator;
typedef SmallVector<ModuleFile*, 2>::const_iterator ModuleConstIterator;
@@ -117,7 +138,10 @@ public:
/// \brief Add an in-memory buffer the list of known buffers
void addInMemoryBuffer(StringRef FileName, llvm::MemoryBuffer *Buffer);
-
+
+ /// \brief Set the global module index.
+ void setGlobalIndex(GlobalModuleIndex *Index);
+
/// \brief Visit each of the modules.
///
/// This routine visits each of the modules, starting with the
@@ -136,7 +160,13 @@ public:
///
/// \param UserData User data associated with the visitor object, which
/// will be passed along to the visitor.
- void visit(bool (*Visitor)(ModuleFile &M, void *UserData), void *UserData);
+ ///
+ /// \param ModuleFilesHit If non-NULL, contains the set of module files
+ /// that we know we need to visit because the global module index told us to.
+ /// Any module that is known to both the global module index and the module
+ /// manager that is *not* in this set can be skipped.
+ void visit(bool (*Visitor)(ModuleFile &M, void *UserData), void *UserData,
+ llvm::SmallPtrSet<const FileEntry *, 4> *ModuleFilesHit = 0);
/// \brief Visit each of the modules with a depth-first traversal.
///