diff options
author | Eli Bendersky <eliben@chromium.org> | 2013-07-15 16:08:08 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@chromium.org> | 2013-07-15 16:08:08 -0700 |
commit | e789858899a7b36caf11b371a97411a1582a482b (patch) | |
tree | e8c28b178b32010f73b477b3c65b5ff74437530c /include/clang/Serialization/GlobalModuleIndex.h | |
parent | 99a5501f5ae5b75017dfc386d4abf648234e85df (diff) | |
parent | 20c7d45a4da9f58ad805ad1d37f92fe7dc232ec8 (diff) |
Merge commit '20c7d45a4da9f58ad805ad1d37f92fe7dc232ec8'
Conflicts:
lib/CodeGen/ItaniumCXXABI.cpp
Diffstat (limited to 'include/clang/Serialization/GlobalModuleIndex.h')
-rw-r--r-- | include/clang/Serialization/GlobalModuleIndex.h | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/include/clang/Serialization/GlobalModuleIndex.h b/include/clang/Serialization/GlobalModuleIndex.h index ec8ad353e0..ab91f4009c 100644 --- a/include/clang/Serialization/GlobalModuleIndex.h +++ b/include/clang/Serialization/GlobalModuleIndex.h @@ -20,6 +20,7 @@ #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include <utility> @@ -34,9 +35,14 @@ class DirectoryEntry; class FileEntry; class FileManager; +namespace serialization { + class ModuleFile; +} + using llvm::SmallVector; using llvm::SmallVectorImpl; using llvm::StringRef; +using serialization::ModuleFile; /// \brief A global index for a set of module files, providing information about /// the identifiers within those module files. @@ -63,25 +69,42 @@ class GlobalModuleIndex { /// \brief Information about a given module file. struct ModuleInfo { - ModuleInfo() : File() { } + ModuleInfo() : File(), Size(), ModTime() { } + + /// \brief The module file, once it has been resolved. + ModuleFile *File; + + /// \brief The module file name. + std::string FileName; - /// \brief The module file entry. - const FileEntry *File; + /// \brief Size of the module file at the time the global index was built. + off_t Size; - /// \brief The module files on which this module directly depends. - llvm::SmallVector<const FileEntry *, 4> Dependencies; + /// \brief Modification time of the module file at the time the global + /// index was built. + time_t ModTime; + + /// \brief The module IDs on which this module directly depends. + /// FIXME: We don't really need a vector here. + llvm::SmallVector<unsigned, 4> Dependencies; }; /// \brief A mapping from module IDs to information about each module. /// /// This vector may have gaps, if module files have been removed or have /// been updated since the index was built. A gap is indicated by an empty - /// \c File pointer. + /// file name. llvm::SmallVector<ModuleInfo, 16> Modules; - /// \brief Lazily-populated mapping from module file entries to their + /// \brief Lazily-populated mapping from module files to their /// corresponding index into the \c Modules vector. - llvm::DenseMap<const FileEntry *, unsigned> ModulesByFile; + llvm::DenseMap<ModuleFile *, unsigned> ModulesByFile; + + /// \brief The set of modules that have not yet been resolved. + /// + /// The string is just the name of the module itself, which maps to the + /// module ID. + llvm::StringMap<unsigned> UnresolvedModules; /// \brief The number of identifier lookups we performed. unsigned NumIdentifierLookups; @@ -89,9 +112,9 @@ class GlobalModuleIndex { /// \brief The number of identifier lookup hits, where we recognize the /// identifier. unsigned NumIdentifierLookupHits; - + /// \brief Internal constructor. Use \c readIndex() to read an index. - explicit GlobalModuleIndex(FileManager &FileMgr, llvm::MemoryBuffer *Buffer, + explicit GlobalModuleIndex(llvm::MemoryBuffer *Buffer, llvm::BitstreamCursor Cursor); GlobalModuleIndex(const GlobalModuleIndex &) LLVM_DELETED_FUNCTION; @@ -115,29 +138,32 @@ public: /// \brief Read a global index file for the given directory. /// - /// \param FileMgr The file manager to use for reading files. - /// /// \param Path The path to the specific module cache where the module files /// for the intended configuration reside. /// /// \returns A pair containing the global module index (if it exists) and /// the error code. static std::pair<GlobalModuleIndex *, ErrorCode> - readIndex(FileManager &FileMgr, StringRef Path); + readIndex(StringRef Path); + + /// \brief Returns an iterator for identifiers stored in the index table. + /// + /// The caller accepts ownership of the returned object. + IdentifierIterator *createIdentifierIterator() const; /// \brief Retrieve the set of modules that have up-to-date indexes. /// /// \param ModuleFiles Will be populated with the set of module files that /// have been indexed. - void getKnownModules(SmallVectorImpl<const FileEntry *> &ModuleFiles); + void getKnownModules(SmallVectorImpl<ModuleFile *> &ModuleFiles); /// \brief Retrieve the set of module files on which the given module file /// directly depends. - void getModuleDependencies(const FileEntry *ModuleFile, - SmallVectorImpl<const FileEntry *> &Dependencies); + void getModuleDependencies(ModuleFile *File, + SmallVectorImpl<ModuleFile *> &Dependencies); /// \brief A set of module files in which we found a result. - typedef llvm::SmallPtrSet<const FileEntry *, 4> HitSet; + typedef llvm::SmallPtrSet<ModuleFile *, 4> HitSet; /// \brief Look for all of the module files with information about the given /// identifier, e.g., a global function, variable, or type with that name. @@ -150,6 +176,12 @@ public: /// \returns true if the identifier is known to the index, false otherwise. bool lookupIdentifier(StringRef Name, HitSet &Hits); + /// \brief Note that the given module file has been loaded. + /// + /// \returns false if the global module index has information about this + /// module file, and true otherwise. + bool loadedModuleFile(ModuleFile *File); + /// \brief Print statistics to standard error. void printStats(); |