mirror of
https://github.com/github/codeql.git
synced 2026-05-14 19:29:28 +02:00
C#: Handle compound assignment operators in the dispatch logic (and assignable definition).
This commit is contained in:
@@ -315,7 +315,8 @@ module AssignableInternal {
|
||||
TAddressOfDefinition(AddressOfExpr aoe) or
|
||||
TPatternDefinition(TopLevelPatternDecl tlpd) or
|
||||
TAssignOperationDefinition(AssignOperation ao) {
|
||||
ao instanceof AssignCallOperation or
|
||||
ao instanceof AssignCallOperation and not ao instanceof CompoundAssignmentOperatorCall
|
||||
or
|
||||
ao instanceof AssignCoalesceExpr
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,11 @@ private module Internal {
|
||||
or
|
||||
ac instanceof AssignableWrite and isRead = false
|
||||
} or
|
||||
TDispatchOperatorCall(OperatorCall oc) { not oc.isLateBound() } or
|
||||
TDispatchOperatorCall(OperatorCall oc) {
|
||||
not oc.isLateBound() and
|
||||
not oc instanceof CompoundAssignmentOperatorCall
|
||||
} or
|
||||
TDispatchCompoundAssignmentOperatorCall(CompoundAssignmentOperatorCall caoc) or
|
||||
TDispatchReflectionCall(MethodCall mc, string name, Expr object, Expr qualifier, int args) {
|
||||
isReflectionCall(mc, name, object, qualifier, args)
|
||||
} or
|
||||
@@ -886,6 +890,20 @@ private module Internal {
|
||||
override Operator getAStaticTarget() { result = this.getCall().getTarget() }
|
||||
}
|
||||
|
||||
private class DispatchCompoundAssignmentOperatorCall extends DispatchOverridableCall,
|
||||
TDispatchCompoundAssignmentOperatorCall
|
||||
{
|
||||
override CompoundAssignmentOperatorCall getCall() {
|
||||
this = TDispatchCompoundAssignmentOperatorCall(result)
|
||||
}
|
||||
|
||||
override Expr getArgument(int i) { result = this.getCall().getArgument(i) }
|
||||
|
||||
override Expr getQualifier() { result = this.getCall().getQualifier() }
|
||||
|
||||
override Operator getAStaticTarget() { result = this.getCall().getTarget() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to an accessor.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user