https://github.com/mugiwaraluffy56 updated 
https://github.com/llvm/llvm-project/pull/178656

>From 183e6c6882ffffb79a2d86af93f77b1f719d23ce 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 +++++
 clang-tools-extra/docs/ReleaseNotes.rst                     | 5 +++++
 .../checkers/cppcoreguidelines/pro-type-vararg.cpp          | 6 ++++++
 3 files changed, 16 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/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 754880bd1a381..673ec53e2f7f7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -136,6 +136,11 @@ Changes in existing checks
   the invalidating function in the warning message when a custom invalidation
   function is used (via the `InvalidationFunctions` option).
 
+- Improved :doc:`cppcoreguidelines-pro-type-vararg
+  <clang-tidy/checks/cppcoreguidelines/pro-type-vararg>` check by no longer
+  warning on type-generic builtins (``__builtin_clzg``, ``__builtin_ctzg``,
+  ``__builtin_popcountg``, ``__builtin_bswapg``).
+
 - Improved :doc:`llvm-use-ranges
   <clang-tidy/checks/llvm/use-ranges>` check by adding support for the 
following
   algorithms: ``std::accumulate``, ``std::replace_copy``, and
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

Reply via email to