[clang] [clang-tools-extra] Fix hicpp vararg popcountg (PR #178709)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 29 09:51:59 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Devanshi (Devanshi-cmd)

<details>
<summary>Changes</summary>



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


4 Files Affected:

- (modified) clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp (+1) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-vararg.cpp (+9-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp (+3-1) 
- (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp (+3-1) 


``````````diff
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
index d5ff4af84b0b7..0601de71e57a3 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -55,6 +55,7 @@ static constexpr StringRef AllowedVariadics[] = {
     "__builtin_preserve_access_index",
     "__builtin_nontemporal_store",
     "__builtin_nontemporal_load",
+    "__builtin_popcountg",              
     "__builtin_ms_va_start",
     // 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..d2ee6cf477b34 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,7 @@ void ignoredBuiltinsTest(void *ptr) {
   (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
   (void)__builtin_isinf_sign(0.f);
   (void)__builtin_prefetch(nullptr);
+  (void)__builtin_popcountg(42);
 }
 
 // Some implementations of __builtin_va_list and __builtin_ms_va_list desugared
@@ -68,7 +69,14 @@ void no_false_positive_desugar_va_list(char *in) {
 }
 
 namespace PR30542 {
-  struct X;
+  struct X;static cl::opt<unsigned long long>
+  MaxSamples("max-samples",
+    cl::init(-1ULL),
+    cl::desc("maximum number of samples to read from LBR profile"),
+    cl::Optional,
+    cl::Hidden,
+    cl::cat(AggregatorCategory));
+  
   template <typename T>
   char IsNullConstant(X*);
   template <typename T>
diff --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
index 26465a804f1e6..e61e0390ee86d 100644
--- a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
@@ -26,6 +26,8 @@
 #include "clang/CIR/MissingFeatures.h"
 #include "llvm/Support/ErrorHandling.h"
 
+#include <limits>
+
 using namespace clang;
 using namespace clang::CIRGen;
 
@@ -1939,7 +1941,7 @@ static CharUnits computeOffsetHint(ASTContext &astContext,
       // If the path contains a virtual base class we can't give any hint.
       // -1: no hint.
       if (pathElement.Base->isVirtual())
-        return CharUnits::fromQuantity(-1ULL);
+        return CharUnits::fromQuantity( std::numeric_limits<uint64_t>::max());
 
       if (numPublicPaths > 1) // Won't use offsets, skip computation.
         continue;
diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp
index 50c481192f16b..05ac389970c59 100644
--- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp
@@ -26,6 +26,8 @@
 #include "mlir/IR/ImplicitLocOpBuilder.h"
 #include "llvm/Support/ErrorHandling.h"
 
+#include <limits>
+
 namespace cir {
 
 namespace {
@@ -177,7 +179,7 @@ mlir::TypedAttr LowerItaniumCXXABI::lowerDataMemberConstant(
   if (attr.isNullPtr()) {
     // Itanium C++ ABI 2.3:
     //   A NULL pointer is represented as -1.
-    memberOffset = -1ull;
+    memberOffset = -1;
   } else {
     // Itanium C++ ABI 2.3:
     //   A pointer to data member is an offset from the base address of

``````````

</details>


https://github.com/llvm/llvm-project/pull/178709


More information about the cfe-commits mailing list