C++: Extend the GetsFunction and SystemFunction models.#3694
Conversation
jbj
left a comment
There was a problem hiding this comment.
LGTM. I took this uncontroversial PR as an opportunity to advertise a new QL language feature.
|
|
||
| override predicate interestingArg(int arg) { arg = 0 } | ||
|
|
||
| override predicate hasArrayWithNullTerminator(int bufParam) { bufParam = 0 or bufParam = 1 } |
There was a problem hiding this comment.
It's of course a matter of preference, but this disjunction can also be written as bufParam = [0, 1] (since about a month ago). Apart from saving bytes, it might make the meaning of the code jump of the screen faster because the reader doesn't have to read the words to see that bufParam is used twice and that it's an or rather than an and.
Also below.
There was a problem hiding this comment.
Cool. I suspect this will be most valuable when there are more than two cases (MagicConstants.qll!), and I shall look out for opportunities to use it in future. We could also update the entire models library, but I'm not in a rush to.
|
Also, the tests failed. |
|
I assume we're not worried about the (new, experimental?) code scanning checks at this stage, all other tests are now passing. |
I was hoping one of these would fix an issue I was looking at. They didn't. But the improvements are worth keeping anyway.