[cfe-commits] r83512 - /cfe/trunk/include/clang/AST/DeclTemplate.h
Douglas Gregor
dgregor at apple.com
Wed Oct 7 17:19:07 PDT 2009
Author: dgregor
Date: Wed Oct 7 19:19:07 2009
New Revision: 83512
URL: http://llvm.org/viewvc/llvm-project?rev=83512&view=rev
Log:
Compress storage for MemberSpecializationInfo into a single
pointer. Yay, PointerIntPair.
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=83512&r1=83511&r2=83512&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Wed Oct 7 19:19:07 2009
@@ -552,26 +552,32 @@
/// 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);
}
};
More information about the cfe-commits
mailing list