Make the type associated with a ClassTemplateSpecializationDecl be a
nicely sugared type that shows how the user wrote the actual
specialization. This sugared type won't actually show up until we
start doing instantiations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65577 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 210be03..327e623 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -331,7 +331,7 @@
}
const RecordType *Type::getAsRecordType() const {
- // If this is directly a reference type, return it.
+ // If this is directly a record type, return it.
if (const RecordType *RTy = dyn_cast<RecordType>(this))
return RTy;
@@ -348,6 +348,24 @@
return getDesugaredType()->getAsRecordType();
}
+const TagType *Type::getAsTagType() const {
+ // If this is directly a tag type, return it.
+ if (const TagType *TagTy = dyn_cast<TagType>(this))
+ return TagTy;
+
+ // If the canonical form of this type isn't the right kind, reject it.
+ if (!isa<TagType>(CanonicalType)) {
+ // Look through type qualifiers
+ if (isa<TagType>(CanonicalType.getUnqualifiedType()))
+ return CanonicalType.getUnqualifiedType()->getAsTagType();
+ return 0;
+ }
+
+ // If this is a typedef for a tag type, strip the typedef off without
+ // losing all typedef information.
+ return getDesugaredType()->getAsTagType();
+}
+
const RecordType *Type::getAsStructureType() const {
// If this is directly a structure type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {