[clang] [clang] Fix crash on no-prototype indirect calls with -fexperimental-call-graph-section (PR #210846)
Prabhu Rajasekaran via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 21 10:51:58 PDT 2026
Prabhuk wrote:
> Why? Clang still supports K&R C functions, so this seems wrong at least in some language modes (it makes sense in C++ or C23 and later).
Thanks for the question @AaronBallman. This is my thinking behind this change.
Though Clang supports K&R C functions without prototypes, the -fexperimental-call-graph-section feature requires us to emit a concrete, mangled type ID of the "target" function for every call site.
When we encounter an indirect call to a no-prototype function, we don't have a concrete signature to derive this type ID from.
So, I am falling back to generating the metadata as if it were a zero-parameter function (e.g., _ZTSFvE in Itanium).
Since this fallback causes a possible loss of accuracy/precision and means the call site's type ID might not match the actual target's type ID, I am emitting a specific warning.
If this was an oversight by the developer to not declare the arg list as "(void)" they can correct it.
But for the general case, I do not know how to generate the precise "target" type ID without prototype though this is something I would like to address in the future.
Currently, these cases crash when `-fexperimental-call-grah-section` flag is set which make this feature unusable due to this corner case.
https://github.com/llvm/llvm-project/pull/210846
More information about the cfe-commits
mailing list