diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp index adf0ca1a1fe93..e3fe3ca1c30c9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp @@ -42,17 +42,17 @@ CIRGenFunctionInfo::create(CanQualType resultType, return fi; } -cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &fi) { - mlir::Type resultType = convertType(fi.getReturnType()); +cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &info) { + mlir::Type resultType = convertType(info.getReturnType()); SmallVector argTypes; - argTypes.reserve(fi.getNumRequiredArgs()); + argTypes.reserve(info.getNumRequiredArgs()); - for (const CanQualType &argType : fi.requiredArguments()) + for (const CanQualType &argType : info.requiredArguments()) argTypes.push_back(convertType(argType)); return cir::FuncType::get(argTypes, (resultType ? resultType : builder.getVoidTy()), - fi.isVariadic()); + info.isVariadic()); } CIRGenCallee CIRGenCallee::prepareConcreteCallee(CIRGenFunction &cgf) const { diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index c437b14dd8d1c..d8f7ba5c79cc6 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -1169,7 +1169,8 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf, ->getBaseElementTypeUnsafe() ->getAs()) { // Get the destructor for the reference temporary. - auto *classDecl = cast(rt->getOriginalDecl()); + auto *classDecl = + cast(rt->getOriginalDecl()->getDefinitionOrSelf()); if (!classDecl->hasTrivialDestructor()) referenceTemporaryDtor = classDecl->getDefinitionOrSelf()->getDestructor(); diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 03555a52f1252..8a3f5ab78ab59 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -356,8 +356,8 @@ static bool mayDropFunctionReturn(const ASTContext &astContext, // destructor or a non-trivially copyable type. if (const RecordType *recordType = returnType.getCanonicalType()->getAs()) { - if (const auto *classDecl = - dyn_cast(recordType->getOriginalDecl())) + if (const auto *classDecl = dyn_cast( + recordType->getOriginalDecl()->getDefinitionOrSelf())) return classDecl->hasTrivialDestructor(); } return returnType.isTriviallyCopyableType(astContext); diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index 2084b6d9e8989..0084519154e2a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -139,6 +139,8 @@ isSafeToConvert(const RecordDecl *rd, CIRGenTypes &cgt, if (!alreadyChecked.insert(rd).second) return true; + assert(rd->isCompleteDefinition() && + "Expect RecordDecl to be CompleteDefinition"); const Type *key = cgt.getASTContext().getCanonicalTagType(rd).getTypePtr(); // If this type is already laid out, converting it is a noop. diff --git a/clang/lib/CIR/CodeGen/TargetInfo.cpp b/clang/lib/CIR/CodeGen/TargetInfo.cpp index 1447dba87db7e..7b6259b04122d 100644 --- a/clang/lib/CIR/CodeGen/TargetInfo.cpp +++ b/clang/lib/CIR/CodeGen/TargetInfo.cpp @@ -17,13 +17,13 @@ bool clang::CIRGen::isEmptyRecordForLayout(const ASTContext &context, if (cxxrd->isDynamicClass()) return false; - for (const auto &I : cxxrd->bases()) - if (!isEmptyRecordForLayout(context, I.getType())) + for (const auto &i : cxxrd->bases()) + if (!isEmptyRecordForLayout(context, i.getType())) return false; } - for (const auto *I : rd->fields()) - if (!isEmptyFieldForLayout(context, I)) + for (const auto *i : rd->fields()) + if (!isEmptyFieldForLayout(context, i)) return false; return true;