-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Generate a temporary IRVariable
for PostfixCrementOperation
s
#13326
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
C++: Generate a temporary IRVariable
for PostfixCrementOperation
s
#13326
Conversation
d4d4068
to
e9812df
Compare
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.
LGTM. One small comment. I haven't looked at the DCA result changes. Will do that next (I'm assuming you haven't gotten to that yet).
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll
Outdated
Show resolved
Hide resolved
The alert losses on the nightly query suite seem to be genuine losses (I did spot checking only). All queries with losses either use default taint tracking or are rewrites that clearly derive from default taint tracking, so it's not completely clear to me to what extent we should worry about these losses. |
The memory corruption |
…slatedExpr.qll Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Thanks for looking at these. I'll take a brief look at what's going on with some of these and see if I can fix it. |
Superseded by #13406. |
Since IR dataflow doesn't look at memory operands, it's not possible for the dataflow SSA to distinguish between
*p++
and*++p
(since the only difference between those two expressions is whichInstruction
defines the memory operand of theLoadInstruction
). This causes lots of FPs in the experimentalcpp/invalid-pointer-deref
query.As a workaround for this problem, this PR generates a temporary
IRVariable
to capture the fact that a difference value is loaded from in theLoadInstruction
. That is, on this snippetint x = *p++;
we now generate:instead of:
(Edit: I've updated the example to reflect the changes in bfde165.)
This means dataflow SSA now correctly concludes that the increment of
x
doesn't flow to the address of theLoad
instruction.To reduce the number of additional instructions and
IRVariables
generated, I've limited the change to only cases where the postfix crement isn't in a void context.This is currently marked as a draft because I don't quite understand the changes to range-analysis in d4d4068.I took an extra look, and these changes also seem completely fine. It's just a result of more slightly more instructions. All the other changes looks good, though - especially the ones in 9d33547 🎉!(cc @jketema)