summaryrefslogtreecommitdiffstats
path: root/include/clang/Serialization
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r--include/clang/Serialization/ASTBitCodes.h411
-rw-r--r--include/clang/Serialization/ASTReader.h320
-rw-r--r--include/clang/Serialization/ContinuousRangeMap.h34
3 files changed, 567 insertions, 198 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 42c62257ad..34a7bb3301 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -14,17 +14,23 @@
// respective lists.
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_CLANG_SERIALIZATION_ASTBITCODES_H
#define LLVM_CLANG_SERIALIZATION_ASTBITCODES_H
#include "clang/AST/DeclarationName.h"
#include "clang/AST/Type.h"
-#include "llvm/ADT/DenseMap.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Bitcode/BitCodes.h"
-#include "llvm/Support/DataTypes.h"
+#include <cassert>
+#include <cstdint>
namespace clang {
- namespace serialization {
+namespace serialization {
+
/// \brief AST file major version number supported by this version of
/// Clang.
///
@@ -52,7 +58,7 @@ namespace clang {
///
/// The ID numbers of identifiers are consecutive (in order of discovery)
/// and start at 1. 0 is reserved for NULL.
- typedef uint32_t IdentifierID;
+ using IdentifierID = uint32_t;
/// \brief An ID number that refers to a declaration in an AST file.
///
@@ -60,12 +66,12 @@ namespace clang {
/// discovery), with values below NUM_PREDEF_DECL_IDS being reserved.
/// At the start of a chain of precompiled headers, declaration ID 1 is
/// used for the translation unit declaration.
- typedef uint32_t DeclID;
+ using DeclID = uint32_t;
// FIXME: Turn these into classes so we can have some type safety when
// we go from local ID to global and vice-versa.
- typedef DeclID LocalDeclID;
- typedef DeclID GlobalDeclID;
+ using LocalDeclID = DeclID;
+ using GlobalDeclID = DeclID;
/// \brief An ID number that refers to a type in an AST file.
///
@@ -77,22 +83,25 @@ namespace clang {
/// 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;
+ using TypeID = uint32_t;
/// \brief A type index; the type ID with the qualifier bits removed.
class TypeIdx {
- uint32_t Idx;
+ uint32_t Idx = 0;
+
public:
- TypeIdx() : Idx(0) { }
- explicit TypeIdx(uint32_t index) : Idx(index) { }
+ TypeIdx() = default;
+ explicit TypeIdx(uint32_t index) : Idx(index) {}
uint32_t getIndex() const { return Idx; }
+
TypeID asTypeID(unsigned FastQuals) const {
if (Idx == uint32_t(-1))
return TypeID(-1);
return (Idx << Qualifiers::FastWidth) | FastQuals;
}
+
static TypeIdx fromTypeID(TypeID ID) {
if (ID == TypeID(-1))
return TypeIdx(-1);
@@ -104,14 +113,17 @@ namespace clang {
/// A structure for putting "fast"-unqualified QualTypes into a
/// DenseMap. This uses the standard pointer hash function.
struct UnsafeQualTypeDenseMapInfo {
- static inline bool isEqual(QualType A, QualType B) { return A == B; }
- static inline QualType getEmptyKey() {
+ static bool isEqual(QualType A, QualType B) { return A == B; }
+
+ static QualType getEmptyKey() {
return QualType::getFromOpaquePtr((void*) 1);
}
- static inline QualType getTombstoneKey() {
+
+ static QualType getTombstoneKey() {
return QualType::getFromOpaquePtr((void*) 2);
}
- static inline unsigned getHashValue(QualType T) {
+
+ static unsigned getHashValue(QualType T) {
assert(!T.getLocalFastQualifiers() &&
"hash invalid for types with fast quals");
uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
@@ -120,44 +132,44 @@ namespace clang {
};
/// \brief An ID number that refers to an identifier in an AST file.
- typedef uint32_t IdentID;
+ using IdentID = uint32_t;
/// \brief The number of predefined identifier IDs.
const unsigned int NUM_PREDEF_IDENT_IDS = 1;
/// \brief An ID number that refers to a macro in an AST file.
- typedef uint32_t MacroID;
+ using MacroID = uint32_t;
/// \brief A global ID number that refers to a macro in an AST file.
- typedef uint32_t GlobalMacroID;
+ using GlobalMacroID = uint32_t;
/// \brief A local to a module ID number that refers to a macro in an
/// AST file.
- typedef uint32_t LocalMacroID;
+ using LocalMacroID = uint32_t;
/// \brief The number of predefined macro IDs.
const unsigned int NUM_PREDEF_MACRO_IDS = 1;
/// \brief An ID number that refers to an ObjC selector in an AST file.
- typedef uint32_t SelectorID;
+ using SelectorID = uint32_t;
/// \brief The number of predefined selector IDs.
const unsigned int NUM_PREDEF_SELECTOR_IDS = 1;
/// \brief An ID number that refers to a set of CXXBaseSpecifiers in an
/// AST file.
- typedef uint32_t CXXBaseSpecifiersID;
+ using CXXBaseSpecifiersID = uint32_t;
/// \brief An ID number that refers to a list of CXXCtorInitializers in an
/// AST file.
- typedef uint32_t CXXCtorInitializersID;
+ using CXXCtorInitializersID = uint32_t;
/// \brief An ID number that refers to an entity in the detailed
/// preprocessing record.
- typedef uint32_t PreprocessedEntityID;
+ using PreprocessedEntityID = uint32_t;
/// \brief An ID number that refers to a submodule in a module file.
- typedef uint32_t SubmoduleID;
+ using SubmoduleID = uint32_t;
/// \brief The number of predefined submodule IDs.
const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1;
@@ -166,18 +178,21 @@ namespace clang {
struct PPEntityOffset {
/// \brief Raw source location of beginning of range.
unsigned Begin;
+
/// \brief Raw source location of end of range.
unsigned End;
+
/// \brief Offset in the AST file.
uint32_t BitOffset;
PPEntityOffset(SourceRange R, uint32_t BitOffset)
: Begin(R.getBegin().getRawEncoding()),
- End(R.getEnd().getRawEncoding()),
- BitOffset(BitOffset) { }
+ End(R.getEnd().getRawEncoding()), BitOffset(BitOffset) {}
+
SourceLocation getBegin() const {
return SourceLocation::getFromRawEncoding(Begin);
}
+
SourceLocation getEnd() const {
return SourceLocation::getFromRawEncoding(End);
}
@@ -186,17 +201,19 @@ namespace clang {
/// \brief Source range/offset of a preprocessed entity.
struct DeclOffset {
/// \brief Raw source location.
- unsigned Loc;
+ unsigned Loc = 0;
+
/// \brief Offset in the AST file.
- uint32_t BitOffset;
+ uint32_t BitOffset = 0;
- DeclOffset() : Loc(0), BitOffset(0) { }
+ DeclOffset() = default;
DeclOffset(SourceLocation Loc, uint32_t BitOffset)
- : Loc(Loc.getRawEncoding()),
- BitOffset(BitOffset) { }
+ : Loc(Loc.getRawEncoding()), BitOffset(BitOffset) {}
+
void setLocation(SourceLocation L) {
Loc = L.getRawEncoding();
}
+
SourceLocation getLocation() const {
return SourceLocation::getFromRawEncoding(Loc);
}
@@ -617,17 +634,21 @@ namespace clang {
/// \brief Describes a source location entry (SLocEntry) for a
/// file.
SM_SLOC_FILE_ENTRY = 1,
+
/// \brief Describes a source location entry (SLocEntry) for a
/// buffer.
SM_SLOC_BUFFER_ENTRY = 2,
+
/// \brief Describes a blob that contains the data for a buffer
/// entry. This kind of record always directly follows a
/// SM_SLOC_BUFFER_ENTRY record or a SM_SLOC_FILE_ENTRY with an
/// overridden buffer.
SM_SLOC_BUFFER_BLOB = 3,
+
/// \brief Describes a zlib-compressed blob that contains the data for
/// a buffer entry.
SM_SLOC_BUFFER_BLOB_COMPRESSED = 4,
+
/// \brief Describes a source location entry (SLocEntry) for a
/// macro expansion.
SM_SLOC_EXPANSION_ENTRY = 5
@@ -676,46 +697,63 @@ namespace clang {
enum SubmoduleRecordTypes {
/// \brief Metadata for submodules as a whole.
SUBMODULE_METADATA = 0,
+
/// \brief Defines the major attributes of a submodule, including its
/// name and parent.
SUBMODULE_DEFINITION = 1,
+
/// \brief Specifies the umbrella header used to create this module,
/// if any.
SUBMODULE_UMBRELLA_HEADER = 2,
+
/// \brief Specifies a header that falls into this (sub)module.
SUBMODULE_HEADER = 3,
+
/// \brief Specifies a top-level header that falls into this (sub)module.
SUBMODULE_TOPHEADER = 4,
+
/// \brief Specifies an umbrella directory.
SUBMODULE_UMBRELLA_DIR = 5,
+
/// \brief Specifies the submodules that are imported by this
/// submodule.
SUBMODULE_IMPORTS = 6,
+
/// \brief Specifies the submodules that are re-exported from this
/// submodule.
SUBMODULE_EXPORTS = 7,
+
/// \brief Specifies a required feature.
SUBMODULE_REQUIRES = 8,
+
/// \brief Specifies a header that has been explicitly excluded
/// from this submodule.
SUBMODULE_EXCLUDED_HEADER = 9,
+
/// \brief Specifies a library or framework to link against.
SUBMODULE_LINK_LIBRARY = 10,
+
/// \brief Specifies a configuration macro for this module.
SUBMODULE_CONFIG_MACRO = 11,
+
/// \brief Specifies a conflict with another module.
SUBMODULE_CONFLICT = 12,
+
/// \brief Specifies a header that is private to this submodule.
SUBMODULE_PRIVATE_HEADER = 13,
+
/// \brief Specifies a header that is part of the module but must be
/// textually included.
SUBMODULE_TEXTUAL_HEADER = 14,
+
/// \brief Specifies a header that is private to this submodule but
/// must be textually included.
SUBMODULE_PRIVATE_TEXTUAL_HEADER = 15,
+
/// \brief Specifies some declarations with initializers that must be
/// emitted to initialize the module.
SUBMODULE_INITIALIZERS = 16,
+
/// \brief Specifies the name of the module that will eventually
/// re-export the entities in this module.
SUBMODULE_EXPORT_AS = 17,
@@ -743,94 +781,139 @@ namespace clang {
enum PredefinedTypeIDs {
/// \brief The NULL type.
PREDEF_TYPE_NULL_ID = 0,
+
/// \brief The void type.
PREDEF_TYPE_VOID_ID = 1,
+
/// \brief The 'bool' or '_Bool' type.
PREDEF_TYPE_BOOL_ID = 2,
+
/// \brief The 'char' type, when it is unsigned.
PREDEF_TYPE_CHAR_U_ID = 3,
+
/// \brief The 'unsigned char' type.
PREDEF_TYPE_UCHAR_ID = 4,
+
/// \brief The 'unsigned short' type.
PREDEF_TYPE_USHORT_ID = 5,
+
/// \brief The 'unsigned int' type.
PREDEF_TYPE_UINT_ID = 6,
+
/// \brief The 'unsigned long' type.
PREDEF_TYPE_ULONG_ID = 7,
+
/// \brief The 'unsigned long long' type.
PREDEF_TYPE_ULONGLONG_ID = 8,
+
/// \brief The 'char' type, when it is signed.
PREDEF_TYPE_CHAR_S_ID = 9,
+
/// \brief The 'signed char' type.
PREDEF_TYPE_SCHAR_ID = 10,
+
/// \brief The C++ 'wchar_t' type.
PREDEF_TYPE_WCHAR_ID = 11,
+
/// \brief The (signed) 'short' type.
PREDEF_TYPE_SHORT_ID = 12,
+
/// \brief The (signed) 'int' type.
PREDEF_TYPE_INT_ID = 13,
+
/// \brief The (signed) 'long' type.
PREDEF_TYPE_LONG_ID = 14,
+
/// \brief The (signed) 'long long' type.
PREDEF_TYPE_LONGLONG_ID = 15,
+
/// \brief The 'float' type.
PREDEF_TYPE_FLOAT_ID = 16,
+
/// \brief The 'double' type.
PREDEF_TYPE_DOUBLE_ID = 17,
+
/// \brief The 'long double' type.
PREDEF_TYPE_LONGDOUBLE_ID = 18,
+
/// \brief The placeholder type for overloaded function sets.
PREDEF_TYPE_OVERLOAD_ID = 19,
+
/// \brief The placeholder type for dependent types.
PREDEF_TYPE_DEPENDENT_ID = 20,
+
/// \brief The '__uint128_t' type.
PREDEF_TYPE_UINT128_ID = 21,
+
/// \brief The '__int128_t' type.
PREDEF_TYPE_INT128_ID = 22,
+
/// \brief The type of 'nullptr'.
PREDEF_TYPE_NULLPTR_ID = 23,
+
/// \brief The C++ 'char16_t' type.
PREDEF_TYPE_CHAR16_ID = 24,
+
/// \brief The C++ 'char32_t' type.
PREDEF_TYPE_CHAR32_ID = 25,
+
/// \brief The ObjC 'id' type.
PREDEF_TYPE_OBJC_ID = 26,
+
/// \brief The ObjC 'Class' type.
PREDEF_TYPE_OBJC_CLASS = 27,
+
/// \brief The ObjC 'SEL' type.
PREDEF_TYPE_OBJC_SEL = 28,
+
/// \brief The 'unknown any' placeholder type.
PREDEF_TYPE_UNKNOWN_ANY = 29,
+
/// \brief The placeholder type for bound member functions.
PREDEF_TYPE_BOUND_MEMBER = 30,
+
/// \brief The "auto" deduction type.
PREDEF_TYPE_AUTO_DEDUCT = 31,
+
/// \brief The "auto &&" deduction type.
PREDEF_TYPE_AUTO_RREF_DEDUCT = 32,
+
/// \brief The OpenCL 'half' / ARM NEON __fp16 type.
PREDEF_TYPE_HALF_ID = 33,
+
/// \brief ARC's unbridged-cast placeholder type.
PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34,
+
/// \brief The pseudo-object placeholder type.
PREDEF_TYPE_PSEUDO_OBJECT = 35,
+
/// \brief The placeholder type for builtin functions.
PREDEF_TYPE_BUILTIN_FN = 36,
+
/// \brief OpenCL event type.
PREDEF_TYPE_EVENT_ID = 37,
+
/// \brief OpenCL clk event type.
PREDEF_TYPE_CLK_EVENT_ID = 38,
+
/// \brief OpenCL sampler type.
PREDEF_TYPE_SAMPLER_ID = 39,
+
/// \brief OpenCL queue type.
PREDEF_TYPE_QUEUE_ID = 40,
+
/// \brief OpenCL reserve_id type.
PREDEF_TYPE_RESERVE_ID_ID = 41,
+
/// \brief The placeholder type for OpenMP array section.
PREDEF_TYPE_OMP_ARRAY_SECTION = 42,
+
/// \brief The '__float128' type
PREDEF_TYPE_FLOAT128_ID = 43,
+
/// \brief The '_Float16' type
PREDEF_TYPE_FLOAT16_ID = 44,
+
/// \brief OpenCL image types with auto numeration
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
PREDEF_TYPE_##Id##_ID,
@@ -853,94 +936,139 @@ namespace clang {
enum TypeCode {
/// \brief An ExtQualType record.
TYPE_EXT_QUAL = 1,
+
/// \brief A ComplexType record.
TYPE_COMPLEX = 3,
+
/// \brief A PointerType record.
TYPE_POINTER = 4,
+
/// \brief A BlockPointerType record.
TYPE_BLOCK_POINTER = 5,
+
/// \brief An LValueReferenceType record.
TYPE_LVALUE_REFERENCE = 6,
+
/// \brief An RValueReferenceType record.
TYPE_RVALUE_REFERENCE = 7,
+
/// \brief A MemberPointerType record.
TYPE_MEMBER_POINTER = 8,
+
/// \brief A ConstantArrayType record.
TYPE_CONSTANT_ARRAY = 9,
+
/// \brief An IncompleteArrayType record.
TYPE_INCOMPLETE_ARRAY = 10,
+
/// \brief A VariableArrayType record.
TYPE_VARIABLE_ARRAY = 11,
+
/// \brief A VectorType record.
TYPE_VECTOR = 12,
+
/// \brief An ExtVectorType record.
TYPE_EXT_VECTOR = 13,
+
/// \brief A FunctionNoProtoType record.
TYPE_FUNCTION_NO_PROTO = 14,
+
/// \brief A FunctionProtoType record.
TYPE_FUNCTION_PROTO = 15,
+
/// \brief A TypedefType record.
TYPE_TYPEDEF = 16,
+
/// \brief A TypeOfExprType record.
TYPE_TYPEOF_EXPR = 17,
+
/// \brief A TypeOfType record.
TYPE_TYPEOF = 18,
+
/// \brief A RecordType record.
TYPE_RECORD = 19,
+
/// \brief An EnumType record.
TYPE_ENUM = 20,
+
/// \brief An ObjCInterfaceType record.
TYPE_OBJC_INTERFACE = 21,
+
/// \brief An ObjCObjectPointerType record.
TYPE_OBJC_OBJECT_POINTER = 22,
+
/// \brief a DecltypeType record.
TYPE_DECLTYPE = 23,
+
/// \brief An ElaboratedType record.
TYPE_ELABORATED = 24,
+
/// \brief A SubstTemplateTypeParmType record.
TYPE_SUBST_TEMPLATE_TYPE_PARM = 25,
+
/// \brief An UnresolvedUsingType record.
TYPE_UNRESOLVED_USING = 26,
+
/// \brief An InjectedClassNameType record.
TYPE_INJECTED_CLASS_NAME = 27,
+
/// \brief An ObjCObjectType record.
TYPE_OBJC_OBJECT = 28,
+
/// \brief An TemplateTypeParmType record.
TYPE_TEMPLATE_TYPE_PARM = 29,
+
/// \brief An TemplateSpecializationType record.
TYPE_TEMPLATE_SPECIALIZATION = 30,
+
/// \brief A DependentNameType record.
TYPE_DEPENDENT_NAME = 31,
+
/// \brief A DependentTemplateSpecializationType record.
TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION = 32,
+
/// \brief A DependentSizedArrayType record.
TYPE_DEPENDENT_SIZED_ARRAY = 33,
+
/// \brief A ParenType record.
TYPE_PAREN = 34,
+
/// \brief A PackExpansionType record.
TYPE_PACK_EXPANSION = 35,
+
/// \brief An AttributedType record.
TYPE_ATTRIBUTED = 36,
+
/// \brief A SubstTemplateTypeParmPackType record.
TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK = 37,
+
/// \brief A AutoType record.
TYPE_AUTO = 38,
+
/// \brief A UnaryTransformType record.
TYPE_UNARY_TRANSFORM = 39,
+
/// \brief An AtomicType record.
TYPE_ATOMIC = 40,
+
/// \brief A DecayedType record.
TYPE_DECAYED = 41,
+
/// \brief An AdjustedType record.
TYPE_ADJUSTED = 42,
+
/// \brief A PipeType record.
TYPE_PIPE = 43,
+
/// \brief An ObjCTypeParamType record.
TYPE_OBJC_TYPE_PARAM = 44,
+
/// \brief A DeducedTemplateSpecializationType record.
TYPE_DEDUCED_TEMPLATE_SPECIALIZATION = 45,
+
/// \brief A DependentSizedExtVectorType record.
TYPE_DEPENDENT_SIZED_EXT_VECTOR = 46,
+
/// \brief A DependentAddressSpaceType record.
TYPE_DEPENDENT_ADDRESS_SPACE = 47
};
@@ -953,18 +1081,25 @@ namespace clang {
enum SpecialTypeIDs {
/// \brief CFConstantString type
SPECIAL_TYPE_CF_CONSTANT_STRING = 0,
+
/// \brief C FILE typedef type
SPECIAL_TYPE_FILE = 1,
+
/// \brief C jmp_buf typedef type
SPECIAL_TYPE_JMP_BUF = 2,
+
/// \brief C sigjmp_buf typedef type
SPECIAL_TYPE_SIGJMP_BUF = 3,
+
/// \brief Objective-C "id" redefinition type
SPECIAL_TYPE_OBJC_ID_REDEFINITION = 4,
+
/// \brief Objective-C "Class" redefinition type
SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 5,
+
/// \brief Objective-C "SEL" redefinition type
SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 6,
+
/// \brief C ucontext_t typedef type
SPECIAL_TYPE_UCONTEXT_T = 7
};
@@ -1055,57 +1190,84 @@ namespace clang {
/// \brief A TypedefDecl record.
DECL_TYPEDEF = 51,
/// \brief A TypeAliasDecl record.
+
DECL_TYPEALIAS,
+
/// \brief An EnumDecl record.
DECL_ENUM,
+
/// \brief A RecordDecl record.
DECL_RECORD,
+
/// \brief An EnumConstantDecl record.
DECL_ENUM_CONSTANT,
+
/// \brief A FunctionDecl record.
DECL_FUNCTION,
+
/// \brief A ObjCMethodDecl record.
DECL_OBJC_METHOD,
+
/// \brief A ObjCInterfaceDecl record.
DECL_OBJC_INTERFACE,
+
/// \brief A ObjCProtocolDecl record.
DECL_OBJC_PROTOCOL,
+
/// \brief A ObjCIvarDecl record.
DECL_OBJC_IVAR,
+
/// \brief A ObjCAtDefsFieldDecl record.
DECL_OBJC_AT_DEFS_FIELD,
+
/// \brief A ObjCCategoryDecl record.
DECL_OBJC_CATEGORY,
+
/// \brief A ObjCCategoryImplDecl record.
DECL_OBJC_CATEGORY_IMPL,
+
/// \brief A ObjCImplementationDecl record.
DECL_OBJC_IMPLEMENTATION,
+
/// \brief A ObjCCompatibleAliasDecl record.
DECL_OBJC_COMPATIBLE_ALIAS,
+
/// \brief A ObjCPropertyDecl record.
DECL_OBJC_PROPERTY,
+
/// \brief A ObjCPropertyImplDecl record.
DECL_OBJC_PROPERTY_IMPL,
+
/// \brief A FieldDecl record.
DECL_FIELD,
+
/// \brief A MSPropertyDecl record.
DECL_MS_PROPERTY,
+
/// \brief A VarDecl record.
DECL_VAR,
+
/// \brief An ImplicitParamDecl record.
DECL_IMPLICIT_PARAM,
+
/// \brief A ParmVarDecl record.
DECL_PARM_VAR,
+
/// \brief A DecompositionDecl record.
DECL_DECOMPOSITION,
+
/// \brief A BindingDecl record.
DECL_BINDING,
+
/// \brief A FileScopeAsmDecl record.
DECL_FILE_SCOPE_ASM,
+
/// \brief A BlockDecl record.
DECL_BLOCK,
+
/// \brief A CapturedDecl record.
DECL_CAPTURED,
+
/// \brief A record that stores the set of declarations that are
/// lexically stored within a given DeclContext.
///
@@ -1115,6 +1277,7 @@ namespace clang {
/// the contents of a DeclContext, e.g., via
/// DeclContext::decls_begin() and DeclContext::decls_end().
DECL_CONTEXT_LEXICAL,
+
/// \brief A record that stores the set of declarations that are
/// visible from a given DeclContext.
///
@@ -1123,104 +1286,151 @@ namespace clang {
/// IDs. This data is used when performing qualified name lookup
/// into a DeclContext via DeclContext::lookup.
DECL_CONTEXT_VISIBLE,
+
/// \brief A LabelDecl record.
DECL_LABEL,
+
/// \brief A NamespaceDecl record.
DECL_NAMESPACE,
+
/// \brief A NamespaceAliasDecl record.
DECL_NAMESPACE_ALIAS,
+
/// \brief A UsingDecl record.
DECL_USING,
+
/// \brief A UsingPackDecl record.
DECL_USING_PACK,
+
/// \brief A UsingShadowDecl record.
DECL_USING_SHADOW,
+
/// \brief A ConstructorUsingShadowDecl record.
DECL_CONSTRUCTOR_USING_SHADOW,
+
/// \brief A UsingDirecitveDecl record.
DECL_USING_DIRECTIVE,
+
/// \brief An UnresolvedUsingValueDecl record.
DECL_UNRESOLVED_USING_VALUE,
+
/// \brief An UnresolvedUsingTypenameDecl record.
DECL_UNRESOLVED_USING_TYPENAME,
+
/// \brief A LinkageSpecDecl record.
DECL_LINKAGE_SPEC,
+
/// \brief An ExportDecl record.
DECL_EXPORT,
+
/// \brief A CXXRecordDecl record.
DECL_CXX_RECORD,
+
/// \brief A CXXDeductionGuideDecl record.
DECL_CXX_DEDUCTION_GUIDE,
+
/// \brief A CXXMethodDecl record.
DECL_CXX_METHOD,
+
/// \brief A CXXConstructorDecl record.
DECL_CXX_CONSTRUCTOR,
+
/// \brief A CXXConstructorDecl record for an inherited constructor.
DECL_CXX_INHERITED_CONSTRUCTOR,
+
/// \brief A CXXDestructorDecl record.
DECL_CXX_DESTRUCTOR,
+
/// \brief A CXXConversionDecl record.
DECL_CXX_CONVERSION,
+
/// \brief An AccessSpecDecl record.
DECL_ACCESS_SPEC,
/// \brief A FriendDecl record.
DECL_FRIEND,
+
/// \brief A FriendTemplateDecl record.
DECL_FRIEND_TEMPLATE,
+
/// \brief A ClassTemplateDecl record.
DECL_CLASS_TEMPLATE,
+
/// \brief A ClassTemplateSpecializationDecl record.
DECL_CLASS_TEMPLATE_SPECIALIZATION,
+
/// \brief A ClassTemplatePartialSpecializationDecl record.
DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION,
+
/// \brief A VarTemplateDecl record.
DECL_VAR_TEMPLATE,
+
/// \brief A VarTemplateSpecializationDecl record.
DECL_VAR_TEMPLATE_SPECIALIZATION,
+
/// \brief A VarTemplatePartialSpecializationDecl record.
DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION,
+
/// \brief A FunctionTemplateDecl record.
DECL_FUNCTION_TEMPLATE,
+
/// \brief A TemplateTypeParmDecl record.
DECL_TEMPLATE_TYPE_PARM,
+
/// \brief A NonTypeTemplateParmDecl record.
DECL_NON_TYPE_TEMPLATE_PARM,
+
/// \brief A TemplateTemplateParmDecl record.
DECL_TEMPLATE_TEMPLATE_PARM,
+
/// \brief A TypeAliasTemplateDecl record.
DECL_TYPE_ALIAS_TEMPLATE,
+
/// \brief A StaticAssertDecl record.
DECL_STATIC_ASSERT,
+
/// \brief A record containing CXXBaseSpecifiers.
DECL_CXX_BASE_SPECIFIERS,
+
/// \brief A record containing CXXCtorInitializers.
DECL_CXX_CTOR_INITIALIZERS,
+
/// \brief A IndirectFieldDecl record.
DECL_INDIRECTFIELD,
+
/// \brief A NonTypeTemplateParmDecl record that stores an expanded
/// non-type template parameter pack.
DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK,
+
/// \brief A TemplateTemplateParmDecl record that stores an expanded
/// template template parameter pack.
DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK,
+
/// \brief A ClassScopeFunctionSpecializationDecl record a class scope
/// function specialization. (Microsoft extension).
DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION,
+
/// \brief An ImportDecl recording a module import.
DECL_IMPORT,
+
/// \brief An OMPThreadPrivateDecl record.
DECL_OMP_THREADPRIVATE,
+
/// \brief An EmptyDecl record.
DECL_EMPTY,
+
/// \brief An ObjCTypeParamDecl record.
DECL_OBJC_TYPE_PARAM,
+
/// \brief An OMPCapturedExprDecl record.
DECL_OMP_CAPTUREDEXPR,
+
/// \brief A PragmaCommentDecl record.
DECL_PRAGMA_COMMENT,
+
/// \brief A PragmaDetectMismatchDecl record.
DECL_PRAGMA_DETECT_MISMATCH,
+
/// \brief An OMPDeclareReductionDecl record.
DECL_OMP_DECLARE_REDUCTION,
};
@@ -1236,128 +1446,190 @@ namespace clang {
/// \brief A marker record that indicates that we are at the end
/// of an expression.
STMT_STOP = 128,
+
/// \brief A NULL expression.
STMT_NULL_PTR,
+
/// \brief A reference to a previously [de]serialized Stmt record.
STMT_REF_PTR,
+
/// \brief A NullStmt record.
STMT_NULL,
+
/// \brief A CompoundStmt record.
STMT_COMPOUND,
+
/// \brief A CaseStmt record.
STMT_CASE,
+
/// \brief A DefaultStmt record.
STMT_DEFAULT,
+
/// \brief A LabelStmt record.
STMT_LABEL,
+
/// \brief An AttributedStmt record.
STMT_ATTRIBUTED,
+
/// \brief An IfStmt record.
STMT_IF,
+
/// \brief A SwitchStmt record.
STMT_SWITCH,
+
/// \brief A WhileStmt record.
STMT_WHILE,
+
/// \brief A DoStmt record.
STMT_DO,
+
/// \brief A ForStmt record.
STMT_FOR,
+
/// \brief A GotoStmt record.
STMT_GOTO,
+
/// \brief An IndirectGotoStmt record.
STMT_INDIRECT_GOTO,
+
/// \brief A ContinueStmt record.
STMT_CONTINUE,
+
/// \brief A BreakStmt record.
STMT_BREAK,
+
/// \brief A ReturnStmt record.
STMT_RETURN,
+
/// \brief A DeclStmt record.
STMT_DECL,
+
/// \brief A CapturedStmt record.
STMT_CAPTURED,
+
/// \brief A GCC-style AsmStmt record.
STMT_GCCASM,
+
/// \brief A MS-style AsmStmt record.
STMT_MSASM,
+
/// \brief A PredefinedExpr record.
EXPR_PREDEFINED,
+
/// \brief A DeclRefExpr record.
EXPR_DECL_REF,
+
/// \brief An IntegerLiteral record.
EXPR_INTEGER_LITERAL,
+
/// \brief A FloatingLiteral record.
EXPR_FLOATING_LITERAL,
+
/// \brief An ImaginaryLiteral record.
EXPR_IMAGINARY_LITERAL,
+
/// \brief A StringLiteral record.
EXPR_STRING_LITERAL,
+
/// \brief A CharacterLiteral record.
EXPR_CHARACTER_LITERAL,
+
/// \brief A ParenExpr record.
EXPR_PAREN,
+
/// \brief A ParenListExpr record.
EXPR_PAREN_LIST,
+
/// \brief A UnaryOperator record.
EXPR_UNARY_OPERATOR,
+
/// \brief An OffsetOfExpr record.
EXPR_OFFSETOF,
+
/// \brief A SizefAlignOfExpr record.
EXPR_SIZEOF_ALIGN_OF,
+
/// \brief An ArraySubscriptExpr record.
EXPR_ARRAY_SUBSCRIPT,
+
/// \brief A CallExpr record.
EXPR_CALL,
+
/// \brief A MemberExpr record.
EXPR_MEMBER,
+
/// \brief A BinaryOperator record.
EXPR_BINARY_OPERATOR,
+
/// \brief A CompoundAssignOperator record.
EXPR_COMPOUND_ASSIGN_OPERATOR,
+
/// \brief A ConditionOperator record.
EXPR_CONDITIONAL_OPERATOR,
+
/// \brief An ImplicitCastExpr record.
EXPR_IMPLICIT_CAST,
+
/// \brief A CStyleCastExpr record.
EXPR_CSTYLE_CAST,
+
/// \brief A CompoundLiteralExpr record.
EXPR_COMPOUND_LITERAL,
+
/// \brief An ExtVectorElementExpr record.
EXPR_EXT_VECTOR_ELEMENT,
+
/// \brief An InitListExpr record.
EXPR_INIT_LIST,
+
/// \brief A DesignatedInitExpr record.
EXPR_DESIGNATED_INIT,
+
/// \brief A DesignatedInitUpdateExpr record.
EXPR_DESIGNATED_INIT_UPDATE,
+
/// \brief An NoInitExpr record.
EXPR_NO_INIT,
+
/// \brief An ArrayInitLoopExpr record.
EXPR_ARRAY_INIT_LOOP,
+
/// \brief An ArrayInitIndexExpr record.
EXPR_ARRAY_INIT_INDEX,
+
/// \brief An ImplicitValueInitExpr record.
EXPR_IMPLICIT_VALUE_INIT,
+
/// \brief A VAArgExpr record.
EXPR_VA_ARG,
+
/// \brief An AddrLabelExpr record.
EXPR_ADDR_LABEL,
+
/// \brief A StmtExpr record.
EXPR_STMT,
+
/// \brief A ChooseExpr record.
EXPR_CHOOSE,
+
/// \brief A GNUNullExpr record.
EXPR_GNU_NULL,
+
/// \brief A ShuffleVectorExpr record.
EXPR_SHUFFLE_VECTOR,
+
/// \brief A ConvertVectorExpr record.
EXPR_CONVERT_VECTOR,
+
/// \brief BlockExpr
EXPR_BLOCK,
+
/// \brief A GenericSelectionExpr record.
EXPR_GENERIC_SELECTION,
+
/// \brief A PseudoObjectExpr record.
EXPR_PSEUDO_OBJECT,
+
/// \brief An AtomicExpr record.
EXPR_ATOMIC,
@@ -1369,45 +1641,61 @@ namespace clang {
EXPR_OBJC_BOXED_EXPRESSION,
EXPR_OBJC_ARRAY_LITERAL,
EXPR_OBJC_DICTIONARY_LITERAL,
-
-
+
/// \brief An ObjCEncodeExpr record.
EXPR_OBJC_ENCODE,
+
/// \brief An ObjCSelectorExpr record.
EXPR_OBJC_SELECTOR_EXPR,
+
/// \brief An ObjCProtocolExpr record.
EXPR_OBJC_PROTOCOL_EXPR,
+
/// \brief An ObjCIvarRefExpr record.
EXPR_OBJC_IVAR_REF_EXPR,
+
/// \brief An ObjCPropertyRefExpr record.
EXPR_OBJC_PROPERTY_REF_EXPR,
+
/// \brief An ObjCSubscriptRefExpr record.
EXPR_OBJC_SUBSCRIPT_REF_EXPR,
+
/// \brief UNUSED
EXPR_OBJC_KVC_REF_EXPR,
+
/// \brief An ObjCMessageExpr record.
EXPR_OBJC_MESSAGE_EXPR,
+
/// \brief An ObjCIsa Expr record.
EXPR_OBJC_ISA,
+
/// \brief An ObjCIndirectCopyRestoreExpr record.
EXPR_OBJC_INDIRECT_COPY_RESTORE,
/// \brief An ObjCForCollectionStmt record.
STMT_OBJC_FOR_COLLECTION,
+
/// \brief An ObjCAtCatchStmt record.
STMT_OBJC_CATCH,
+
/// \brief An ObjCAtFinallyStmt record.
STMT_OBJC_FINALLY,
+
/// \brief An ObjCAtTryStmt record.
STMT_OBJC_AT_TRY,
+
/// \brief An ObjCAtSynchronizedStmt record.
STMT_OBJC_AT_SYNCHRONIZED,
+
/// \brief An ObjCAtThrowStmt record.
STMT_OBJC_AT_THROW,
+
/// \brief An ObjCAutoreleasePoolStmt record.
STMT_OBJC_AUTORELEASE_POOL,
+
/// \brief An ObjCBoolLiteralExpr record.
EXPR_OBJC_BOOL_LITERAL,
+
/// \brief An ObjCAvailabilityCheckExpr record.
EXPR_OBJC_AVAILABILITY_CHECK,
@@ -1415,37 +1703,52 @@ namespace clang {
/// \brief A CXXCatchStmt record.
STMT_CXX_CATCH,
+
/// \brief A CXXTryStmt record.
STMT_CXX_TRY,
/// \brief A CXXForRangeStmt record.
+
STMT_CXX_FOR_RANGE,
/// \brief A CXXOperatorCallExpr record.
EXPR_CXX_OPERATOR_CALL,
+
/// \brief A CXXMemberCallExpr record.
EXPR_CXX_MEMBER_CALL,
+
/// \brief A CXXConstructExpr record.
EXPR_CXX_CONSTRUCT,
+
/// \brief A CXXInheritedCtorInitExpr record.
EXPR_CXX_INHERITED_CTOR_INIT,
+
/// \brief A CXXTemporaryObjectExpr record.
EXPR_CXX_TEMPORARY_OBJECT,
+
/// \brief A CXXStaticCastExpr record.
EXPR_CXX_STATIC_CAST,
+
/// \brief A CXXDynamicCastExpr record.
EXPR_CXX_DYNAMIC_CAST,
+
/// \brief A CXXReinterpretCastExpr record.
EXPR_CXX_REINTERPRET_CAST,
+
/// \brief A CXXConstCastExpr record.
EXPR_CXX_CONST_CAST,
+
/// \brief A CXXFunctionalCastExpr record.
EXPR_CXX_FUNCTIONAL_CAST,
+
/// \brief A UserDefinedLiteral record.
EXPR_USER_DEFINED_LITERAL,
+
/// \brief A CXXStdInitializerListExpr record.
EXPR_CXX_STD_INITIALIZER_LIST,
+
/// \brief A CXXBoolLiteralExpr record.
EXPR_CXX_BOOL_LITERAL,
+
EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr
EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr).
EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type).
@@ -1567,11 +1870,14 @@ namespace clang {
enum DesignatorTypes {
/// \brief Field designator where only the field name is known.
DESIG_FIELD_NAME = 0,
+
/// \brief Field designator where the field has been resolved to
/// a declaration.
DESIG_FIELD_DECL = 1,
+
/// \brief Array designator.
DESIG_ARRAY = 2,
+
/// \brief GNU array range designator.
DESIG_ARRAY_RANGE = 3
};
@@ -1587,8 +1893,11 @@ namespace clang {
/// \brief Describes the redeclarations of a declaration.
struct LocalRedeclarationsInfo {
- DeclID FirstID; // The ID of the first declaration
- unsigned Offset; // Offset into the array of redeclaration chains.
+ // The ID of the first declaration
+ DeclID FirstID;
+
+ // Offset into the array of redeclaration chains.
+ unsigned Offset;
friend bool operator<(const LocalRedeclarationsInfo &X,
const LocalRedeclarationsInfo &Y) {
@@ -1613,8 +1922,11 @@ namespace clang {
/// \brief Describes the categories of an Objective-C class.
struct ObjCCategoriesInfo {
- DeclID DefinitionID; // The ID of the definition
- unsigned Offset; // Offset into the array of category lists.
+ // The ID of the definition
+ DeclID DefinitionID;
+
+ // Offset into the array of category lists.
+ unsigned Offset;
friend bool operator<(const ObjCCategoriesInfo &X,
const ObjCCategoriesInfo &Y) {
@@ -1643,15 +1955,14 @@ namespace clang {
/// same key can occasionally represent multiple names (for names that
/// contain types, in particular).
class DeclarationNameKey {
- typedef unsigned NameKind;
+ using NameKind = unsigned;
- NameKind Kind;
- uint64_t Data;
+ NameKind Kind = 0;
+ uint64_t Data = 0;
public:
- DeclarationNameKey() : Kind(), Data() {}
+ DeclarationNameKey() = default;
DeclarationNameKey(DeclarationName Name);
-
DeclarationNameKey(NameKind Kind, uint64_t Data)
: Kind(Kind), Data(Data) {}
@@ -1663,12 +1974,14 @@ namespace clang {
Kind == DeclarationName::CXXDeductionGuideName);
return (IdentifierInfo *)Data;
}
+
Selector getSelector() const {
assert(Kind == DeclarationName::ObjCZeroArgSelector ||
Kind == DeclarationName::ObjCOneArgSelector ||
Kind == DeclarationName::ObjCMultiArgSelector);
return Selector(Data);
}
+
OverloadedOperatorKind getOperatorKind() const {
assert(Kind == DeclarationName::CXXOperatorName);
return (OverloadedOperatorKind)Data;
@@ -1684,26 +1997,32 @@ namespace clang {
};
/// @}
- }
-} // end namespace clang
+
+} // namespace serialization
+} // namespace clang
namespace llvm {
+
template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> {
static clang::serialization::DeclarationNameKey getEmptyKey() {
return clang::serialization::DeclarationNameKey(-1, 1);
}
+
static clang::serialization::DeclarationNameKey getTombstoneKey() {
return clang::serialization::DeclarationNameKey(-1, 2);
}
+
static unsigned
getHashValue(const clang::serialization::DeclarationNameKey &Key) {
return Key.getHash();
}
+
static bool isEqual(const clang::serialization::DeclarationNameKey &L,
const clang::serialization::DeclarationNameKey &R) {
return L == R;
}
};
-}
-#endif
+} // namespace llvm
+
+#endif // LLVM_CLANG_SERIALIZATION_ASTBITCODES_H
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index 9c5ad00691..7b71fee95d 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -1,4 +1,4 @@
-//===--- ASTReader.h - AST File Reader --------------------------*- C++ -*-===//
+//===- ASTReader.h - AST File Reader ----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,13 +17,21 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/Module.h"
+#include "clang/Basic/OpenCLOptions.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Version.h"
+#include "clang/Basic/VersionTuple.h"
#include "clang/Lex/ExternalPreprocessorSource.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/PreprocessingRecord.h"
+#include "clang/Lex/Token.h"
#include "clang/Sema/ExternalSemaSource.h"
#include "clang/Sema/IdentifierResolver.h"
#include "clang/Serialization/ASTBitCodes.h"
@@ -31,70 +39,86 @@
#include "clang/Serialization/Module.h"
#include "clang/Serialization/ModuleFileExtension.h"
#include "clang/Serialization/ModuleManager.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Timer.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <ctime>
#include <deque>
#include <memory>
+#include <set>
#include <string>
#include <utility>
#include <vector>
-namespace llvm {
- class BitstreamCursor;
- class MemoryBuffer;
- class APInt;
- class APSInt;
- class APFloat;
-}
-
namespace clang {
-class SourceManager;
-class HeaderSearchOptions;
-class FileManager;
-class AddrLabelExpr;
class ASTConsumer;
class ASTContext;
-class ASTIdentifierIterator;
-class ASTUnit; // FIXME: Layering violation and egregious hack.
-class Attr;
-class Decl;
-class DeclContext;
-class DefMacroDirective;
-class DiagnosticOptions;
-class NestedNameSpecifier;
+class ASTDeserializationListener;
+class ASTReader;
+class ASTRecordReader;
class CXXBaseSpecifier;
class CXXConstructorDecl;
class CXXCtorInitializer;
+class CXXTemporary;
+class Decl;
+class DeclaratorDecl;
+class DeclContext;
+class EnumDecl;
+class Expr;
+class FieldDecl;
+class FileEntry;
+class FileManager;
+class FileSystemOptions;
+class FunctionDecl;
class GlobalModuleIndex;
-class GotoStmt;
-class MacroDefinition;
-class MacroDirective;
-class ModuleMacro;
+struct HeaderFileInfo;
+class HeaderSearchOptions;
+class LangOptions;
+class LazyASTUnresolvedSet;
+class MacroInfo;
+class MemoryBufferCache;
class NamedDecl;
-class OpaqueValueExpr;
+class NamespaceDecl;
+class NestedNameSpecifier;
+class ObjCCategoryDecl;
+class ObjCInterfaceDecl;
+class PCHContainerReader;
class Preprocessor;
class PreprocessorOptions;
+struct QualifierInfo;
class Sema;
+class SourceManager;
+class Stmt;
class SwitchCase;
-class ASTDeserializationListener;
-class ASTWriter;
-class ASTReader;
-class ASTDeclReader;
-class ASTStmtReader;
-class ASTRecordReader;
-class TypeLocReader;
-struct HeaderFileInfo;
-class VersionTuple;
class TargetOptions;
-class LazyASTUnresolvedSet;
+class TemplateParameterList;
+class TypedefNameDecl;
+class TypeSourceInfo;
+class ValueDecl;
+class VarDecl;
/// \brief Abstract interface for callback invocations by the ASTReader.
///
@@ -189,9 +213,11 @@ public:
/// \brief Returns true if this \c ASTReaderListener wants to receive the
/// input files of the AST file via \c visitInputFile, false otherwise.
virtual bool needsInputFileVisitation() { return false; }
+
/// \brief Returns true if this \c ASTReaderListener wants to receive the
/// system input files of the AST file via \c visitInputFile, false otherwise.
virtual bool needsSystemInputFileVisitation() { return false; }
+
/// \brief if \c needsInputFileVisitation returns true, this is called for
/// each non-system input file of the AST File. If
/// \c needsSystemInputFileVisitation is true, then it is called for all
@@ -206,6 +232,7 @@ public:
/// \brief Returns true if this \c ASTReaderListener wants to receive the
/// imports of the AST file via \c visitImport, false otherwise.
virtual bool needsImportVisitation() const { return false; }
+
/// \brief If needsImportVisitation returns \c true, this is called for each
/// AST file imported by this AST file.
virtual void visitImport(StringRef Filename) {}
@@ -306,12 +333,15 @@ namespace serialization {
class ReadMethodPoolVisitor;
namespace reader {
- class ASTIdentifierLookupTrait;
- /// \brief The on-disk hash table(s) used for DeclContext name lookup.
- struct DeclContextLookupTable;
-}
-} // end namespace serialization
+class ASTIdentifierLookupTrait;
+
+/// \brief The on-disk hash table(s) used for DeclContext name lookup.
+struct DeclContextLookupTable;
+
+} // namespace reader
+
+} // namespace serialization
/// \brief Reads an AST files chain containing the contents of a translation
/// unit.
@@ -334,8 +364,20 @@ class ASTReader
public ExternalSLocEntrySource
{
public:
- typedef SmallVector<uint64_t, 64> RecordData;
- typedef SmallVectorImpl<uint64_t> RecordDataImpl;
+ /// \brief Types of AST files.
+ friend class ASTDeclReader;
+ friend class ASTIdentifierIterator;
+ friend class ASTRecordReader;
+ friend class ASTStmtReader;
+ friend class ASTUnit; // ASTUnit needs to remap source locations.
+ friend class ASTWriter;
+ friend class PCHValidator;
+ friend class serialization::reader::ASTIdentifierLookupTrait;
+ friend class serialization::ReadMethodPoolVisitor;
+ friend class TypeLocReader;
+
+ using RecordData = SmallVector<uint64_t, 64>;
+ using RecordDataImpl = SmallVectorImpl<uint64_t>;
/// \brief The result of reading the control block of an AST file, which
/// can fail for various reasons.
@@ -343,41 +385,34 @@ public:
/// \brief The control block was read successfully. Aside from failures,
/// the AST file is safe to read into the current context.
Success,
+
/// \brief The AST file itself appears corrupted.
Failure,
+
/// \brief The AST file was missing.
Missing,
+
/// \brief The AST file is out-of-date relative to its input files,
/// and needs to be regenerated.
OutOfDate,
+
/// \brief The AST file was written by a different version of Clang.
VersionMismatch,
+
/// \brief The AST file was writtten with a different language/target
/// configuration.
ConfigurationMismatch,
+
/// \brief The AST file has errors.
HadErrors
};
- /// \brief Types of AST files.
- friend class PCHValidator;
- friend class ASTDeclReader;
- friend class ASTStmtReader;
- friend class ASTIdentifierIterator;
- friend class serialization::reader::ASTIdentifierLookupTrait;
- friend class TypeLocReader;
- friend class ASTRecordReader;
- friend class ASTWriter;
- friend class ASTUnit; // ASTUnit needs to remap source locations.
- friend class serialization::ReadMethodPoolVisitor;
-
- typedef serialization::ModuleFile ModuleFile;
- typedef serialization::ModuleKind ModuleKind;
- typedef serialization::ModuleManager ModuleManager;
-
- typedef ModuleManager::ModuleIterator ModuleIterator;
- typedef ModuleManager::ModuleConstIterator ModuleConstIterator;
- typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator;
+ using ModuleFile = serialization::ModuleFile;
+ using ModuleKind = serialization::ModuleKind;
+ using ModuleManager = serialization::ModuleManager;
+ using ModuleIterator = ModuleManager::ModuleIterator;
+ using ModuleConstIterator = ModuleManager::ModuleConstIterator;
+ using ModuleReverseIterator = ModuleManager::ModuleReverseIterator;
private:
/// \brief The receiver of some callbacks invoked by ASTReader.
@@ -385,6 +420,7 @@ private:
/// \brief The receiver of deserialization events.
ASTDeserializationListener *DeserializationListener = nullptr;
+
bool OwnsDeserializationListener = false;
SourceManager &SourceMgr;
@@ -436,7 +472,8 @@ private:
/// \brief A map of negated SLocEntryIDs to the modules containing them.
ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap;
- typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType;
+ using GlobalSLocOffsetMapType =
+ ContinuousRangeMap<unsigned, ModuleFile *, 64>;
/// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
/// SourceLocation offsets to the modules containing them.
@@ -448,8 +485,8 @@ private:
/// ID = (I + 1) << FastQual::Width has already been loaded
std::vector<QualType> TypesLoaded;
- typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>
- GlobalTypeMapType;
+ using GlobalTypeMapType =
+ ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>;
/// \brief Mapping from global type IDs to the module in which the
/// type resides along with the offset that should be added to the
@@ -462,17 +499,17 @@ private:
/// = I + 1 has already been loaded.
std::vector<Decl *> DeclsLoaded;
- typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>
- GlobalDeclMapType;
+ using GlobalDeclMapType =
+ ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>;
/// \brief Mapping from global declaration IDs to the module in which the
/// declaration resides.
GlobalDeclMapType GlobalDeclMap;
- typedef std::pair<ModuleFile *, uint64_t> FileOffset;
- typedef SmallVector<FileOffset, 2> FileOffsetsTy;
- typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
- DeclUpdateOffsetsMap;
+ using FileOffset = std::pair<ModuleFile *, uint64_t>;
+ using FileOffsetsTy = SmallVector<FileOffset, 2>;
+ using DeclUpdateOffsetsMap =
+ llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
/// \brief Declarations that have modifications residing in a later file
/// in the chain.
@@ -481,12 +518,15 @@ private:
struct PendingUpdateRecord {
Decl *D;
serialization::GlobalDeclID ID;
+
// Whether the declaration was just deserialized.
bool JustLoaded;
+
PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
bool JustLoaded)
: D(D), ID(ID), JustLoaded(JustLoaded) {}
};
+
/// \brief Declaration updates for already-loaded declarations that we need
/// to apply once we finish processing an import.
llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords;
@@ -505,7 +545,7 @@ private:
/// \brief Declarations that have been imported and have typedef names for
/// linkage purposes.
- llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
+ llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *>
ImportedTypedefNamesForLinkage;
/// \brief Mergeable declaration contexts that have anonymous declarations
@@ -514,10 +554,10 @@ private:
AnonymousDeclarationsForMerging;
struct FileDeclsInfo {
- ModuleFile *Mod;
+ ModuleFile *Mod = nullptr;
ArrayRef<serialization::LocalDeclID> Decls;
- FileDeclsInfo() : Mod(nullptr) {}
+ FileDeclsInfo() = default;
FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
: Mod(Mod), Decls(Decls) {}
};
@@ -527,7 +567,7 @@ private:
/// \brief An array of lexical contents of a declaration context, as a sequence of
/// Decl::Kind, DeclID pairs.
- typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
+ using LexicalContents = ArrayRef<llvm::support::unaligned_uint32_t>;
/// \brief Map from a DeclContext to its lexical contents.
llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
@@ -548,7 +588,7 @@ private:
ModuleFile *Mod;
const unsigned char *Data;
};
- typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
+ using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
/// \brief Updates to the visible declarations of declaration contexts that
/// haven't been loaded yet.
@@ -559,22 +599,23 @@ private:
/// declarations that have not yet been linked to their definitions.
llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
- typedef llvm::MapVector<Decl *, uint64_t,
- llvm::SmallDenseMap<Decl *, unsigned, 4>,
- SmallVector<std::pair<Decl *, uint64_t>, 4> >
- PendingBodiesMap;
+ using PendingBodiesMap =
+ llvm::MapVector<Decl *, uint64_t,
+ llvm::SmallDenseMap<Decl *, unsigned, 4>,
+ SmallVector<std::pair<Decl *, uint64_t>, 4>>;
/// \brief Functions or methods that have bodies that will be attached.
PendingBodiesMap PendingBodies;
/// \brief Definitions for which we have added merged definitions but not yet
/// performed deduplication.
- llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
+ llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
/// \brief Read the record that describes the lexical contents of a DC.
bool ReadLexicalDeclContextStorage(ModuleFile &M,
llvm::BitstreamCursor &Cursor,
uint64_t Offset, DeclContext *DC);
+
/// \brief Read the record that describes the visible contents of a DC.
bool ReadVisibleDeclContextStorage(ModuleFile &M,
llvm::BitstreamCursor &Cursor,
@@ -588,8 +629,8 @@ private:
/// been loaded.
std::vector<IdentifierInfo *> IdentifiersLoaded;
- typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
- GlobalIdentifierMapType;
+ using GlobalIdentifierMapType =
+ ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>;
/// \brief Mapping from global identifier IDs to the module in which the
/// identifier resides along with the offset that should be added to the
@@ -604,16 +645,16 @@ private:
/// been loaded.
std::vector<MacroInfo *> MacrosLoaded;
- typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
- LoadedMacroInfo;
+ using LoadedMacroInfo =
+ std::pair<IdentifierInfo *, serialization::SubmoduleID>;
/// \brief A set of #undef directives that we have loaded; used to
/// deduplicate the same #undef information coming from multiple module
/// files.
llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
- typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
- GlobalMacroMapType;
+ using GlobalMacroMapType =
+ ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;
/// \brief Mapping from global macro IDs to the module in which the
/// macro resides along with the offset that should be added to the
@@ -626,8 +667,8 @@ private:
/// indicate that the particular submodule ID has not yet been loaded.
SmallVector<Module *, 2> SubmodulesLoaded;
- typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
- GlobalSubmoduleMapType;
+ using GlobalSubmoduleMapType =
+ ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>;
/// \brief Mapping from global submodule IDs to the module file in which the
/// submodule resides along with the offset that should be added to the
@@ -635,14 +676,13 @@ private:
GlobalSubmoduleMapType GlobalSubmoduleMap;
/// \brief A set of hidden declarations.
- typedef SmallVector<Decl*, 2> HiddenNames;
- typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
+ using HiddenNames = SmallVector<Decl *, 2>;
+ using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
/// \brief A mapping from each of the hidden submodules to the deserialized
/// declarations in that submodule that could be made visible.
HiddenNamesMapType HiddenNamesMap;
-
/// \brief A module import, export, or conflict that hasn't yet been resolved.
struct UnresolvedModuleRef {
/// \brief The file in which this module resides.
@@ -675,11 +715,10 @@ private:
/// been loaded.
SmallVector<Selector, 16> SelectorsLoaded;
- typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
- GlobalSelectorMapType;
+ using GlobalSelectorMapType =
+ ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>;
/// \brief Mapping from global selector IDs to the module in which the
-
/// global selector ID to produce a local ID.
GlobalSelectorMapType GlobalSelectorMap;
@@ -699,15 +738,15 @@ private:
: M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
};
- typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
- PendingMacroIDsMap;
+ using PendingMacroIDsMap =
+ llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
/// \brief Mapping from identifiers that have a macro history to the global
/// IDs have not yet been deserialized to the global IDs of those macros.
PendingMacroIDsMap PendingMacroIDs;
- typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
- GlobalPreprocessedEntityMapType;
+ using GlobalPreprocessedEntityMapType =
+ ContinuousRangeMap<unsigned, ModuleFile *, 4>;
/// \brief Mapping from global preprocessing entity IDs to the module in
/// which the preprocessed entity resides along with the offset that should be
@@ -895,7 +934,8 @@ private:
///\brief Whether we are currently processing update records.
bool ProcessingUpdateRecords = false;
- typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
+ using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
+
/// \brief Mapping from switch-case IDs in the chain to switch-case statements
///
/// Statements usually don't have IDs, but switch cases need them, so that the
@@ -979,7 +1019,7 @@ private:
///
/// The declarations on the identifier chain for these identifiers will be
/// loaded once the recursive loading has completed.
- llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
+ llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
PendingIdentifierInfos;
/// \brief The set of lookup results that we have faked in order to support
@@ -998,7 +1038,9 @@ private:
public:
InterestingDecl(Decl *D, bool HasBody)
: D(D), DeclHasPendingBody(HasBody) {}
+
Decl *getDecl() { return D; }
+
/// Whether the declaration has a pending body.
bool hasPendingBody() { return DeclHasPendingBody; }
};
@@ -1062,8 +1104,8 @@ private:
/// module is loaded.
SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
- typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
- KeyDeclsMap;
+ using KeyDeclsMap =
+ llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
/// \brief A mapping from canonical declarations to the set of global
/// declaration IDs for key declaration that have been merged with that
@@ -1097,15 +1139,14 @@ private:
ASTReader &Reader;
enum ReadingKind PrevKind;
- ReadingKindTracker(const ReadingKindTracker &) = delete;
- void operator=(const ReadingKindTracker &) = delete;
-
public:
ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
: Reader(reader), PrevKind(Reader.ReadingKind) {
Reader.ReadingKind = newKind;
}
+ ReadingKindTracker(const ReadingKindTracker &) = delete;
+ ReadingKindTracker &operator=(const ReadingKindTracker &) = delete;
~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
};
@@ -1114,15 +1155,15 @@ private:
ASTReader &Reader;
bool PrevState;
- ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
- void operator=(const ProcessingUpdatesRAIIObj &) = delete;
-
public:
ProcessingUpdatesRAIIObj(ASTReader &reader)
: Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
Reader.ProcessingUpdateRecords = true;
}
+ ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
+ ProcessingUpdatesRAIIObj &
+ operator=(const ProcessingUpdatesRAIIObj &) = delete;
~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
};
@@ -1205,7 +1246,7 @@ private:
ImportedModule(ModuleFile *Mod,
ModuleFile *ImportedBy,
SourceLocation ImportLoc)
- : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
+ : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
};
ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
@@ -1266,10 +1307,11 @@ private:
std::string &SuggestedPredefines);
struct RecordLocation {
- RecordLocation(ModuleFile *M, uint64_t O)
- : F(M), Offset(O) {}
ModuleFile *F;
uint64_t Offset;
+
+ RecordLocation(ModuleFile *M, uint64_t O)
+ : F(M), Offset(O) {}
};
QualType readTypeRecord(unsigned Index);
@@ -1328,12 +1370,11 @@ public:
ModuleDeclIterator, const serialization::LocalDeclID *,
std::random_access_iterator_tag, const Decl *, ptrdiff_t,
const Decl *, const Decl *> {
- ASTReader *Reader;
- ModuleFile *Mod;
+ ASTReader *Reader = nullptr;
+ ModuleFile *Mod = nullptr;
public:
- ModuleDeclIterator()
- : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
+ ModuleDeclIterator() : iterator_adaptor_base(nullptr) {}
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod,
const serialization::LocalDeclID *Pos)
@@ -1342,6 +1383,7 @@ public:
value_type operator*() const {
return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
}
+
value_type operator->() const { return **this; }
bool operator==(const ModuleDeclIterator &RHS) const {
@@ -1378,8 +1420,6 @@ private:
void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
StringRef Arg2 = StringRef()) const;
- ASTReader(const ASTReader &) = delete;
- void operator=(const ASTReader &) = delete;
public:
/// \brief Load the AST file and validate its contents against the given
/// Preprocessor.
@@ -1428,7 +1468,8 @@ public:
bool AllowConfigurationMismatch = false,
bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
std::unique_ptr<llvm::Timer> ReadTimer = {});
-
+ ASTReader(const ASTReader &) = delete;
+ ASTReader &operator=(const ASTReader &) = delete;
~ASTReader() override;
SourceManager &getSourceManager() const { return SourceMgr; }
@@ -1443,15 +1484,19 @@ public:
enum LoadFailureCapabilities {
/// \brief The client can't handle any AST loading failures.
ARR_None = 0,
+
/// \brief The client can handle an AST file that cannot load because it
/// is missing.
ARR_Missing = 0x1,
+
/// \brief The client can handle an AST file that cannot load because it
/// is out-of-date relative to its input files.
ARR_OutOfDate = 0x2,
+
/// \brief The client can handle an AST file that cannot load because it
/// was built with a different version of Clang.
ARR_VersionMismatch = 0x4,
+
/// \brief The client can handle an AST file that cannot load because it's
/// compiled configuration doesn't match that of the context it was
/// loaded into.
@@ -1522,11 +1567,11 @@ public:
/// RAII object to temporarily add an AST callback listener.
class ListenerScope {
ASTReader &Reader;
- bool Chained;
+ bool Chained = false;
public:
ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
- : Reader(Reader), Chained(false) {
+ : Reader(Reader) {
auto Old = Reader.takeListener();
if (Old) {
Chained = true;
@@ -1535,6 +1580,7 @@ public:
}
Reader.setListener(std::move(L));
}
+
~ListenerScope() {
auto New = Reader.takeListener();
if (Chained)
@@ -1933,16 +1979,16 @@ public:
llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override;
void ReadReferencedSelectors(
- SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override;
+ SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override;
void ReadWeakUndeclaredIdentifiers(
- SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override;
+ SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WI) override;
void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
void ReadPendingInstantiations(
- SmallVectorImpl<std::pair<ValueDecl *,
- SourceLocation> > &Pending) override;
+ SmallVectorImpl<std::pair<ValueDecl *,
+ SourceLocation>> &Pending) override;
void ReadLateParsedTemplates(
llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
@@ -2275,20 +2321,19 @@ public:
/// \brief An object for streaming information from a record.
class ASTRecordReader {
- typedef serialization::ModuleFile ModuleFile;
+ using ModuleFile = serialization::ModuleFile;
ASTReader *Reader;
ModuleFile *F;
unsigned Idx = 0;
ASTReader::RecordData Record;
- typedef ASTReader::RecordData RecordData;
- typedef ASTReader::RecordDataImpl RecordDataImpl;
+ using RecordData = ASTReader::RecordData;
+ using RecordDataImpl = ASTReader::RecordDataImpl;
public:
/// Construct an ASTRecordReader that uses the default encoding scheme.
- ASTRecordReader(ASTReader &Reader, ModuleFile &F)
- : Reader(&Reader), F(&F) {}
+ ASTRecordReader(ASTReader &Reader, ModuleFile &F) : Reader(&Reader), F(&F) {}
/// \brief Reads a record with id AbbrevID from Cursor, resetting the
/// internal state.
@@ -2302,17 +2347,20 @@ public:
/// \brief The current position in this record.
unsigned getIdx() const { return Idx; }
+
/// \brief The length of this record.
size_t size() const { return Record.size(); }
/// \brief An arbitrary index in this record.
const uint64_t &operator[](size_t N) { return Record[N]; }
+
/// \brief The last element in this record.
const uint64_t &back() const { return Record.back(); }
/// \brief Returns the current value in this record, and advances to the
/// next value.
const uint64_t &readInt() { return Record[Idx++]; }
+
/// \brief Returns the current value in this record, without advancing.
const uint64_t &peekInt() { return Record[Idx]; }
@@ -2566,7 +2614,7 @@ public:
/// then restores it when destroyed.
struct SavedStreamPosition {
explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
- : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
+ : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
~SavedStreamPosition() {
Cursor.JumpToBit(Offset);
@@ -2581,6 +2629,6 @@ inline void PCHValidator::Error(const char *Msg) {
Reader.Error(Msg);
}
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h
index 244b01b22a..24bfadd0f8 100644
--- a/include/clang/Serialization/ContinuousRangeMap.h
+++ b/include/clang/Serialization/ContinuousRangeMap.h
@@ -1,4 +1,4 @@
-//===--- ContinuousRangeMap.h - Map with int range as key -------*- C++ -*-===//
+//===- ContinuousRangeMap.h - Map with int range as key ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,6 +18,7 @@
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallVector.h"
#include <algorithm>
+#include <cassert>
#include <utility>
namespace clang {
@@ -35,14 +36,15 @@ namespace clang {
template <typename Int, typename V, unsigned InitialCapacity>
class ContinuousRangeMap {
public:
- typedef std::pair<Int, V> value_type;
- typedef value_type &reference;
- typedef const value_type &const_reference;
- typedef value_type *pointer;
- typedef const value_type *const_pointer;
+ using value_type = std::pair<Int, V>;
+ using reference = value_type &;
+ using const_reference = const value_type &;
+ using pointer = value_type *;
+ using const_pointer = const value_type *;
private:
- typedef SmallVector<value_type, InitialCapacity> Representation;
+ using Representation = SmallVector<value_type, InitialCapacity>;
+
Representation Rep;
struct Compare {
@@ -52,7 +54,7 @@ private:
bool operator ()(Int L, const_reference R) const {
return L < R.first;
}
- bool operator ()(Int L, Int R) const {
+ bool operator ()(Int L, Int R) const {
return L < R;
}
bool operator ()(const_reference L, const_reference R) const {
@@ -80,8 +82,8 @@ public:
Rep.insert(I, Val);
}
- typedef typename Representation::iterator iterator;
- typedef typename Representation::const_iterator const_iterator;
+ using iterator = typename Representation::iterator;
+ using const_iterator = typename Representation::const_iterator;
iterator begin() { return Rep.begin(); }
iterator end() { return Rep.end(); }
@@ -108,13 +110,12 @@ public:
/// from a set of values.
class Builder {
ContinuousRangeMap &Self;
-
+
+ public:
+ explicit Builder(ContinuousRangeMap &Self) : Self(Self) {}
Builder(const Builder&) = delete;
Builder &operator=(const Builder&) = delete;
- public:
- explicit Builder(ContinuousRangeMap &Self) : Self(Self) { }
-
~Builder() {
std::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
std::unique(Self.Rep.begin(), Self.Rep.end(),
@@ -131,9 +132,10 @@ public:
Self.Rep.push_back(Val);
}
};
+
friend class Builder;
};
-}
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_CONTINUOUSRANGEMAP_H