From dc8596d5485a52abee2967cec72f81ef4872270c Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 25 Aug 2025 20:18:56 -0300 Subject: [clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313) This changes a bunch of places which use getAs, including derived types, just to obtain the tag definition. This is preparation for #155028, offloading all the changes that PR used to introduce which don't depend on any new helpers. --- clang/lib/CodeGen/CGClass.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'clang/lib/CodeGen/CGClass.cpp') diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index e9a92ae0f01c..10e4543a6ab2 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -1408,13 +1408,10 @@ FieldHasTrivialDestructorBody(ASTContext &Context, { QualType FieldBaseElementType = Context.getBaseElementType(Field->getType()); - const RecordType *RT = FieldBaseElementType->getAs(); - if (!RT) + auto *FieldClassDecl = FieldBaseElementType->getAsCXXRecordDecl(); + if (!FieldClassDecl) return true; - auto *FieldClassDecl = - cast(RT->getOriginalDecl())->getDefinitionOrSelf(); - // The destructor for an implicit anonymous union member is never invoked. if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion()) return true; @@ -2850,13 +2847,10 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T, Address Derived, if (!getLangOpts().CPlusPlus) return; - auto *ClassTy = T->getAs(); - if (!ClassTy) + const auto *ClassDecl = T->getAsCXXRecordDecl(); + if (!ClassDecl) return; - const auto *ClassDecl = - cast(ClassTy->getOriginalDecl())->getDefinitionOrSelf(); - if (!ClassDecl->isCompleteDefinition() || !ClassDecl->isDynamicClass()) return; -- cgit v1.2.3