-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Fix dataflow node <> expression problem on prvalues #15918
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
Conversation
…e expression is a prvalue.
88a31fd
to
a839c92
Compare
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
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.
Changes look reasonable. DCA run looks clean. I'm slightly surprised there weren't any result changes.
@@ -1533,6 +1552,12 @@ private class IndirectArgumentOutExprNode extends ExprNodeBase, IndirectArgument | |||
final override Expr getConvertedExpr(int n) { exprNodeShouldBeIndirectOutNode(this, result, n) } | |||
} | |||
|
|||
private class IndirectTemporaryExpr extends ExprNodeBase instanceof IndirectOperand { | |||
IndirectTemporaryExpr() { exprNodeShouldBeIndirectOperand(this, _, _) } |
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.
I feel like there's a mismatch between this class, which claims that the node is a temporary expr, with the QLDoc on exprNodeShouldBeIndirectOperand
, which only claims the node is an IndirectOperand
(that should have a .asExpr()
). Its probably just be me, missing a connection here.
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.
That's fair. I'll rename the class to something more generic. It's currently true because exprNodeShouldBeIndirectOperand
restricts the node to be an indirection of an operand whose definition is related to a temporary IR variable. But that's not guaranteed to be true if we find other uses of this class.
If it's okay with you, I'll do this in a subsequent PR so that you can get this change into #15371 without waiting for another round of CI
This fixes the two surprising missing results from #15371 that @geoffw0 was seeing when he switched from interpreting
Argument[-1]
asthis
to*this
.I didn't bother adding a testcase since @geoffw0 PR will contain such tests anyway