C++: Fix FP in cpp/uninitialized-local#6342
Conversation
| not exists(v.getInitializer()) and | ||
| /* The type of the variable is not stack-allocated. */ | ||
| not allocatedType(v.getType()) | ||
| exists(Type t | t = v.getType() | not allocatedType(t)) |
There was a problem hiding this comment.
Change LGTM.
Remind me why it's OK for a Variable to have no type. Is it possible for one to have more than one type?
There was a problem hiding this comment.
I wonder what would happen in a situation where a variable has two types, one of which is 'stack-allocated' and the other of which isn't. It's hard to imagine it coming up. Possibly a forex might be more robust in that situation???
(I think 'stack-allocated' is a poor choice of name by the way; what we're really talking about, I think, is types that can be partially assigned)
There was a problem hiding this comment.
It would be more robust, yeah. I think, however, that there are many places where such a change would make things more robust. It might even be better to just leave them as they are, as this gives us a better chance to expose extractor-related issues in the wild.
I also agree that the name could be more precise. Would you prefer if I changed the name to partiallyAssignable or something similar?
There was a problem hiding this comment.
I prefer partiallyAssignable, but I appreciate you probably have higher priorities than cleaning up this query.
geoffw0
left a comment
There was a problem hiding this comment.
Happy with this change as it is though.
I was testing something completely different when I came across a result from
cpp/uninitialized-localthat was very unexpected. Onmainwe currently raise an alert in Joystick.cpp due to the use ofnotin the following predicate:because the
jinputvariable has no result forgetType(). This PR fixes that FP.