Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -2014,6 +2014,9 @@ /// type of a class template or class template partial specialization. CXXRecordDecl *getAsCXXRecordDecl() const; + /// Retrieves the RecordDecl this type refers to. + RecordDecl *getAsRecordDecl() const; + /// Retrieves the TagDecl that this type refers to, either /// because the type is a TagType or because it is the injected-class-name /// type of a class template or class template partial specialization. Index: clang/lib/AST/Type.cpp =================================================================== --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -1622,6 +1622,10 @@ return dyn_cast_or_null(getAsTagDecl()); } +RecordDecl *Type::getAsRecordDecl() const { + return dyn_cast_or_null(getAsTagDecl()); +} + TagDecl *Type::getAsTagDecl() const { if (const auto *TT = getAs()) return TT->getDecl();