llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: puneeth_aditya_5656 (mugiwaraluffy56)

<details>
<summary>Changes</summary>

## 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

---
Full diff: https://github.com/llvm/llvm-project/pull/178656.diff


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp (+5) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-vararg.cpp
 (+6) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/178656
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to