@@ -92,8 +92,9 @@ class Type extends Locatable, @type {
9292 /**
9393 * Gets this type after typedefs have been resolved.
9494 *
95- * The result of this predicate will be the type itself, except in the case of a TypedefType or a Decltype,
96- * in which case the result will be type which results from (possibly recursively) resolving typedefs.
95+ * The result of this predicate will be the type itself, except in the case of a TypedefType, a Decltype,
96+ * or a TypeofType, in which case the result will be type which results from (possibly recursively)
97+ * resolving typedefs.
9798 */
9899 pragma [ nomagic]
99100 Type getUnderlyingType ( ) { result = this }
@@ -1117,18 +1118,20 @@ class DerivedType extends Type, @derivedtype {
11171118 * decltype(a) b;
11181119 * ```
11191120 */
1120- class Decltype extends Type , @decltype {
1121+ class Decltype extends Type {
1122+ Decltype ( ) { decltypes ( underlyingElement ( this ) , _, 0 , _, _) }
1123+
11211124 override string getAPrimaryQlClass ( ) { result = "Decltype" }
11221125
11231126 /**
1124- * The expression whose type is being obtained by this decltype.
1127+ * Gets the expression whose type is being obtained by this decltype.
11251128 */
1126- Expr getExpr ( ) { decltypes ( underlyingElement ( this ) , unresolveElement ( result ) , _, _) }
1129+ Expr getExpr ( ) { decltypes ( underlyingElement ( this ) , unresolveElement ( result ) , _, _, _ ) }
11271130
11281131 /**
1129- * The type immediately yielded by this decltype.
1132+ * Gets the type immediately yielded by this decltype.
11301133 */
1131- Type getBaseType ( ) { decltypes ( underlyingElement ( this ) , _, unresolveElement ( result ) , _) }
1134+ Type getBaseType ( ) { decltypes ( underlyingElement ( this ) , _, _ , unresolveElement ( result ) , _) }
11321135
11331136 /**
11341137 * Whether an extra pair of parentheses around the expression would change the semantics of this decltype.
@@ -1142,7 +1145,7 @@ class Decltype extends Type, @decltype {
11421145 * ```
11431146 * Please consult the C++11 standard for more details.
11441147 */
1145- predicate parenthesesWouldChangeMeaning ( ) { decltypes ( underlyingElement ( this ) , _, _, true ) }
1148+ predicate parenthesesWouldChangeMeaning ( ) { decltypes ( underlyingElement ( this ) , _, _, _ , true ) }
11461149
11471150 override Type getUnderlyingType ( ) { result = this .getBaseType ( ) .getUnderlyingType ( ) }
11481151
@@ -1183,6 +1186,211 @@ class Decltype extends Type, @decltype {
11831186 }
11841187}
11851188
1189+ /**
1190+ * An instance of the C23 `typeof` operator. For example:
1191+ * ```
1192+ * int a;
1193+ * typeof(a) b;
1194+ * ```
1195+ */
1196+ class TypeofType extends Type {
1197+ TypeofType ( ) {
1198+ decltypes ( underlyingElement ( this ) , _, 1 , _, _) or
1199+ type_operators ( underlyingElement ( this ) , _, 0 , _)
1200+ }
1201+
1202+ Type getBaseType ( ) {
1203+ decltypes ( underlyingElement ( this ) , _, _, unresolveElement ( result ) , _)
1204+ or
1205+ type_operators ( underlyingElement ( this ) , _, _, unresolveElement ( result ) )
1206+ }
1207+
1208+ override Type getUnderlyingType ( ) { result = this .getBaseType ( ) .getUnderlyingType ( ) }
1209+
1210+ override Type stripTopLevelSpecifiers ( ) { result = this .getBaseType ( ) .stripTopLevelSpecifiers ( ) }
1211+
1212+ override Type stripType ( ) { result = this .getBaseType ( ) .stripType ( ) }
1213+
1214+ override Type resolveTypedefs ( ) { result = this .getBaseType ( ) .resolveTypedefs ( ) }
1215+
1216+ override string toString ( ) { result = "typeof(...)" }
1217+
1218+ override string getName ( ) { none ( ) }
1219+
1220+ override int getSize ( ) { result = this .getBaseType ( ) .getSize ( ) }
1221+
1222+ override int getAlignment ( ) { result = this .getBaseType ( ) .getAlignment ( ) }
1223+
1224+ override int getPointerIndirectionLevel ( ) {
1225+ result = this .getBaseType ( ) .getPointerIndirectionLevel ( )
1226+ }
1227+
1228+ override string explain ( ) {
1229+ result = "typeof resulting in {" + this .getBaseType ( ) .explain ( ) + "}"
1230+ }
1231+
1232+ override predicate involvesReference ( ) { this .getBaseType ( ) .involvesReference ( ) }
1233+
1234+ override predicate involvesTemplateParameter ( ) { this .getBaseType ( ) .involvesTemplateParameter ( ) }
1235+
1236+ override predicate isDeeplyConst ( ) { this .getBaseType ( ) .isDeeplyConst ( ) }
1237+
1238+ override predicate isDeeplyConstBelow ( ) { this .getBaseType ( ) .isDeeplyConstBelow ( ) }
1239+
1240+ override Specifier internal_getAnAdditionalSpecifier ( ) {
1241+ result = this .getBaseType ( ) .getASpecifier ( )
1242+ }
1243+ }
1244+
1245+ /**
1246+ * An instance of the C23 `typeof` or `typeof_unqual` operator taking an expression
1247+ * as its argument. For example:
1248+ * ```
1249+ * int a;
1250+ * typeof(a) b;
1251+ * ```
1252+ */
1253+ class TypeofExprType extends TypeofType {
1254+ TypeofExprType ( ) { decltypes ( underlyingElement ( this ) , _, 1 , _, _) }
1255+
1256+ override string getAPrimaryQlClass ( ) { result = "TypeofExprType" }
1257+
1258+ /**
1259+ * Gets the expression whose type is being obtained by this typeof.
1260+ */
1261+ Expr getExpr ( ) { decltypes ( underlyingElement ( this ) , unresolveElement ( result ) , _, _, _) }
1262+
1263+ override Location getLocation ( ) { result = this .getExpr ( ) .getLocation ( ) }
1264+ }
1265+
1266+ /**
1267+ * A type obtained by C23 `typeof` or `typeof_unqual` operator taking a type as its
1268+ * argument. For example:
1269+ * ```
1270+ * typeof_unqual(const int) b;
1271+ * ```
1272+ */
1273+ class TypeofTypeType extends TypeofType {
1274+ TypeofTypeType ( ) { type_operators ( underlyingElement ( this ) , _, 0 , _) }
1275+
1276+ /**
1277+ * Gets the expression whose type is being obtained by this typeof.
1278+ */
1279+ Type getType ( ) { type_operators ( underlyingElement ( this ) , unresolveElement ( result ) , _, _) }
1280+
1281+ override string getAPrimaryQlClass ( ) { result = "TypeofTypeType" }
1282+
1283+ override string toString ( ) { result = "typeof(...)" }
1284+ }
1285+
1286+ /**
1287+ * A type obtained by applying a type transforming intrinsic. For example:
1288+ * ```
1289+ * __make_unsigned(int) x;
1290+ * ```
1291+ */
1292+ class IntrinsicTransformedType extends Type {
1293+ int intrinsic ;
1294+
1295+ IntrinsicTransformedType ( ) {
1296+ type_operators ( underlyingElement ( this ) , _, intrinsic , _) and
1297+ intrinsic in [ 1 .. 19 ]
1298+ }
1299+
1300+ override string getAPrimaryQlClass ( ) { result = "IntrinsicTransformedType" }
1301+
1302+ override string toString ( ) { result = this .getIntrinsicName ( ) + "(...)" }
1303+
1304+ /**
1305+ * Gets the type immediately yielded by this transformation.
1306+ */
1307+ Type getBaseType ( ) { type_operators ( underlyingElement ( this ) , _, _, unresolveElement ( result ) ) }
1308+
1309+ /**
1310+ * Gets the type that is transformed.
1311+ */
1312+ Type getType ( ) { type_operators ( underlyingElement ( this ) , unresolveElement ( result ) , _, _) }
1313+
1314+ /**
1315+ * Gets the name of the intrinsic used to transform the type.
1316+ */
1317+ string getIntrinsicName ( ) {
1318+ intrinsic = 1 and result = "__underlying_type"
1319+ or
1320+ intrinsic = 2 and result = "__bases"
1321+ or
1322+ intrinsic = 3 and result = "__direct_bases"
1323+ or
1324+ intrinsic = 4 and result = "__add_lvalue_reference"
1325+ or
1326+ intrinsic = 5 and result = "__add_pointer"
1327+ or
1328+ intrinsic = 6 and result = "__add_rvalue_reference"
1329+ or
1330+ intrinsic = 7 and result = "__decay"
1331+ or
1332+ intrinsic = 8 and result = "__make_signed"
1333+ or
1334+ intrinsic = 9 and result = "__make_unsigned"
1335+ or
1336+ intrinsic = 10 and result = "__remove_all_extents"
1337+ or
1338+ intrinsic = 11 and result = "__remove_const"
1339+ or
1340+ intrinsic = 12 and result = "__remove_cv"
1341+ or
1342+ intrinsic = 13 and result = "__remove_cvref"
1343+ or
1344+ intrinsic = 14 and result = "__remove_extent"
1345+ or
1346+ intrinsic = 15 and result = "__remove_pointer"
1347+ or
1348+ intrinsic = 16 and result = "__remove_reference_t"
1349+ or
1350+ intrinsic = 17 and result = "__remove_restrict"
1351+ or
1352+ intrinsic = 18 and result = "__remove_volatile"
1353+ or
1354+ intrinsic = 19 and result = "__remove_reference"
1355+ }
1356+
1357+ override Type getUnderlyingType ( ) { result = this .getBaseType ( ) .getUnderlyingType ( ) }
1358+
1359+ override Type stripTopLevelSpecifiers ( ) { result = this .getBaseType ( ) .stripTopLevelSpecifiers ( ) }
1360+
1361+ override Type stripType ( ) { result = this .getBaseType ( ) .stripType ( ) }
1362+
1363+ override Type resolveTypedefs ( ) { result = this .getBaseType ( ) .resolveTypedefs ( ) }
1364+
1365+ override string getName ( ) { none ( ) }
1366+
1367+ override int getSize ( ) { result = this .getBaseType ( ) .getSize ( ) }
1368+
1369+ override int getAlignment ( ) { result = this .getBaseType ( ) .getAlignment ( ) }
1370+
1371+ override int getPointerIndirectionLevel ( ) {
1372+ result = this .getBaseType ( ) .getPointerIndirectionLevel ( )
1373+ }
1374+
1375+ override string explain ( ) {
1376+ result =
1377+ "application of " + this .getIntrinsicName ( ) + " resulting in {" + this .getBaseType ( ) .explain ( )
1378+ + "}"
1379+ }
1380+
1381+ override predicate involvesReference ( ) { this .getBaseType ( ) .involvesReference ( ) }
1382+
1383+ override predicate involvesTemplateParameter ( ) { this .getBaseType ( ) .involvesTemplateParameter ( ) }
1384+
1385+ override predicate isDeeplyConst ( ) { this .getBaseType ( ) .isDeeplyConst ( ) }
1386+
1387+ override predicate isDeeplyConstBelow ( ) { this .getBaseType ( ) .isDeeplyConstBelow ( ) }
1388+
1389+ override Specifier internal_getAnAdditionalSpecifier ( ) {
1390+ result = this .getBaseType ( ) .getASpecifier ( )
1391+ }
1392+ }
1393+
11861394/**
11871395 * A C/C++ pointer type. See 4.9.1.
11881396 * ```
0 commit comments