diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Serialization/GlobalModuleIndex.h | 26 | ||||
-rw-r--r-- | clang/include/clang/Serialization/ModuleManager.h | 34 |
2 files changed, 38 insertions, 22 deletions
diff --git a/clang/include/clang/Serialization/GlobalModuleIndex.h b/clang/include/clang/Serialization/GlobalModuleIndex.h index 703025ea2e7..38ccb26970f 100644 --- a/clang/include/clang/Serialization/GlobalModuleIndex.h +++ b/clang/include/clang/Serialization/GlobalModuleIndex.h @@ -93,9 +93,6 @@ class GlobalModuleIndex { /// identifier. unsigned NumIdentifierLookupHits; - /// \brief The number of modules provided via skip sets. - unsigned NumIdentifierModulesSkipped; - /// \brief Internal constructor. Use \c readIndex() to read an index. explicit GlobalModuleIndex(FileManager &FileMgr, llvm::MemoryBuffer *Buffer, llvm::BitstreamCursor Cursor); @@ -142,31 +139,20 @@ public: void getModuleDependencies(const FileEntry *ModuleFile, SmallVectorImpl<const FileEntry *> &Dependencies); + /// \brief A set of module files in which we found a result. + typedef llvm::SmallPtrSet<const FileEntry *, 4> HitSet; + /// \brief Look for all of the module files with a namespace-scope binding /// for the given identifier, e.g., a global function, variable, or type with /// that name, or declare a method with the selector. /// /// \param Name The identifier to look for. /// - /// \param ModuleFiles Will be populated with the list of module + /// \param Hits Will be populated with the set of module /// files that declare entities with the given name. /// - /// \returns true if any module files were found, false otherwise. - bool lookupIdentifier(StringRef Name, - SmallVectorImpl<const FileEntry *> &ModuleFiles); - - /// \brief A set of module files into which name lookup can be skipped, - /// because they are known not to contain any bindings for the given name. - typedef llvm::SmallPtrSet<const FileEntry *, 16> SkipSet; - - /// \brief Compute the "skip set", meaning those known modules that do not - /// have some particular property. - /// - /// \param ModuleFiles The set of module files that has some property. - /// - /// \returns The set of known modules that do not have the property exhibited - /// by the files in \p ModuleFiles. - SkipSet computeSkipSet(const SmallVectorImpl<const FileEntry *> &ModuleFiles); + /// \returns true if the identifier is known to the index, false otherwise. + bool lookupIdentifier(StringRef Name, HitSet &Hits); /// \brief Print statistics to standard error. void printStats(); diff --git a/clang/include/clang/Serialization/ModuleManager.h b/clang/include/clang/Serialization/ModuleManager.h index 465da767879..05d702664e8 100644 --- a/clang/include/clang/Serialization/ModuleManager.h +++ b/clang/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. /// |