Skip to content

Commit e43ddd3

Browse files
committed
C++: QLDoc Type.qll.
1 parent 6bcc1a0 commit e43ddd3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

cpp/ql/src/semmle/code/cpp/Type.qll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides a hierarchy of classes for modelling C/C++ types.
3+
*/
4+
15
import semmle.code.cpp.Element
26
import semmle.code.cpp.Member
37
import semmle.code.cpp.Function
@@ -1080,21 +1084,37 @@ class DerivedType extends Type, @derivedtype {
10801084

10811085
override Type stripType() { result = getBaseType().stripType() }
10821086

1087+
/**
1088+
* Holds if this type has the `__autoreleasing` specifier or if it points to
1089+
* a type with the `__autoreleasing` specifier.
1090+
*/
10831091
predicate isAutoReleasing() {
10841092
this.hasSpecifier("__autoreleasing") or
10851093
this.(PointerType).getBaseType().hasSpecifier("__autoreleasing")
10861094
}
10871095

1096+
/**
1097+
* Holds if this type has the `__strong` specifier or if it points to
1098+
* a type with the `__strong` specifier.
1099+
*/
10881100
predicate isStrong() {
10891101
this.hasSpecifier("__strong") or
10901102
this.(PointerType).getBaseType().hasSpecifier("__strong")
10911103
}
10921104

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+
*/
10931109
predicate isUnsafeRetained() {
10941110
this.hasSpecifier("__unsafe_unretained") or
10951111
this.(PointerType).getBaseType().hasSpecifier("__unsafe_unretained")
10961112
}
10971113

1114+
/**
1115+
* Holds if this type has the `__weak` specifier or if it points to
1116+
* a type with the `__weak` specifier.
1117+
*/
10981118
predicate isWeak() {
10991119
this.hasSpecifier("__weak") or
11001120
this.(PointerType).getBaseType().hasSpecifier("__weak")
@@ -1316,6 +1336,10 @@ class ArrayType extends DerivedType {
13161336

13171337
override string getCanonicalQLClass() { result = "ArrayType" }
13181338

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+
*/
13191343
predicate hasArraySize() { arraysizes(underlyingElement(this), _, _, _) }
13201344

13211345
/**
@@ -1568,12 +1592,21 @@ class RoutineType extends Type, @routinetype {
15681592

15691593
override string getName() { result = "..()(..)" }
15701594

1595+
/**
1596+
* Gets the type of the `n`th parameter to this routine.
1597+
*/
15711598
Type getParameterType(int n) {
15721599
routinetypeargs(underlyingElement(this), n, unresolveElement(result))
15731600
}
15741601

1602+
/**
1603+
* Gets the type of a parameter to this routine.
1604+
*/
15751605
Type getAParameterType() { routinetypeargs(underlyingElement(this), _, unresolveElement(result)) }
15761606

1607+
/**
1608+
* Gets the return type of this routine.
1609+
*/
15771610
Type getReturnType() { routinetypes(underlyingElement(this), unresolveElement(result)) }
15781611

15791612
override string explain() {

0 commit comments

Comments
 (0)