Skip to content

Commit 8966a96

Browse files
committed
C#: Rename arithmetic classes.
1 parent 95b1ad5 commit 8966a96

7 files changed

Lines changed: 106 additions & 92 deletions

File tree

csharp/ql/lib/semmle/code/csharp/Assignable.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ module AssignableInternal {
290290
newtype TAssignableDefinition =
291291
TAssignmentDefinition(Assignment a) {
292292
not a.getLeftOperand() instanceof TupleExpr and
293-
not a instanceof AssignCallOperation and
293+
not a instanceof AssignCallExpr and
294294
not a instanceof AssignCoalesceExpr
295295
} or
296296
TTupleAssignmentDefinition(AssignExpr ae, Expr leaf) { tupleAssignmentDefinition(ae, leaf) } or
@@ -324,7 +324,7 @@ module AssignableInternal {
324324
TAddressOfDefinition(AddressOfExpr aoe) or
325325
TPatternDefinition(TopLevelPatternDecl tlpd) or
326326
TAssignOperationDefinition(AssignOperation ao) {
327-
ao instanceof AssignCallOperation and not ao instanceof CompoundAssignmentOperatorCall
327+
ao instanceof AssignCallExpr and not ao instanceof CompoundAssignmentOperatorCall
328328
or
329329
ao instanceof AssignCoalesceExpr
330330
}

csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -912,18 +912,17 @@ module Internal {
912912
)
913913
or
914914
// In C#, `null + 1` has type `int?` with value `null`
915-
exists(BinaryOperation bo, Expr o |
916-
bo instanceof BinaryArithmeticOperation or
917-
bo instanceof AssignArithmeticOperation
918-
|
919-
result = bo and
920-
bo.getAnOperand() = e and
921-
bo.getAnOperand() = o and
922-
// The other operand must be provably non-null in order
923-
// for `only if` to hold
924-
nonNullValueImplied(o) and
925-
e != o
926-
)
915+
result =
916+
any(BinaryArithmeticOperation bao |
917+
exists(Expr o |
918+
bao.getAnOperand() = e and
919+
bao.getAnOperand() = o and
920+
// The other operand must be provably non-null in order
921+
// for `only if` to hold
922+
nonNullValueImplied(o) and
923+
e != o
924+
)
925+
)
927926
}
928927

929928
/**
@@ -934,10 +933,10 @@ module Internal {
934933
any(QualifiableExpr qe |
935934
qe.isConditional() and
936935
result = qe.getQualifier()
937-
) or
936+
)
937+
or
938938
// In C#, `null + 1` has type `int?` with value `null`
939-
e = any(BinaryArithmeticOperation bao | result = bao.getAnOperand()) or
940-
e = any(AssignArithmeticOperation aao | result = aao.getAnOperand())
939+
e = any(BinaryArithmeticOperation bao | result = bao.getAnOperand())
941940
}
942941

943942
deprecated predicate isGuard(Expr e, GuardValue val) {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ private module Internal {
124124
TDispatchDynamicOperatorCall(DynamicOperatorCall doc) or
125125
TDispatchDynamicMemberAccess(DynamicMemberAccess dma) or
126126
TDispatchDynamicElementAccess(DynamicElementAccess dea) or
127-
TDispatchDynamicEventAccess(
128-
AssignArithmeticOperation aao, DynamicMemberAccess dma, string name
129-
) {
127+
TDispatchDynamicEventAccess(AssignArithmeticExpr aao, DynamicMemberAccess dma, string name) {
130128
isPotentialEventCall(aao, dma, name)
131129
} or
132130
TDispatchDynamicObjectCreation(DynamicObjectCreation doc) or
@@ -230,7 +228,7 @@ private module Internal {
230228
* accessor.
231229
*/
232230
private predicate isPotentialEventCall(
233-
AssignArithmeticOperation aao, DynamicMemberAccess dma, string name
231+
AssignArithmeticExpr aao, DynamicMemberAccess dma, string name
234232
) {
235233
aao instanceof DynamicOperatorCall and
236234
dma = aao.getLeftOperand() and
@@ -1397,9 +1395,7 @@ private module Internal {
13971395
private class DispatchDynamicEventAccess extends DispatchReflectionOrDynamicCall,
13981396
TDispatchDynamicEventAccess
13991397
{
1400-
override AssignArithmeticOperation getCall() {
1401-
this = TDispatchDynamicEventAccess(result, _, _)
1402-
}
1398+
override AssignArithmeticExpr getCall() { this = TDispatchDynamicEventAccess(result, _, _) }
14031399

14041400
override string getName() { this = TDispatchDynamicEventAccess(_, _, result) }
14051401

csharp/ql/lib/semmle/code/csharp/exprs/ArithmeticOperation.qll

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Expr
1111
* (`UnaryArithmeticOperation`) or a binary arithmetic operation
1212
* (`BinaryArithmeticOperation`).
1313
*/
14-
class ArithmeticOperation extends Operation, @arith_op_expr {
14+
class ArithmeticOperation extends Operation, @arith_operation {
1515
override string getOperator() { none() }
1616
}
1717

@@ -20,7 +20,7 @@ class ArithmeticOperation extends Operation, @arith_op_expr {
2020
* (`UnaryMinusExpr`), a unary plus operation (`UnaryPlusExpr`),
2121
* or a mutator operation (`MutatorOperation`).
2222
*/
23-
class UnaryArithmeticOperation extends ArithmeticOperation, UnaryOperation, @un_arith_op_expr { }
23+
class UnaryArithmeticOperation extends ArithmeticOperation, UnaryOperation, @un_arith_operation { }
2424

2525
/**
2626
* A unary minus operation, for example `-x`.
@@ -44,21 +44,21 @@ class UnaryPlusExpr extends UnaryArithmeticOperation, @plus_expr {
4444
* A mutator operation. Either an increment operation (`IncrementOperation`)
4545
* or a decrement operation (`DecrementOperation`).
4646
*/
47-
class MutatorOperation extends UnaryArithmeticOperation, @mut_op_expr { }
47+
class MutatorOperation extends UnaryArithmeticOperation, @mut_operation { }
4848

4949
/**
5050
* An increment operation. Either a postfix increment operation
5151
* (`PostIncrExpr`) or a prefix increment operation (`PreIncrExpr`).
5252
*/
53-
class IncrementOperation extends MutatorOperation, @incr_op_expr {
53+
class IncrementOperation extends MutatorOperation, @incr_operation {
5454
override string getOperator() { result = "++" }
5555
}
5656

5757
/**
5858
* A decrement operation. Either a postfix decrement operation
5959
* (`PostDecrExpr`) or a prefix decrement operation (`PreDecrExpr`).
6060
*/
61-
class DecrementOperation extends MutatorOperation, @decr_op_expr {
61+
class DecrementOperation extends MutatorOperation, @decr_operation {
6262
override string getOperator() { result = "--" }
6363
}
6464

@@ -95,19 +95,17 @@ class PostDecrExpr extends DecrementOperation, @post_decr_expr {
9595
}
9696

9797
/**
98-
* A binary arithmetic operation. Either an addition operation
99-
* (`AddExpr`), a subtraction operation (`SubExpr`), a multiplication
100-
* operation (`MulExpr`), a division operation (`DivExpr`), or a
101-
* remainder operation (`RemExpr`).
98+
* A binary arithmetic expression. Either an addition expression
99+
* (`AddExpr`), a subtraction expression (`SubExpr`), a multiplication
100+
* expression (`MulExpr`), a division expression (`DivExpr`), or a
101+
* remainder expression (`RemExpr`).
102102
*/
103-
class BinaryArithmeticOperation extends ArithmeticOperation, BinaryOperation, @bin_arith_op_expr {
104-
override string getOperator() { none() }
105-
}
103+
class BinaryArithmeticExpr extends BinaryArithmeticOperation, @bin_arith_expr { }
106104

107105
/**
108106
* An addition operation, for example `x + y`.
109107
*/
110-
class AddExpr extends BinaryArithmeticOperation, AddOperation, @add_expr {
108+
class AddExpr extends BinaryArithmeticExpr, AddOperation, @add_expr {
111109
override string getOperator() { result = "+" }
112110

113111
override string getAPrimaryQlClass() { result = "AddExpr" }
@@ -116,7 +114,7 @@ class AddExpr extends BinaryArithmeticOperation, AddOperation, @add_expr {
116114
/**
117115
* A subtraction operation, for example `x - y`.
118116
*/
119-
class SubExpr extends BinaryArithmeticOperation, SubOperation, @sub_expr {
117+
class SubExpr extends BinaryArithmeticExpr, SubOperation, @sub_expr {
120118
override string getOperator() { result = "-" }
121119

122120
override string getAPrimaryQlClass() { result = "SubExpr" }
@@ -125,7 +123,7 @@ class SubExpr extends BinaryArithmeticOperation, SubOperation, @sub_expr {
125123
/**
126124
* A multiplication operation, for example `x * y`.
127125
*/
128-
class MulExpr extends BinaryArithmeticOperation, MulOperation, @mul_expr {
126+
class MulExpr extends BinaryArithmeticExpr, MulOperation, @mul_expr {
129127
override string getOperator() { result = "*" }
130128

131129
override string getAPrimaryQlClass() { result = "MulExpr" }
@@ -134,7 +132,7 @@ class MulExpr extends BinaryArithmeticOperation, MulOperation, @mul_expr {
134132
/**
135133
* A division operation, for example `x / y`.
136134
*/
137-
class DivExpr extends BinaryArithmeticOperation, DivOperation, @div_expr {
135+
class DivExpr extends BinaryArithmeticExpr, DivOperation, @div_expr {
138136
override string getOperator() { result = "/" }
139137

140138
override string getAPrimaryQlClass() { result = "DivExpr" }
@@ -143,7 +141,7 @@ class DivExpr extends BinaryArithmeticOperation, DivOperation, @div_expr {
143141
/**
144142
* A remainder operation, for example `x % y`.
145143
*/
146-
class RemExpr extends BinaryArithmeticOperation, RemOperation, @rem_expr {
144+
class RemExpr extends BinaryArithmeticExpr, RemOperation, @rem_expr {
147145
override string getOperator() { result = "%" }
148146

149147
override string getAPrimaryQlClass() { result = "RemExpr" }

0 commit comments

Comments
 (0)