-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][analyzer] Fix the false positive ArgInitializedness warning on unnamed bit-field #145066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
03004d9
c54bc99
cf09a9e
db350f6
093b909
4e8fc65
ff376d1
00e509a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2122,8 +2122,21 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B, | |
| if (const std::optional<SVal> &V = B.getDirectBinding(R)) | ||
| return *V; | ||
|
|
||
| // If the containing record was initialized, try to get its constant value. | ||
| // UnnamedBitField is always Undefined unless using memory operation such | ||
| // as 'memset'. | ||
| // For example, for code | ||
| // typedef struct { | ||
| // int i :2; | ||
| // int :30; // unnamed bit-field | ||
| // } A; | ||
| // A a = {1}; | ||
| // The bits of the unnamed bit-field in local variable a can be anything. | ||
| const FieldDecl *FD = R->getDecl(); | ||
| if (FD->isUnnamedBitField()) { | ||
| return UndefinedVal(); | ||
| } | ||
|
|
||
| // If the containing record was initialized, try to get its constant value. | ||
|
||
| QualType Ty = FD->getType(); | ||
| const MemRegion* superR = R->getSuperRegion(); | ||
| if (const auto *VR = dyn_cast<VarRegion>(superR)) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.