================ @@ -23,6 +23,55 @@ namespace clang { +inline CXXRecordDecl *Type::getAsCXXRecordDecl() const { + const auto *TT = dyn_cast<TagType>(CanonicalType); + if (!isa_and_present<RecordType, InjectedClassNameType>(TT)) + return nullptr; + auto *TD = TT->getOriginalDecl(); + if (!isa<InjectedClassNameType>(TT) && !isa<CXXRecordDecl>(TD)) + return nullptr; ---------------- Sirraide wrote:
> Yeah, from my experience experimenting for the previous patch, touching the > type Kind field is almost free, but doing the indirection to the decl Kind > field can be expensive. For example, we could have gotten rid of EnumType, > RecordType and InjectedClassNameType as a simplification, as these types are > basically the same in all ways except the kinds of declarations they store. > > So we could have kept just TagType. Except that whenever you need to test you > have a record, having a different TypeClass allows you to quickly bail out > without having to touch the declaration, otherwise you get a a performance > regression. I see; I figured it might be something like that. https://github.com/llvm/llvm-project/pull/155051 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits