[clang] [CIR] Add proper handling for no prototype function calls (PR #150553)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 25 08:56:00 PDT 2025
================
@@ -1729,6 +1783,34 @@ cir::FuncOp CIRGenModule::getOrCreateCIRFunction(
invalidLoc ? theModule->getLoc() : getLoc(funcDecl->getSourceRange()),
mangledName, mlir::cast<cir::FuncType>(funcType), funcDecl);
+ // If we already created a function with the same mangled name (but different
+ // type) before, take its name and add it to the list of functions to be
+ // replaced with F at the end of CodeGen.
+ //
+ // This happens if there is a prototype for a function (e.g. "int f()") and
+ // then a definition of a different type (e.g. "int f(int x)").
+ if (entry) {
+
+ // Fetch a generic symbol-defining operation and its uses.
+ auto symbolOp = mlir::cast<mlir::SymbolOpInterface>(entry);
+
+ // TODO(cir): When can this symbol be something other than a function?
+ if (!isa<cir::FuncOp>(entry))
+ errorNYI(d->getSourceRange(), "getOrCreateCIRFunction: non-FuncOp");
----------------
Lancern wrote:
Is this branch ever possible?
https://github.com/llvm/llvm-project/pull/150553
More information about the cfe-commits
mailing list