Skip to content

Commit 2c0d06b

Browse files
committed
Make CanonicalIntegerType singular, use it more widely
1 parent feccaf7 commit 2c0d06b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

cpp/misra/src/codingstandards/cpp/misra/BuiltInTypeRules.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ predicate isUnsignedType(NumericType t) { t.getSignedness() = Unsigned() }
144144
/**
145145
* One of the 10 canonical integer types, which are the standard integer types.
146146
*/
147-
class CanonicalIntegerTypes extends NumericType, IntegralType {
148-
CanonicalIntegerTypes() { this = this.getCanonicalArithmeticType() }
147+
class CanonicalIntegerType extends NumericType, IntegralType {
148+
CanonicalIntegerType() { this = this.getCanonicalArithmeticType() }
149149
}
150150

151151
predicate isAssignment(Expr source, Type targetType, string context) {
@@ -264,14 +264,14 @@ predicate isPreConversionAssignment(Expr source, Type targetType, string context
264264
*
265265
* The type is determined by the signedness of the bit field and the number of bits.
266266
*/
267-
CanonicalIntegerTypes getBitFieldType(BitField bf) {
267+
CanonicalIntegerType getBitFieldType(BitField bf) {
268268
exists(NumericType bitfieldActualType |
269269
bitfieldActualType = bf.getType() and
270270
// Integral type with the same signedness as the bit field, and big enough to hold the bit field value
271271
result.getSignedness() = bitfieldActualType.getSignedness() and
272272
result.getSize() * 8 >= bf.getNumBits() and
273273
// No smaller integral type can hold the bit field value
274-
not exists(CanonicalIntegerTypes other |
274+
not exists(CanonicalIntegerType other |
275275
other.getSize() * 8 >= bf.getNumBits() and
276276
other.getSignedness() = result.getSignedness()
277277
|

cpp/misra/src/rules/RULE-7-0-5/NoSignednessChangeFromPromotion.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ class ImpliedIntegerPromotion extends RelevantConversion {
145145

146146
override NumericType getFromType() { result = fromType }
147147

148-
override NumericType getToType() {
148+
override CanonicalIntegerType getToType() {
149149
// Only report the canonical type - e.g. `int` not `signed int`
150-
result = result.(IntegralType).getCanonicalArithmeticType() and
151150
if result instanceof Char16Type or result instanceof Char32Type or result instanceof Wchar_t
152151
then
153152
// Smallest type that can hold the value of the `fromType`

0 commit comments

Comments
 (0)