https://github.com/kr-2003 created 
https://github.com/llvm/llvm-project/pull/132427

Fixes #132001 

Edit ```isNonUnionUninit``` (caller of ```isPrimitiveUninit```): Add a check 
before calling ```isPrimitiveUninit```
```cpp
if (isPrimitiveType(T)) {
  if (I->isUnnamedBitField()) {
    continue;
  }
  if (isPrimitiveUninit(V)) {
    if (addFieldToUninits(LocalChain.add(RegularField(FR))))
      ContainsUninitField = true;
  }
  continue;
}
```

**Test Results**
```bash
Testing Time: 221.93s

Total Discovered Tests: 991
  Unsupported      :  16 (1.61%)
  Passed           : 968 (97.68%)
  Expectedly Failed:   7 (0.71%)
[100%] Built target check-clang-analysis
```

>From 72aafcc255bbcfccb3fa5317e260faf97a3dfed5 Mon Sep 17 00:00:00 2001
From: kr-2003 <kumar.kr.abhi...@gmail.com>
Date: Fri, 21 Mar 2025 20:45:11 +0530
Subject: [PATCH 1/2] [clang][analyzer] Removed warnings for unnamed bitfields

---
 .../UninitializedObject/UninitializedObjectChecker.cpp        | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 6e1222fedad3e..bf954c3711309 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -332,6 +332,10 @@ bool FindUninitializedFields::isNonUnionUninit(const 
TypedValueRegion *R,
     }
 
     if (isPrimitiveType(T)) {
+      if (I->isUnnamedBitField()) {
+        IsAnyFieldInitialized = true;
+        continue;
+      }
       if (isPrimitiveUninit(V)) {
         if (addFieldToUninits(LocalChain.add(RegularField(FR))))
           ContainsUninitField = true;

>From ff01085e3e7aaab4a5dd54e69b3f5be19d43001f Mon Sep 17 00:00:00 2001
From: kr-2003 <kumar.kr.abhi...@gmail.com>
Date: Fri, 21 Mar 2025 22:46:33 +0530
Subject: [PATCH 2/2] removed IsAnyFieldInitialized after isUnnamedBitField

---
 .../Checkers/UninitializedObject/UninitializedObjectChecker.cpp  | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index bf954c3711309..bf7759975b3ec 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -333,7 +333,6 @@ bool FindUninitializedFields::isNonUnionUninit(const 
TypedValueRegion *R,
 
     if (isPrimitiveType(T)) {
       if (I->isUnnamedBitField()) {
-        IsAnyFieldInitialized = true;
         continue;
       }
       if (isPrimitiveUninit(V)) {

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to