[clang] [CIR] Cleanup support for C functions (PR #136854)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon May 12 09:38:59 PDT 2025
================
@@ -247,8 +248,21 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
"function definition with a non-identifier for a name");
return;
}
- cir::FuncType funcType =
- cast<cir::FuncType>(convertType(funcDecl->getType()));
+
+ 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<FunctionNoProtoType> noProto =
+ funcDecl->getType()
+ ->getCanonicalTypeUnqualified()
+ .getAs<FunctionNoProtoType>()) {
+ const CIRGenFunctionInfo &fi = getTypes().arrangeCIRFunctionInfo(
+ noProto->getReturnType(), {}, RequiredArgs::All);
+ funcType = getTypes().getFunctionType(fi);
+ } else
----------------
andykaylor wrote:
LLVM Coding Standards require braces for the `else` if they are required for the `if`.
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
https://github.com/llvm/llvm-project/pull/136854
More information about the cfe-commits
mailing list