|
| 1 | +/** |
| 2 | + * Provides a hierarchy of classes for modeling C/C++ types. |
| 3 | + */ |
| 4 | + |
1 | 5 | import semmle.code.cpp.Element |
2 | | -import semmle.code.cpp.Member |
3 | 6 | import semmle.code.cpp.Function |
4 | 7 | private import semmle.code.cpp.internal.ResolveClass |
5 | 8 |
|
@@ -1080,22 +1083,46 @@ class DerivedType extends Type, @derivedtype { |
1080 | 1083 |
|
1081 | 1084 | override Type stripType() { result = getBaseType().stripType() } |
1082 | 1085 |
|
1083 | | - predicate isAutoReleasing() { |
| 1086 | + /** |
| 1087 | + * Holds if this type has the `__autoreleasing` specifier or if it points to |
| 1088 | + * a type with the `__autoreleasing` specifier. |
| 1089 | + * |
| 1090 | + * DEPRECATED: use `hasSpecifier` directly instead. |
| 1091 | + */ |
| 1092 | + deprecated predicate isAutoReleasing() { |
1084 | 1093 | this.hasSpecifier("__autoreleasing") or |
1085 | 1094 | this.(PointerType).getBaseType().hasSpecifier("__autoreleasing") |
1086 | 1095 | } |
1087 | 1096 |
|
1088 | | - predicate isStrong() { |
| 1097 | + /** |
| 1098 | + * Holds if this type has the `__strong` specifier or if it points to |
| 1099 | + * a type with the `__strong` specifier. |
| 1100 | + * |
| 1101 | + * DEPRECATED: use `hasSpecifier` directly instead. |
| 1102 | + */ |
| 1103 | + deprecated predicate isStrong() { |
1089 | 1104 | this.hasSpecifier("__strong") or |
1090 | 1105 | this.(PointerType).getBaseType().hasSpecifier("__strong") |
1091 | 1106 | } |
1092 | 1107 |
|
1093 | | - predicate isUnsafeRetained() { |
| 1108 | + /** |
| 1109 | + * Holds if this type has the `__unsafe_unretained` specifier or if it points |
| 1110 | + * to a type with the `__unsafe_unretained` specifier. |
| 1111 | + * |
| 1112 | + * DEPRECATED: use `hasSpecifier` directly instead. |
| 1113 | + */ |
| 1114 | + deprecated predicate isUnsafeRetained() { |
1094 | 1115 | this.hasSpecifier("__unsafe_unretained") or |
1095 | 1116 | this.(PointerType).getBaseType().hasSpecifier("__unsafe_unretained") |
1096 | 1117 | } |
1097 | 1118 |
|
1098 | | - predicate isWeak() { |
| 1119 | + /** |
| 1120 | + * Holds if this type has the `__weak` specifier or if it points to |
| 1121 | + * a type with the `__weak` specifier. |
| 1122 | + * |
| 1123 | + * DEPRECATED: use `hasSpecifier` directly instead. |
| 1124 | + */ |
| 1125 | + deprecated predicate isWeak() { |
1099 | 1126 | this.hasSpecifier("__weak") or |
1100 | 1127 | this.(PointerType).getBaseType().hasSpecifier("__weak") |
1101 | 1128 | } |
@@ -1316,6 +1343,10 @@ class ArrayType extends DerivedType { |
1316 | 1343 |
|
1317 | 1344 | override string getCanonicalQLClass() { result = "ArrayType" } |
1318 | 1345 |
|
| 1346 | + /** |
| 1347 | + * Holds if this array is declared to be of a constant size. See |
| 1348 | + * `getArraySize` and `getByteSize` to get the size of the array. |
| 1349 | + */ |
1319 | 1350 | predicate hasArraySize() { arraysizes(underlyingElement(this), _, _, _) } |
1320 | 1351 |
|
1321 | 1352 | /** |
@@ -1568,12 +1599,21 @@ class RoutineType extends Type, @routinetype { |
1568 | 1599 |
|
1569 | 1600 | override string getName() { result = "..()(..)" } |
1570 | 1601 |
|
| 1602 | + /** |
| 1603 | + * Gets the type of the `n`th parameter to this routine. |
| 1604 | + */ |
1571 | 1605 | Type getParameterType(int n) { |
1572 | 1606 | routinetypeargs(underlyingElement(this), n, unresolveElement(result)) |
1573 | 1607 | } |
1574 | 1608 |
|
| 1609 | + /** |
| 1610 | + * Gets the type of a parameter to this routine. |
| 1611 | + */ |
1575 | 1612 | Type getAParameterType() { routinetypeargs(underlyingElement(this), _, unresolveElement(result)) } |
1576 | 1613 |
|
| 1614 | + /** |
| 1615 | + * Gets the return type of this routine. |
| 1616 | + */ |
1577 | 1617 | Type getReturnType() { routinetypes(underlyingElement(this), unresolveElement(result)) } |
1578 | 1618 |
|
1579 | 1619 | override string explain() { |
|
0 commit comments