]> granicus.if.org Git - clang/commitdiff
Waste two bits in every clang::Type so that the type class can be read
authorJohn McCall <rjmccall@apple.com>
Fri, 12 Feb 2010 03:41:30 +0000 (03:41 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 12 Feb 2010 03:41:30 +0000 (03:41 +0000)
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

include/clang/AST/Type.h
include/clang/AST/TypeNodes.def
lib/Sema/Sema.h

index 47b7d4811c07777b91bb36ba74303530c2a41b0d..04dc99eda2d0d55281775f92ca122f72fe74e713 100644 (file)
@@ -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;
index 575011a8724c824d3d318a18a7cc5047763ae7b4..9cf2cb7bd7730ec17a256170c84bb36c5b3832d2 100644 (file)
@@ -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)
index 0ee16cae95107291d6c786081449caca8c98524c..5ee790cefed6fde6066853285da2d0de021fb3f1 100644 (file)
@@ -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;