@@ -93,8 +93,11 @@ newtype Signedness =
9393 * - Typedefs to built in types
9494 * - References to built in types
9595 * - Enum types with an explicit underlying type that is a built-in type.
96+ *
97+ * Note: this does not extend `Type` directly, to prevent accidental use of `getSize()`, which
98+ * returns the "wrong" size for e.g. reference types.
9699 */
97- class MisraBuiltInType extends Type {
100+ class MisraBuiltInType extends Element {
98101// The built in type underlying this MISRA built in type
99102BuiltInType builtInType ;
100103
@@ -108,6 +111,8 @@ class MisraBuiltInType extends Type{
108111TypeCategory getTypeCategory ( ) { result = getBuiltInTypeCategory ( builtInType ) }
109112
110113predicate isSameType ( MisraBuiltInType other ) { this .getBuiltInType ( ) = other .getBuiltInType ( ) }
114+
115+ string getName ( ) { result = this .( Type ) .getName ( ) }
111116}
112117
113118class CharacterType extends MisraBuiltInType {
@@ -298,13 +303,13 @@ CanonicalIntegerNumericType getBitFieldType(BitField bf){
298303bitfieldActualType = bf .getType ( ) and
299304// Integral type with the same signedness as the bit field, and big enough to hold the bit field value
300305result .getSignedness ( ) = bitfieldActualType .getSignedness ( ) and
301- result .getSize ( ) * 8 >= bf .getNumBits ( ) and
306+ result .getBuiltInSize ( ) * 8 >= bf .getNumBits ( ) and
302307// No smaller integral type can hold the bit field value
303308not exists ( CanonicalIntegerNumericType other |
304- other .getSize ( ) * 8 >= bf .getNumBits ( ) and
309+ other .getBuiltInSize ( ) * 8 >= bf .getNumBits ( ) and
305310other .getSignedness ( ) = result .getSignedness ( )
306311|
307- other .getSize ( ) < result .getBuiltInSize ( )
312+ other .getBuiltInSize ( ) < result .getBuiltInSize ( )
308313)
309314)
310315}
0 commit comments