https://github.com/mugiwaraluffy56 created https://github.com/llvm/llvm-project/pull/178656
## Summary Add type generic builtins to the allowed variadics list in the `cppcoreguidelines-pro-type-vararg` check (also used by `hicpp-vararg`): - `__builtin_clzg` - `__builtin_ctzg` - `__builtin_popcountg` - `__builtin_bswapg` ## Root Cause These builtins are declared as variadic (`int(...)`) to accept any integer type via `CustomTypeChecking`. However, they are not C style vararg functions , they take exactly one argument of a generic integer type. ## Test Added test cases in `pro-type-vararg.cpp` to verify no warning is emitted. Fixes #17862 >From 3455ca6298e0ce44da5a913997c4e09d47a66cc5 Mon Sep 17 00:00:00 2001 From: mugiwaraluffy56 <[email protected]> Date: Thu, 29 Jan 2026 19:22:00 +0530 Subject: [PATCH] [clang-tidy] Allow type-generic builtins in pro-type-vararg check Add __builtin_clzg, __builtin_ctzg, __builtin_popcountg, and __builtin_bswapg to the allowed variadics list. These type-generic builtins are declared as variadic to accept any integer type, but they are not C-style vararg functions and should not trigger the hicpp-vararg / cppcoreguidelines-pro-type-vararg warning. Fixes #178629 --- .../clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp | 5 +++++ .../checkers/cppcoreguidelines/pro-type-vararg.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp index d5ff4af84b0b7..73cadfdf14614 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp @@ -56,6 +56,11 @@ static constexpr StringRef AllowedVariadics[] = { "__builtin_nontemporal_store", "__builtin_nontemporal_load", "__builtin_ms_va_start", + // Type-generic builtins: declared variadic to accept any integer type. + "__builtin_clzg", + "__builtin_ctzg", + "__builtin_popcountg", + "__builtin_bswapg", // clang-format on }; diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-vararg.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-vararg.cpp index 3f73d1de333f4..1a5a5fb7dd93c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-vararg.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-vararg.cpp @@ -57,6 +57,12 @@ void ignoredBuiltinsTest(void *ptr) { (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f); (void)__builtin_isinf_sign(0.f); (void)__builtin_prefetch(nullptr); + + // GH#178629: Type-generic builtins should not warn. + (void)__builtin_clzg(1u); + (void)__builtin_ctzg(1u); + (void)__builtin_popcountg(1u); + (void)__builtin_bswapg(1u); } // Some implementations of __builtin_va_list and __builtin_ms_va_list desugared _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
