diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/AST/DeclBase.h | 1 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclContextInternals.h | 2 | ||||
-rw-r--r-- | clang/include/clang/AST/ExternalASTSource.h | 1 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHBitCodes.h | 91 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHReader.h | 7 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHWriter.h | 6 |
6 files changed, 55 insertions, 53 deletions
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 46af4ec6b60..d05b5a597eb 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -549,6 +549,7 @@ public: /// this context. decl_iterator decls_begin(ASTContext &Context) const; decl_iterator decls_end(ASTContext &Context) const; + bool decls_empty(ASTContext &Context) const; /// specific_decl_iterator - Iterates over a subrange of /// declarations stored in a DeclContext, providing only those that diff --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h index 7489413be89..6a905be4a7e 100644 --- a/clang/include/clang/AST/DeclContextInternals.h +++ b/clang/include/clang/AST/DeclContextInternals.h @@ -112,7 +112,7 @@ public: if (VectorTy *Vector = getAsVector()) delete Vector; - if (Vec.size() == 0) + if (Vec.empty()) Data = 0; else Data = (Vec[0] << 2) | DK_DeclID; diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index 17fa72612ff..f8b3c4db4d1 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -16,7 +16,6 @@ #include "clang/AST/DeclarationName.h" #include "clang/AST/Type.h" #include "llvm/ADT/SmallVector.h" - namespace clang { class Decl; diff --git a/clang/include/clang/Frontend/PCHBitCodes.h b/clang/include/clang/Frontend/PCHBitCodes.h index 00bd1cfac26..e4e50e3aa6b 100644 --- a/clang/include/clang/Frontend/PCHBitCodes.h +++ b/clang/include/clang/Frontend/PCHBitCodes.h @@ -22,8 +22,24 @@ namespace clang { namespace pch { - const int IDBits = 32; - typedef uint32_t ID; + /// \brief An ID number that refers to a declaration in a PCH file. + /// + /// The ID numbers of types are consecutive (in order of + /// discovery) and start at 2. 0 is reserved for NULL, and 1 is + /// reserved for the translation unit declaration. + typedef uint32_t DeclID; + + /// \brief An ID number that refers to a type in a PCH file. + /// + /// The ID of a type is partitioned into two parts: the lower + /// three bits are used to store the const/volatile/restrict + /// qualifiers (as with QualType) and the upper bits provide a + /// type index. The type index values are partitioned into two + /// sets. The values below NUM_PREDEF_TYPE_IDs are predefined type + /// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a + /// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are + /// other types that have serialized representations. + typedef uint32_t TypeID; /// \brief Describes the various kinds of blocks that occur within /// a PCH file. @@ -48,23 +64,39 @@ namespace clang { /// types used within the PCH file. TYPES_BLOCK_ID, - /// \brief The block containing the offsets of all of the types - /// used within the PCH. - /// - /// The offsets in this block point into the block identified by - /// TYPES_BLOCK_ID, and are indexed by the type ID. - TYPE_OFFSETS_BLOCK_ID, - /// \brief The block containing the definitions of all of the /// declarations stored in the PCH file. - DECLS_BLOCK_ID, + DECLS_BLOCK_ID + }; - /// \brief The block containing the offsets of all of the - /// declarations stored within the PCH file. + /// \brief Record types that occur within the PCH block itself. + enum PCHRecordTypes { + /// \brief Offset of each type within the types block. /// - /// The offsets in this block point into the block identified by - /// DECLS_BLOCK_ID, and are indexed by the decaration ID. - DECL_OFFSETS_BLOCK_ID + /// The TYPE_OFFSET constant describes the record that occurs + /// within the block identified by TYPE_OFFSETS_BLOCK_ID within + /// the PCH file. The record itself is an array of offsets that + /// point into the types block (identified by TYPES_BLOCK_ID in + /// the PCH file). The index into the array is based on the ID + /// of a type. For a given type ID @c T, the lower three bits of + /// @c T are its qualifiers (const, volatile, restrict), as in + /// the QualType class. The upper bits, after being shifted and + /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the + /// TYPE_OFFSET block to determine the offset of that type's + /// corresponding record within the TYPES_BLOCK_ID block. + TYPE_OFFSET = 1, + + /// \brief Record code for the offsets of each decl. + /// + /// The DECL_OFFSET constant describes the record that occurs + /// within the block identifier by DECL_OFFSETS_BLOCK_ID within + /// the PCH file. The record itself is an array of offsets that + /// point into the declarations block (identified by + /// DECLS_BLOCK_ID). The declaration ID is an index into this + /// record, after subtracting one to account for the use of + /// declaration ID 0 for a NULL declaration pointer. Index 0 is + /// reserved for the translation unit declaration. + DECL_OFFSET = 2 }; /// \brief Record types used within a source manager block. @@ -209,20 +241,6 @@ namespace clang { /// \brief Record code for the offsets of each type. /// - /// The TYPE_OFFSET constant describes the record that occurs - /// within the block identified by TYPE_OFFSETS_BLOCK_ID within - /// the PCH file. The record itself is an array of offsets that - /// point into the types block (identified by TYPES_BLOCK_ID in - /// the PCH file). The index into the array is based on the ID of - /// a type. For a given type ID @c T, the lower three bits of @c T - /// are its qualifiers (const, volatile, restrict), as in the - /// QualType class. The upper bits, after being shifted and - /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the - /// TYPE_OFFSET block to determine the offset of that type's - /// corresponding record within the TYPES_BLOCK_ID block. - enum TypeOffsetCode { - TYPE_OFFSET = 1 - }; /// \brief Record codes for each kind of declaration. /// @@ -255,21 +273,6 @@ namespace clang { /// into a DeclContext via DeclContext::lookup. DECL_CONTEXT_VISIBLE }; - - /// \brief Record code for the offsets of each decl. - /// - /// The DECL_OFFSET constant describes the record that occurs - /// within the block identifier by DECL_OFFSETS_BLOCK_ID within - /// the PCH file. The record itself is an array of offsets that - /// point into the declarations block (identified by - /// DECLS_BLOCK_ID). The declaration ID is an index into this - /// record, after subtracting one to account for the use of - /// declaration ID 0 for a NULL declaration pointer. Index 0 is - /// reserved for the translation unit declaration. - enum DeclOffsetCode { - DECL_OFFSET = 1 - }; - /// @} } } // end namespace clang diff --git a/clang/include/clang/Frontend/PCHReader.h b/clang/include/clang/Frontend/PCHReader.h index fe7632896e9..52354e3eb3a 100644 --- a/clang/include/clang/Frontend/PCHReader.h +++ b/clang/include/clang/Frontend/PCHReader.h @@ -16,6 +16,7 @@ #include "clang/AST/DeclarationName.h" #include "clang/AST/ExternalASTSource.h" #include "clang/AST/Type.h" +#include "clang/Frontend/PCHBitCodes.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" @@ -100,8 +101,6 @@ class PCHReader : public ExternalASTSource { bool ReadPCHBlock(); bool ReadSourceManagerBlock(); - bool ReadTypeOffsets(); - bool ReadDeclOffsets(); QualType ReadTypeRecord(uint64_t Offset); void LoadedDecl(unsigned Index, Decl *D); @@ -122,11 +121,11 @@ public: /// \brief Resolve a type ID into a type, potentially building a new /// type. - virtual QualType GetType(unsigned ID); + virtual QualType GetType(pch::TypeID ID); /// \brief Resolve a declaration ID into a declaration, potentially /// building a new declaration. - virtual Decl *GetDecl(unsigned ID); + virtual Decl *GetDecl(pch::DeclID ID); /// \brief Read all of the declarations lexically stored in a /// declaration context. diff --git a/clang/include/clang/Frontend/PCHWriter.h b/clang/include/clang/Frontend/PCHWriter.h index 01eb2b0a774..a560857be21 100644 --- a/clang/include/clang/Frontend/PCHWriter.h +++ b/clang/include/clang/Frontend/PCHWriter.h @@ -50,7 +50,7 @@ class PCHWriter { /// The ID numbers of declarations are consecutive (in order of /// discovery) and start at 2. 1 is reserved for the translation /// unit, while 0 is reserved for NULL. - llvm::DenseMap<const Decl *, pch::ID> DeclIDs; + llvm::DenseMap<const Decl *, pch::DeclID> DeclIDs; /// \brief Offset of each declaration in the bitstream, indexed by /// the declaration's ID. @@ -67,14 +67,14 @@ class PCHWriter { /// and start at 1. 0 is reserved for NULL. When types are actually /// stored in the stream, the ID number is shifted by 3 bits to /// allow for the const/volatile/restrict qualifiers. - llvm::DenseMap<const Type *, pch::ID> TypeIDs; + llvm::DenseMap<const Type *, pch::TypeID> TypeIDs; /// \brief Offset of each type in the bitstream, indexed by /// the type's ID. llvm::SmallVector<uint64_t, 16> TypeOffsets; /// \brief The type ID that will be assigned to the next new type. - unsigned NextTypeID; + pch::TypeID NextTypeID; void WriteSourceManagerBlock(SourceManager &SourceMgr); void WritePreprocessor(Preprocessor &PP); |