diff options
| author | Matheus Izvekov <mizvekov@gmail.com> | 2025-08-25 20:18:56 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-25 20:18:56 -0300 |
| commit | dc8596d5485a52abee2967cec72f81ef4872270c (patch) | |
| tree | 5d0b5cbc1fed95f3b9aae2b39387c0f2b4d0e47c /clang/lib/CodeGen/CGExprAgg.cpp | |
| parent | 1ba8b36fef84bedb0a657b570076ec1a47e9061d (diff) | |
| download | llvm-dc8596d5485a52abee2967cec72f81ef4872270c.zip llvm-dc8596d5485a52abee2967cec72f81ef4872270c.tar.gz llvm-dc8596d5485a52abee2967cec72f81ef4872270c.tar.bz2 | |
[clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313)
This changes a bunch of places which use getAs<TagType>, 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.
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 04e125c..ed90e98 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -268,11 +268,11 @@ void AggExprEmitter::EmitAggLoadOfLValue(const Expr *E) { /// True if the given aggregate type requires special GC API calls. bool AggExprEmitter::TypeRequiresGCollection(QualType T) { // Only record types have members that might require garbage collection. - const RecordType *RecordTy = T->getAs<RecordType>(); - if (!RecordTy) return false; + const auto *Record = T->getAsRecordDecl(); + if (!Record) + return false; // Don't mess with non-trivial C++ types. - RecordDecl *Record = RecordTy->getOriginalDecl()->getDefinitionOrSelf(); if (isa<CXXRecordDecl>(Record) && (cast<CXXRecordDecl>(Record)->hasNonTrivialCopyConstructor() || !cast<CXXRecordDecl>(Record)->hasTrivialDestructor())) @@ -2294,9 +2294,7 @@ void CodeGenFunction::EmitAggregateCopy(LValue Dest, LValue Src, QualType Ty, Address SrcPtr = Src.getAddress(); if (getLangOpts().CPlusPlus) { - if (const RecordType *RT = Ty->getAs<RecordType>()) { - auto *Record = - cast<CXXRecordDecl>(RT->getOriginalDecl())->getDefinitionOrSelf(); + if (const auto *Record = Ty->getAsCXXRecordDecl()) { assert((Record->hasTrivialCopyConstructor() || Record->hasTrivialCopyAssignment() || Record->hasTrivialMoveConstructor() || @@ -2379,8 +2377,7 @@ void CodeGenFunction::EmitAggregateCopy(LValue Dest, LValue Src, QualType Ty, // Don't do any of the memmove_collectable tests if GC isn't set. if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { // fall through - } else if (const RecordType *RecordTy = Ty->getAs<RecordType>()) { - RecordDecl *Record = RecordTy->getOriginalDecl()->getDefinitionOrSelf(); + } else if (const auto *Record = Ty->getAsRecordDecl()) { if (Record->hasObjectMember()) { CGM.getObjCRuntime().EmitGCMemmoveCollectable(*this, DestPtr, SrcPtr, SizeVal); @@ -2388,10 +2385,8 @@ void CodeGenFunction::EmitAggregateCopy(LValue Dest, LValue Src, QualType Ty, } } else if (Ty->isArrayType()) { QualType BaseType = getContext().getBaseElementType(Ty); - if (const RecordType *RecordTy = BaseType->getAs<RecordType>()) { - if (RecordTy->getOriginalDecl() - ->getDefinitionOrSelf() - ->hasObjectMember()) { + if (const auto *Record = BaseType->getAsRecordDecl()) { + if (Record->hasObjectMember()) { CGM.getObjCRuntime().EmitGCMemmoveCollectable(*this, DestPtr, SrcPtr, SizeVal); return; |
