Partial fix for 9049: False negative: uninitialized variable with nested ifs#8680
Partial fix for 9049: False negative: uninitialized variable with nested ifs#8680pfultz2 wants to merge 24 commits into
Conversation
| if (Token::Match(ftok, "exit|abort")) | ||
| return true; |
There was a problem hiding this comment.
There is also terminate() but it feels like should already be handled via the noreturn handling below (i.e. library configuration).
| const bool inElse = scope->type == ScopeType::eElse; | ||
| const bool inDoWhile = scope->type == ScopeType::eDo; | ||
| const bool inLoop = contains({ScopeType::eDo, ScopeType::eFor, ScopeType::eWhile}, scope->type); | ||
| const bool hasElse = Token::simpleMatch(tok, "} else {"); |
There was a problem hiding this comment.
Since it is grouped with other similar variables this is fine but in a future we should try to reduce the scope of this (i.e. avoid computing them until they are used).
There was a problem hiding this comment.
It was moved here so its not calculated multiple times. Probably could use the memoize function to lazily compute it once, but I think its beyond the scope here because I need to evaluate if its slower or not.
There was a problem hiding this comment.
I was referring to moving them after the if (!condTok) check. But as also mentioned no need to do so.
|
The comments and the description appear to hint at AI assistance. Is that the case? |
|
|
This fixes the case for this:
Which doesnt use a compund condition
dimensions >= 1 && b)and it also requires complete variables and functions. The compund condition could be handled in the future by forking within the condition, soif(a && b) { ... }can be treated asif(a) { if(b) { ... }}.Here is a summary of the changes: