Code refactoring to define getCXXRecordDeclForPointerType
and use it in several places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77411 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index c27df1f..04961ed 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -523,6 +523,13 @@
return dyn_cast<TemplateTypeParmType>(CanonicalType);
}
+const CXXRecordDecl *Type::getCXXRecordDeclForPointerType() const {
+ if (const PointerType *PT = getAsPointerType())
+ if (const RecordType *RT = PT->getPointeeType()->getAsRecordType())
+ return dyn_cast<CXXRecordDecl>(RT->getDecl());
+ return 0;
+}
+
const TemplateSpecializationType *
Type::getAsTemplateSpecializationType() const {
// There is no sugar for class template specialization types, so