[cfe-commits] r95964 - in /cfe/trunk: include/clang/AST/Type.h include/clang/AST/TypeNodes.def lib/Sema/Sema.h

John McCall rjmccall at apple.com
Thu Feb 11 19:41:31 PST 2010


Author: rjmccall
Date: Thu Feb 11 21:41:30 2010
New Revision: 95964

URL: http://llvm.org/viewvc/llvm-project?rev=95964&view=rev
Log:
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.


Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/AST/TypeNodes.def
    cfe/trunk/lib/Sema/Sema.h

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=95964&r1=95963&r2=95964&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Feb 11 21:41:30 2010
@@ -751,24 +751,22 @@
 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 @@
   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;

Modified: cfe/trunk/include/clang/AST/TypeNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeNodes.def?rev=95964&r1=95963&r2=95964&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/TypeNodes.def (original)
+++ cfe/trunk/include/clang/AST/TypeNodes.def Thu Feb 11 21:41:30 2010
@@ -87,6 +87,11 @@
 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)

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=95964&r1=95963&r2=95964&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Feb 11 21:41:30 2010
@@ -153,7 +153,7 @@
   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;





More information about the cfe-commits mailing list