From: Douglas Gregor Date: Thu, 8 Oct 2009 00:19:07 +0000 (+0000) Subject: Compress storage for MemberSpecializationInfo into a single X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44e368b6a85c42d681148ccd5e0052418ff9751e;p=clang Compress storage for MemberSpecializationInfo into a single pointer. Yay, PointerIntPair. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83512 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 3f6f782c29..f49aeccb46 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -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 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); } };