@@ -18,9 +18,9 @@ import codingstandards.cpp.misra
18
18
import codingstandards.cpp.misra.BuiltInTypeRules
19
19
20
20
abstract class RelevantConversion extends Expr {
21
- abstract Type getFromType ( ) ;
21
+ abstract NumericType getFromType ( ) ;
22
22
23
- abstract Type getToType ( ) ;
23
+ abstract NumericType getToType ( ) ;
24
24
25
25
abstract Expr getConvertedExpr ( ) ;
26
26
@@ -40,9 +40,9 @@ abstract class RelevantRealConversion extends RelevantConversion, Conversion {
40
40
this .isImplicit ( )
41
41
}
42
42
43
- override Type getFromType ( ) { result = fromType }
43
+ override NumericType getFromType ( ) { result = fromType }
44
44
45
- override Type getToType ( ) { result = toType }
45
+ override NumericType getToType ( ) { result = toType }
46
46
47
47
override Expr getConvertedExpr ( ) { result = this .getExpr ( ) }
48
48
}
@@ -119,9 +119,9 @@ class ImpliedUsualArithmeticConversion extends RelevantConversion {
119
119
)
120
120
}
121
121
122
- override Type getFromType ( ) { result = fromType }
122
+ override NumericType getFromType ( ) { result = fromType }
123
123
124
- override Type getToType ( ) { result = toType }
124
+ override NumericType getToType ( ) { result = toType }
125
125
126
126
override Expr getConvertedExpr ( ) { result = this }
127
127
@@ -143,11 +143,11 @@ class ImpliedIntegerPromotion extends RelevantConversion {
143
143
fromType .getRealSize ( ) < sizeOfInt ( )
144
144
}
145
145
146
- override Type getFromType ( ) { result = fromType }
146
+ override NumericType getFromType ( ) { result = fromType }
147
147
148
- override IntegralType getToType ( ) {
148
+ override NumericType getToType ( ) {
149
149
// Only report the canonical type - e.g. `int` not `signed int`
150
- result = result .getCanonicalArithmeticType ( ) and
150
+ result = result .( IntegralType ) . getCanonicalArithmeticType ( ) and
151
151
if result instanceof Char16Type or result instanceof Char32Type or result instanceof Wchar_t
152
152
then
153
153
// Smallest type that can hold the value of the `fromType`
@@ -163,8 +163,6 @@ class ImpliedIntegerPromotion extends RelevantConversion {
163
163
candidateType order by candidateType .getIntegralUpperBound ( )
164
164
)
165
165
else (
166
- // The result is always `int` or `unsigned int`
167
- result instanceof IntType and
168
166
if
169
167
// If the `fromType` is signed, the result must be signed
170
168
fromType .getSignedness ( ) = Signed ( )
@@ -173,10 +171,12 @@ class ImpliedIntegerPromotion extends RelevantConversion {
173
171
// result must be signed as well.
174
172
fromType .getIntegralUpperBound ( ) <=
175
173
any ( IntType t | t .isSigned ( ) ) .( NumericType ) .getIntegralUpperBound ( )
176
- then result .isSigned ( )
174
+ then
175
+ // `int` is returned
176
+ result .( IntType ) .isSigned ( )
177
177
else
178
- // Otherwise an unsigned type is returned
179
- result .isUnsigned ( )
178
+ // Otherwise ` unsigned int` is returned
179
+ result .( IntType ) . isUnsigned ( )
180
180
)
181
181
}
182
182
0 commit comments