mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Convert post-update logic to IR (part 2)
Note that we don't create post-update nodes for method receivers if the call to the method is indirect, via a function variable. We could aim to do this in future.
This commit is contained in:
@@ -815,15 +815,28 @@ module Public {
|
||||
e = any(DerefExpr ae).getOperand() or
|
||||
e = any(IR::EvalImplicitDerefInstruction eidi).getOperand()
|
||||
)
|
||||
or
|
||||
exists(CallExpr ce |
|
||||
ce.getArgument(0).getType() instanceof TupleType and
|
||||
insn = IR::extractTupleElement(IR::evalExprInstruction(ce.getArgument(0)), _)
|
||||
or
|
||||
not ce.getArgument(0).getType() instanceof TupleType and
|
||||
insn = IR::evalExprInstruction(ce.getAnArgument())
|
||||
or
|
||||
// Receiver of a method call
|
||||
exists(IR::MethodReadInstruction mri |
|
||||
ce.getTarget() instanceof Method and
|
||||
mri = IR::evalExprInstruction(ce.getCalleeExpr()) and
|
||||
insn = mri.getReceiver()
|
||||
)
|
||||
) and
|
||||
mutableType(insn.getResultType())
|
||||
}
|
||||
|
||||
predicate hasPostUpdateNode(Node preupd) {
|
||||
insnHasPostUpdateNode(preupd.asInstruction())
|
||||
or
|
||||
preupd = getAWrittenNode()
|
||||
or
|
||||
preupd = any(ArgumentNode arg).getACorrespondingSyntacticArgument() and
|
||||
mutableType(preupd.getType())
|
||||
}
|
||||
|
||||
private class DefaultPostUpdateNode extends PostUpdateNode {
|
||||
|
||||
Reference in New Issue
Block a user