]> granicus.if.org Git - clang/commitdiff
Compress storage for MemberSpecializationInfo into a single
authorDouglas Gregor <dgregor@apple.com>
Thu, 8 Oct 2009 00:19:07 +0000 (00:19 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 8 Oct 2009 00:19:07 +0000 (00:19 +0000)
pointer. Yay, PointerIntPair.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83512 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclTemplate.h

index 3f6f782c29ecf19b71bd2aeabd73cda915c564c0..f49aeccb46eca76f0d7ca7459f9420011a641a71 100644 (file)
@@ -552,26 +552,32 @@ public:
 /// template, which may be a member function, static data member, or
 /// member class.
 class MemberSpecializationInfo {
-  NamedDecl *InstantiatedFrom;
-  TemplateSpecializationKind TSK;
+  // The member declaration from which this member was instantiated, and the
+  // manner in which the instantiation occurred (in the lower two bits).
+  llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
   
 public:
   explicit 
   MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK)
-    : InstantiatedFrom(IF), TSK(TSK) { }
+    : MemberAndTSK(IF, TSK - 1) {
+    assert(TSK != TSK_Undeclared && 
+           "Cannot encode undeclared template specializations for members");
+  }
   
   /// \brief Retrieve the member declaration from which this member was
   /// instantiated.
-  NamedDecl *getInstantiatedFrom() const { return InstantiatedFrom; }
+  NamedDecl *getInstantiatedFrom() const { return MemberAndTSK.getPointer(); }
   
   /// \brief Determine what kind of template specialization this is.
   TemplateSpecializationKind getTemplateSpecializationKind() const {
-    return TSK;
+    return (TemplateSpecializationKind)(MemberAndTSK.getInt() + 1);
   }
   
   /// \brief Set the template specialization kind.
   void setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
-    this->TSK = TSK;
+    assert(TSK != TSK_Undeclared && 
+           "Cannot encode undeclared template specializations for members");
+    MemberAndTSK.setInt(TSK - 1);
   }
 };