diff options
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 18 |
1 files changed, 12 insertions, 6 deletions
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<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); } }; |