aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-29 07:03:59 +0000
committerChris Lattner <sabre@nondot.org>2009-03-29 07:03:59 +0000
commit005f92f53c99ce8e701e44115c94216b108ea021 (patch)
tree742d1ba7aef98c7f2f35bcd2bb29de7b5cb12301
parent5648a8a700d2a0435373da4122d32f8e6fe95656 (diff)
switch TemplateOrInstantiation to be a PointerUnion, which
simplifies some code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67993 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclCXX.h22
-rw-r--r--lib/AST/DeclCXX.cpp18
2 files changed, 13 insertions, 27 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 389ffaec68..5ff6910bb0 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -243,11 +243,10 @@ class CXXRecordDecl : public RecordDecl {
///
/// For non-templates, this value will be NULL. For record
/// declarations that describe a class template, this will be a
- /// pointer to a ClassTemplateDecl (the bit is 0). For member
+ /// pointer to a ClassTemplateDecl. For member
/// classes of class template specializations, this will be the
- /// RecordDecl from which the member class was instantiated (the bit
- /// is 1).
- llvm::PointerIntPair<Decl*, 1> TemplateOrInstantiation;
+ /// RecordDecl from which the member class was instantiated.
+ llvm::PointerUnion<ClassTemplateDecl*, CXXRecordDecl*>TemplateOrInstantiation;
protected:
CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
@@ -395,13 +394,14 @@ public:
/// the CXXRecordDecl X<T>::A. When a complete definition of
/// X<int>::A is required, it will be instantiated from the
/// declaration returned by getInstantiatedFromMemberClass().
- CXXRecordDecl *getInstantiatedFromMemberClass();
+ CXXRecordDecl *getInstantiatedFromMemberClass() {
+ return TemplateOrInstantiation.dyn_cast<CXXRecordDecl*>();
+ }
/// \brief Specify that this record is an instantiation of the
/// member class RD.
void setInstantiationOfMemberClass(CXXRecordDecl *RD) {
- TemplateOrInstantiation.setInt(1);
- TemplateOrInstantiation.setPointer(RD);
+ TemplateOrInstantiation = RD;
}
/// \brief Retrieves the class template that is described by this
@@ -415,9 +415,13 @@ public:
/// CXXRecordDecl that from a ClassTemplateDecl, while
/// getDescribedClassTemplate() retrieves the ClassTemplateDecl from
/// a CXXRecordDecl.
- ClassTemplateDecl *getDescribedClassTemplate();
+ ClassTemplateDecl *getDescribedClassTemplate() {
+ return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl*>();
+ }
- void setDescribedClassTemplate(ClassTemplateDecl *Template);
+ void setDescribedClassTemplate(ClassTemplateDecl *Template) {
+ TemplateOrInstantiation = Template;
+ }
/// viewInheritance - Renders and displays an inheritance diagram
/// for this C++ class and all of its base classes (transitively) using
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 2858d479bb..0fd83efa20 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -179,24 +179,6 @@ void CXXRecordDecl::addConversionFunction(ASTContext &Context,
Conversions.addOverload(ConvDecl);
}
-CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() {
- if (TemplateOrInstantiation.getInt() == 1)
- return cast_or_null<CXXRecordDecl>(TemplateOrInstantiation.getPointer());
- return 0;
-}
-
-void CXXRecordDecl::setDescribedClassTemplate(ClassTemplateDecl *Template) {
- TemplateOrInstantiation.setInt(0);
- TemplateOrInstantiation.setPointer(Template);
-}
-
-ClassTemplateDecl *CXXRecordDecl::getDescribedClassTemplate() {
- if (TemplateOrInstantiation.getInt() == 0)
- return cast_or_null<ClassTemplateDecl>(
- TemplateOrInstantiation.getPointer());
- return 0;
-}
-
CXXMethodDecl *
CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, DeclarationName N,