From fa2263b3097c4e5f361505ce564a246a7f289172 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 16 May 2025 09:08:16 -0700 Subject: [CIR][NFC] Use arrangeFunctionDeclaration to build function types (#139787) This change replaces the simplified call that we were previously using to convert the function type provided by a global declaration to the CIR function type. We now go through 'arrangeGlobalDeclaration' which builds the function type in a more complicated manner. This change has no observable differences for the currently upstreamed CIR support, but it is necessary to prepare for C++ member function calls, which require the extra handling. --- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp') diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index b4e27bc..bd3aa37 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -249,21 +249,8 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd, return; } - cir::FuncType funcType; - // TODO: Move this to arrangeFunctionDeclaration when it is - // implemented. - // When declaring a function without a prototype, always use a - // non-variadic type. - if (CanQual noProto = - funcDecl->getType() - ->getCanonicalTypeUnqualified() - .getAs()) { - const CIRGenFunctionInfo &fi = getTypes().arrangeCIRFunctionInfo( - noProto->getReturnType(), {}, RequiredArgs::All); - funcType = getTypes().getFunctionType(fi); - } else { - funcType = cast(convertType(funcDecl->getType())); - } + const CIRGenFunctionInfo &fi = getTypes().arrangeGlobalDeclaration(gd); + cir::FuncType funcType = getTypes().getFunctionType(fi); cir::FuncOp funcOp = dyn_cast_if_present(op); if (!funcOp || funcOp.getFunctionType() != funcType) { -- cgit v1.1