From: John McCall Date: Fri, 12 Feb 2010 03:41:30 +0000 (+0000) Subject: Waste two bits in every clang::Type so that the type class can be read X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27935ee59c30b0d8b610ab676aab8e65350af932;p=clang Waste two bits in every clang::Type so that the type class can be read in a single byte-load rather than some crazy bitmunging operation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95964 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 47b7d4811c..04dc99eda2 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -751,24 +751,22 @@ class Type { public: enum TypeClass { #define TYPE(Class, Base) Class, +#define LAST_TYPE(Class) TypeLast = Class, #define ABSTRACT_TYPE(Class, Base) #include "clang/AST/TypeNodes.def" TagFirst = Record, TagLast = Enum }; -protected: - enum { TypeClassBitSize = 6 }; - private: QualType CanonicalType; - /// Dependent - Whether this type is a dependent type (C++ [temp.dep.type]). - bool Dependent : 1; - /// TypeClass bitfield - Enum that specifies what subclass this belongs to. + unsigned TC : 8; + + /// Dependent - Whether this type is a dependent type (C++ [temp.dep.type]). /// Note that this should stay at the end of the ivars for Type so that /// subclasses can pack their bitfields into the same word. - unsigned TC : TypeClassBitSize; + bool Dependent : 1; Type(const Type&); // DO NOT IMPLEMENT. void operator=(const Type&); // DO NOT IMPLEMENT. @@ -777,7 +775,7 @@ protected: Type *this_() { return this; } Type(TypeClass tc, QualType Canonical, bool dependent) : CanonicalType(Canonical.isNull() ? QualType(this_(), 0) : Canonical), - Dependent(dependent), TC(tc) {} + TC(tc), Dependent(dependent) {} virtual ~Type() {} virtual void Destroy(ASTContext& C); friend class ASTContext; diff --git a/include/clang/AST/TypeNodes.def b/include/clang/AST/TypeNodes.def index 575011a872..9cf2cb7bd7 100644 --- a/include/clang/AST/TypeNodes.def +++ b/include/clang/AST/TypeNodes.def @@ -87,6 +87,11 @@ DEPENDENT_TYPE(Typename, Type) TYPE(ObjCInterface, Type) TYPE(ObjCObjectPointer, Type) +#ifdef LAST_TYPE +LAST_TYPE(ObjCObjectPointer) +#undef LAST_TYPE +#endif + // These types are always leaves in the type hierarchy. #ifdef LEAF_TYPE LEAF_TYPE(Enum) diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 0ee16cae95..5ee790cefe 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -153,7 +153,7 @@ class LocInfoType : public Type { enum { // The last number that can fit in Type's TC. // Avoids conflict with an existing Type class. - LocInfo = (1 << TypeClassBitSize) - 1 + LocInfo = Type::TypeLast + 1 }; TypeSourceInfo *DeclInfo;