-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #15077 FP uninitvar for array of std::vector #8908
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
base: main
Are you sure you want to change the base?
Changes from all commits
87eac7a
4272487
4f82e10
ad69146
d859d3c
95caefb
52e78c9
b178584
27c4120
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 |
|---|---|---|
|
|
@@ -727,7 +727,7 @@ static void valueFlowArrayBool(TokenList& tokenlist, const Settings& settings) | |
| } | ||
| if (!var) | ||
| continue; | ||
| if (!var->isArray() || var->isArgument() || var->getTypeName() == "std::array") | ||
| if (!var->isArray() || var->isArgument() || var->isStlType("array")) | ||
| continue; | ||
| if (isNonZero(getOtherOperand(tok)) && Token::Match(tok->astParent(), "%comp%")) | ||
| continue; | ||
|
|
@@ -1169,7 +1169,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett | |
| value.setImpossible(); | ||
| setTokenValue(tok, std::move(value), settings); | ||
| } else if (tok->variable() && tok->variable()->isArray() && !tok->variable()->isArgument() && | ||
| tok->variable()->getTypeName() != "std::array") { | ||
| !tok->variable()->isStlType("array")) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve
void h1() { std::array<int,3>::value_type a[2] = {}; if (a) {} }
void h2() { std::array<int,3>::value_type a[2] = {}; if (a == nullptr) {} }main: The same applies to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danmar: Do you see what's happening here? First, there is a suggestion, and only after adopting it I'm told it's a bad idea. What a waste of time. |
||
| ValueFlow::Value value{0}; | ||
| value.setImpossible(); | ||
| setTokenValue(tok, std::move(value), settings); | ||
|
|
@@ -5995,7 +5995,7 @@ static bool needsInitialization(const Variable* var) | |
| return true; | ||
| if (var->valueType()->type == ValueType::Type::ITERATOR) | ||
| return true; | ||
| if (var->isStlType() && var->isArray()) { | ||
| if (var->isArray() && var->isStlType("array")) { | ||
| if (const Token* ctt = var->valueType()->containerTypeToken) { | ||
| if (ctt->isStandardType()) | ||
| return true; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve
Same
isStlType("array")vsgetTypeName() == "std::array"difference as in valueflow.cpp. This one causes a false negative:main warns
sizeofwithsilentarraypointer, the PR is silent. (The old code here had bothisStlType()andgetTypeName() == "std::array", so it was exact.)