|
| 1 | +/** |
| 2 | + * Provides a hierarchy of classes for modelling C/C++ types. |
| 3 | + */ |
| 4 | + |
1 | 5 | import semmle.code.cpp.Element |
2 | 6 | import semmle.code.cpp.Member |
3 | 7 | import semmle.code.cpp.Function |
@@ -1080,21 +1084,37 @@ class DerivedType extends Type, @derivedtype { |
1080 | 1084 |
|
1081 | 1085 | override Type stripType() { result = getBaseType().stripType() } |
1082 | 1086 |
|
| 1087 | + /** |
| 1088 | + * Holds if this type has the `__autoreleasing` specifier or if it points to |
| 1089 | + * a type with the `__autoreleasing` specifier. |
| 1090 | + */ |
1083 | 1091 | predicate isAutoReleasing() { |
1084 | 1092 | this.hasSpecifier("__autoreleasing") or |
1085 | 1093 | this.(PointerType).getBaseType().hasSpecifier("__autoreleasing") |
1086 | 1094 | } |
1087 | 1095 |
|
| 1096 | + /** |
| 1097 | + * Holds if this type has the `__strong` specifier or if it points to |
| 1098 | + * a type with the `__strong` specifier. |
| 1099 | + */ |
1088 | 1100 | predicate isStrong() { |
1089 | 1101 | this.hasSpecifier("__strong") or |
1090 | 1102 | this.(PointerType).getBaseType().hasSpecifier("__strong") |
1091 | 1103 | } |
1092 | 1104 |
|
| 1105 | + /** |
| 1106 | + * Holds if this type has the `__unsafe_unretained` specifier or if it points |
| 1107 | + * to a type with the `__unsafe_unretained` specifier. |
| 1108 | + */ |
1093 | 1109 | predicate isUnsafeRetained() { |
1094 | 1110 | this.hasSpecifier("__unsafe_unretained") or |
1095 | 1111 | this.(PointerType).getBaseType().hasSpecifier("__unsafe_unretained") |
1096 | 1112 | } |
1097 | 1113 |
|
| 1114 | + /** |
| 1115 | + * Holds if this type has the `__weak` specifier or if it points to |
| 1116 | + * a type with the `__weak` specifier. |
| 1117 | + */ |
1098 | 1118 | predicate isWeak() { |
1099 | 1119 | this.hasSpecifier("__weak") or |
1100 | 1120 | this.(PointerType).getBaseType().hasSpecifier("__weak") |
@@ -1316,6 +1336,10 @@ class ArrayType extends DerivedType { |
1316 | 1336 |
|
1317 | 1337 | override string getCanonicalQLClass() { result = "ArrayType" } |
1318 | 1338 |
|
| 1339 | + /** |
| 1340 | + * Holds if this array is declared to be of a constant size. See |
| 1341 | + * `getArraySize` and `getByteSize` to get the size of the array. |
| 1342 | + */ |
1319 | 1343 | predicate hasArraySize() { arraysizes(underlyingElement(this), _, _, _) } |
1320 | 1344 |
|
1321 | 1345 | /** |
@@ -1568,12 +1592,21 @@ class RoutineType extends Type, @routinetype { |
1568 | 1592 |
|
1569 | 1593 | override string getName() { result = "..()(..)" } |
1570 | 1594 |
|
| 1595 | + /** |
| 1596 | + * Gets the type of the `n`th parameter to this routine. |
| 1597 | + */ |
1571 | 1598 | Type getParameterType(int n) { |
1572 | 1599 | routinetypeargs(underlyingElement(this), n, unresolveElement(result)) |
1573 | 1600 | } |
1574 | 1601 |
|
| 1602 | + /** |
| 1603 | + * Gets the type of a parameter to this routine. |
| 1604 | + */ |
1575 | 1605 | Type getAParameterType() { routinetypeargs(underlyingElement(this), _, unresolveElement(result)) } |
1576 | 1606 |
|
| 1607 | + /** |
| 1608 | + * Gets the return type of this routine. |
| 1609 | + */ |
1577 | 1610 | Type getReturnType() { routinetypes(underlyingElement(this), unresolveElement(result)) } |
1578 | 1611 |
|
1579 | 1612 | override string explain() { |
|
0 commit comments