Skip to content

Commit 47019f7

Browse files
committed
Rust: Define NumericType, IntegralType and FloatingPointType in Builtins.qll.
1 parent aaa3b1b commit 47019f7

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

rust/ql/lib/codeql/rust/frameworks/stdlib/Builtins.qll

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,30 @@ class BuiltinType extends Struct {
3131
string getName() { result = super.getName().getText() }
3232
}
3333

34+
/**
35+
* A numerical type, such as `i64`, `usize`, `f32` or `f64`.
36+
*/
37+
abstract private class NumericTypeImpl extends BuiltinType {
38+
}
39+
40+
final class NumericType = NumericTypeImpl;
41+
42+
/**
43+
* An integral numerical type, such as `i64` or `usize`.
44+
*/
45+
abstract private class IntegralTypeImpl extends NumericTypeImpl {
46+
}
47+
48+
final class IntegralType = IntegralTypeImpl;
49+
50+
/**
51+
* A floating-point numerical type, such as `f32` or `f64`.
52+
*/
53+
abstract private class FloatingPointTypeImpl extends NumericTypeImpl {
54+
}
55+
56+
final class FloatingPointType = FloatingPointTypeImpl;
57+
3458
/** The builtin `bool` type. */
3559
class Bool extends BuiltinType {
3660
Bool() { this.getName() = "bool" }
@@ -47,71 +71,71 @@ class Str extends BuiltinType {
4771
}
4872

4973
/** The builtin `i8` type. */
50-
class I8 extends BuiltinType {
74+
class I8 extends IntegralTypeImpl {
5175
I8() { this.getName() = "i8" }
5276
}
5377

5478
/** The builtin `i16` type. */
55-
class I16 extends BuiltinType {
79+
class I16 extends IntegralTypeImpl {
5680
I16() { this.getName() = "i16" }
5781
}
5882

5983
/** The builtin `i32` type. */
60-
class I32 extends BuiltinType {
84+
class I32 extends IntegralTypeImpl {
6185
I32() { this.getName() = "i32" }
6286
}
6387

6488
/** The builtin `i64` type. */
65-
class I64 extends BuiltinType {
89+
class I64 extends IntegralTypeImpl {
6690
I64() { this.getName() = "i64" }
6791
}
6892

6993
/** The builtin `i128` type. */
70-
class I128 extends BuiltinType {
94+
class I128 extends IntegralTypeImpl {
7195
I128() { this.getName() = "i128" }
7296
}
7397

7498
/** The builtin `u8` type. */
75-
class U8 extends BuiltinType {
99+
class U8 extends IntegralTypeImpl {
76100
U8() { this.getName() = "u8" }
77101
}
78102

79103
/** The builtin `u16` type. */
80-
class U16 extends BuiltinType {
104+
class U16 extends IntegralTypeImpl {
81105
U16() { this.getName() = "u16" }
82106
}
83107

84108
/** The builtin `u32` type. */
85-
class U32 extends BuiltinType {
109+
class U32 extends IntegralTypeImpl {
86110
U32() { this.getName() = "u32" }
87111
}
88112

89113
/** The builtin `u64` type. */
90-
class U64 extends BuiltinType {
114+
class U64 extends IntegralTypeImpl {
91115
U64() { this.getName() = "u64" }
92116
}
93117

94118
/** The builtin `u128` type. */
95-
class U128 extends BuiltinType {
119+
class U128 extends IntegralTypeImpl {
96120
U128() { this.getName() = "u128" }
97121
}
98122

99123
/** The builtin `usize` type. */
100-
class Usize extends BuiltinType {
124+
class Usize extends IntegralTypeImpl {
101125
Usize() { this.getName() = "usize" }
102126
}
103127

104128
/** The builtin `isize` type. */
105-
class Isize extends BuiltinType {
129+
class Isize extends IntegralTypeImpl {
106130
Isize() { this.getName() = "isize" }
107131
}
108132

109133
/** The builtin `f32` type. */
110-
class F32 extends BuiltinType {
134+
class F32 extends FloatingPointTypeImpl {
111135
F32() { this.getName() = "f32" }
112136
}
113137

114138
/** The builtin `f64` type. */
115-
class F64 extends BuiltinType {
139+
class F64 extends FloatingPointTypeImpl {
116140
F64() { this.getName() = "f64" }
117141
}

0 commit comments

Comments
 (0)