[clang] [Clang][Sema][Builtins] Check argument count for `__builtin_allow_sanitize_check` (PR #183927)
Thibault Monnier via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 5 13:46:02 PST 2026
================
@@ -3816,6 +3804,9 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
}
case Builtin::BI__builtin_allow_sanitize_check: {
+ if (checkArgCount(TheCall, 1))
----------------
Thibault-Monnier wrote:
I've been trying to work on this. Many builtins have variadic signatures: is there any way to make the arg count check also work on these?
I wrote a check that looks like this:
```cpp
if (FPT->isVariadic() ? checkArgCountAtLeast(TheCall, NumParams)
: checkArgCount(TheCall, NumParams))
```
However, this is messy because all builtins using a variadic signature must implement an additional check later on, and the variadic check straight up doesn't work in C mode (where variadic signatures are `FunctionNoProtoType` instead of `FunctionProtoType`).
To make things worse, the `_setjmp` builtin is usually defined as `int(jmp_buf)`, but in MinGW there is an extra parameter which breaks with this change. There's a `FIXME` about this issue (see [here](https://github.com/llvm/llvm-project/blob/a82e3a19258da70aecd0177a2c4b854a659b153f/clang/include/clang/Basic/Builtins.td?plain=1#L3442)).
https://github.com/llvm/llvm-project/pull/183927
More information about the cfe-commits
mailing list