[clang] Suppress -Wuninitialized for unevaluated builtin args (#217816)
CFGBuilder leaves the arguments of `__builtin_object_size` and
`__builtin_dynamic_object_size` out of the CFG because they are never
evaluated. Use `CallExpr::isUnevaluatedBuiltinCall` instead, which
checks the
`UnevaluatedArguments` attribute, so the same applies to every builtin
declared
that way. `EvaluatedExprVisitor` and `-Wunsequenced` already use the
same
query.
That adds seven builtins: `__builtin_classify_type`,
`__builtin_constant_p`,
`__builtin_infer_alloc_token`, `__GetExceptionInfo`,
`__builtin_os_log_format_buffer_size`, `__builtin_amdgcn_processor_is`
and
`__builtin_amdgcn_is_invocable`. None of them depends on its arguments'
values.
`__builtin_os_log_format_buffer_size` only sizes the buffer; the paired
`__builtin_os_log_format` call evaluates the arguments.
CodeGen does emit `__builtin_constant_p`'s argument for
`llvm.is.constant`,
but that folds to false for an undefined value: `int x; return
__builtin_constant_p(x);` compiles to `ret i32 0`. GCC 15 warns on this
case
at `-O2` (not at `-O0`), and does not warn for
`__builtin_classify_type`.
This fixes spurious `-Wuninitialized` warnings for
`__builtin_classify_type`,
`__builtin_constant_p`, `__builtin_infer_alloc_token` and
`__builtin_os_log_format_buffer_size`; the new cases in
`uninit-variables.c`
warn without the fix. The two AMDGPU predicates are not tested, since
they
would need an `amdgcn` triple and use the same path.
`clang/test` passes, apart from `Modules/pr166068.cppm`, which fails
without
this change too.
Assisted-by: Claude Code