diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Serialization/ASTBitCodes.h | 5 | ||||
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 3 | ||||
-rw-r--r-- | include/clang/Serialization/ASTWriter.h | 23 | ||||
-rw-r--r-- | include/clang/Serialization/Module.h | 3 |
4 files changed, 33 insertions, 1 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 9301a833ba..982c31d293 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -436,7 +436,10 @@ namespace clang { /// \brief Record code for ObjC categories in a module that are chained to /// an interface. - OBJC_CHAINED_CATEGORIES + OBJC_CHAINED_CATEGORIES, + + /// \brief Record code for a file sorted array of DeclIDs in a module. + FILE_SORTED_DECLS }; /// \brief Record types used within a source manager block. diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index a463a280d3..f9ca9b2758 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -296,6 +296,9 @@ private: /// \brief Declarations that have been replaced in a later file in the chain. DeclReplacementMap ReplacedDecls; + /// \brief Map from a FileID to the file-level declarations that it contains. + llvm::DenseMap<FileID, ArrayRef<serialization::DeclID> > FileDeclIDs; + // Updates for visible decls can occur for other contexts than just the // TU, and when we read those update records, the actual context will not // be available yet (unless it's the TU), so have this pending map using the diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 184897fba9..52c80d1248 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -59,6 +59,8 @@ class SwitchCase; class TargetInfo; class VersionTuple; +namespace SrcMgr { class SLocEntry; } + /// \brief Writes an AST file containing the contents of a translation unit. /// /// The ASTWriter class produces a bitstream containing the serialized @@ -144,6 +146,25 @@ private: /// the declaration's ID. std::vector<serialization::DeclOffset> DeclOffsets; + /// \brief Vector of pairs of raw location/DeclID. + typedef SmallVector<std::pair<unsigned, serialization::DeclID>, 64> + LocDeclIDsTy; + struct DeclIDInFileInfo { + LocDeclIDsTy DeclIDs; + /// \brief Set when the DeclIDs vectors from all files are joined, this + /// indicates the index that this particular vector has in the global one. + unsigned FirstDeclIndex; + }; + typedef llvm::DenseMap<const SrcMgr::SLocEntry *, + DeclIDInFileInfo *> FileDeclIDsTy; + + /// \brief Map from file SLocEntries to info about the file-level declarations + /// that it contains. + FileDeclIDsTy FileDeclIDs; + + void associateDeclWithFile(const Decl *D, serialization::DeclID, + SourceLocation FileLoc); + /// \brief The first ID number we can use for our own types. serialization::TypeID FirstTypeID; @@ -354,6 +375,7 @@ private: uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC); uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC); void WriteTypeDeclOffsets(); + void WriteFileDeclIDsMap(); void WriteSelectors(Sema &SemaRef); void WriteReferencedSelectorsPool(Sema &SemaRef); void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver, @@ -393,6 +415,7 @@ public: /// \brief Create a new precompiled header writer that outputs to /// the given bitstream. ASTWriter(llvm::BitstreamWriter &Stream); + ~ASTWriter(); /// \brief Write a precompiled header for the given semantic analysis. /// diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 5c0cc9d296..43687f46dd 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -271,6 +271,9 @@ public: /// Key is the ID of the interface. /// Value is a pair of linked category DeclIDs (head category, tail category). ChainedObjCCategoriesMap ChainedObjCCategories; + + /// \brief Array of file-level DeclIDs sorted by file. + const serialization::DeclID *FileSortedDecls; // === Types === |