-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathBitwiseOperation.qll
More file actions
100 lines (79 loc) · 2.2 KB
/
BitwiseOperation.qll
File metadata and controls
100 lines (79 loc) · 2.2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Provides classes for modeling bitwise operations such as `~`, `<<`, `&` and
* `|`.
*/
import semmle.code.cpp.exprs.Expr
/**
* A C/C++ unary bitwise operation.
*/
class UnaryBitwiseOperation extends UnaryOperation, @un_bitwise_op_expr { }
/**
* A C/C++ complement expression.
* ```
* unsigned c = ~a;
* ```
*/
class ComplementExpr extends UnaryBitwiseOperation, @complementexpr {
override string getOperator() { result = "~" }
override int getPrecedence() { result = 16 }
override string getAPrimaryQlClass() { result = "ComplementExpr" }
}
/**
* A C/C++ binary bitwise operation.
*/
class BinaryBitwiseOperation extends BinaryOperation, @bin_bitwise_op_expr { }
/**
* A C/C++ left shift expression.
* ```
* unsigned c = a << b;
* ```
*/
class LShiftExpr extends BinaryBitwiseOperation, @lshiftexpr {
override string getOperator() { result = "<<" }
override int getPrecedence() { result = 12 }
override string getAPrimaryQlClass() { result = "LShiftExpr" }
}
/**
* A C/C++ right shift expression.
* ```
* unsigned c = a >> b;
* ```
*/
class RShiftExpr extends BinaryBitwiseOperation, @rshiftexpr {
override string getOperator() { result = ">>" }
override int getPrecedence() { result = 12 }
override string getAPrimaryQlClass() { result = "RShiftExpr" }
}
/**
* A C/C++ bitwise AND expression.
* ```
* unsigned c = a & b;
* ```
*/
class BitwiseAndExpr extends BinaryBitwiseOperation, @andexpr {
override string getOperator() { result = "&" }
override int getPrecedence() { result = 8 }
override string getAPrimaryQlClass() { result = "BitwiseAndExpr" }
}
/**
* A C/C++ bitwise OR expression.
* ```
* unsigned c = a | b;
* ```
*/
class BitwiseOrExpr extends BinaryBitwiseOperation, @orexpr {
override string getOperator() { result = "|" }
override int getPrecedence() { result = 6 }
override string getAPrimaryQlClass() { result = "BitwiseOrExpr" }
}
/**
* A C/C++ bitwise XOR expression.
* ```
* unsigned c = a ^ b;
* ```
*/
class BitwiseXorExpr extends BinaryBitwiseOperation, @xorexpr {
override string getOperator() { result = "^" }
override int getPrecedence() { result = 7 }
override string getAPrimaryQlClass() { result = "BitwiseXorExpr" }
}