forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAssignmentOperation.qll
More file actions
57 lines (48 loc) · 1.28 KB
/
AssignmentOperation.qll
File metadata and controls
57 lines (48 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Provides classes for assignment operations.
*/
private import rust
private import codeql.rust.elements.internal.BinaryExprImpl
/**
* An assignment operation, for example:
* ```rust
* x = y;
* x += y;
* ```
*/
abstract private class AssignmentOperationImpl extends Impl::BinaryExpr { }
final class AssignmentOperation = AssignmentOperationImpl;
/**
* An assignment expression, for example:
* ```rust
* x = y;
* ```
*/
final class AssignmentExpr extends AssignmentOperationImpl {
AssignmentExpr() { this.getOperatorName() = "=" }
override string getAPrimaryQlClass() { result = "AssignmentExpr" }
}
/**
* A compound assignment expression, for example:
* ```rust
* x += y;
* ```
*
* Note that compound assignment expressions are syntatic sugar for
* trait invocations, i.e., the above actually means
*
* ```rust
* (&mut x).add_assign(y);
* ```
*/
final class CompoundAssignmentExpr extends AssignmentOperationImpl {
private string operator;
CompoundAssignmentExpr() {
this.getOperatorName().regexpCapture("(\\+|-|\\*|/|%|&|\\||\\^|<<|>>)=", 1) = operator
}
/**
* Gets the operator of this compound assignment expression.
*/
string getOperator() { result = operator }
override string getAPrimaryQlClass() { result = "CompoundAssignmentExpr" }
}