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/CIR/CodeGen/CIRGenFunction.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/CIR/CodeGen/CIRGenFunction.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenFunction.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 706c14a..deabb94 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -356,12 +356,8 @@ static bool mayDropFunctionReturn(const ASTContext &astContext, QualType returnType) { // We can't just discard the return value for a record type with a complex // destructor or a non-trivially copyable type. - if (const RecordType *recordType = - returnType.getCanonicalType()->getAs<RecordType>()) { - if (const auto *classDecl = dyn_cast<CXXRecordDecl>( - recordType->getOriginalDecl()->getDefinitionOrSelf())) - return classDecl->hasTrivialDestructor(); - } + if (const auto *classDecl = returnType->getAsCXXRecordDecl()) + return classDecl->hasTrivialDestructor(); return returnType.isTriviallyCopyableType(astContext); } @@ -829,14 +825,9 @@ std::string CIRGenFunction::getCounterAggTmpAsString() { void CIRGenFunction::emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty) { // Ignore empty classes in C++. - if (getLangOpts().CPlusPlus) { - if (const RecordType *rt = ty->getAs<RecordType>()) { - if (cast<CXXRecordDecl>(rt->getOriginalDecl()) - ->getDefinitionOrSelf() - ->isEmpty()) - return; - } - } + if (getLangOpts().CPlusPlus) + if (const auto *rd = ty->getAsCXXRecordDecl(); rd && rd->isEmpty()) + return; // Cast the dest ptr to the appropriate i8 pointer type. if (builder.isInt8Ty(destPtr.getElementType())) { |