Skip to content

Commit 6723076

Browse files
committed
C#: Add dispatch logic for compound assignment operator calls.
1 parent f2059cf commit 6723076

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

csharp/ql/lib/semmle/code/csharp/dispatch/Dispatch.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ private module Internal {
9191
not isExtensionAccessorCall(mc)
9292
} or
9393
TDispatchAccessorCall(AccessorCall ac) or
94-
TDispatchOperatorCall(OperatorCall oc) { not oc.isLateBound() } or
94+
TDispatchOperatorCall(OperatorCall oc) {
95+
not oc.isLateBound() and
96+
not oc instanceof CompoundAssignmentOperatorCall
97+
} or
98+
TDispatchCompoundAssignmentOperatorCall(CompoundAssignmentOperatorCall caoc) or
9599
TDispatchReflectionCall(MethodCall mc, string name, Expr object, Expr qualifier, int args) {
96100
isReflectionCall(mc, name, object, qualifier, args)
97101
} or
@@ -872,6 +876,20 @@ private module Internal {
872876
override Operator getAStaticTarget() { result = this.getCall().getTarget() }
873877
}
874878

879+
private class DispatchCompoundAssignmentOperatorCall extends DispatchOverridableCall,
880+
TDispatchCompoundAssignmentOperatorCall
881+
{
882+
override CompoundAssignmentOperatorCall getCall() {
883+
this = TDispatchCompoundAssignmentOperatorCall(result)
884+
}
885+
886+
override Expr getArgument(int i) { result = this.getCall().getArgument(i) }
887+
888+
override Expr getQualifier() { result = this.getCall().getChildExpr(-1) }
889+
890+
override Operator getAStaticTarget() { result = this.getCall().getTarget() }
891+
}
892+
875893
/**
876894
* A call to an accessor.
877895
*

0 commit comments

Comments
 (0)