Skip to content

Commit f2ef088

Browse files
authored
Merge pull request #3783 from geoffw0/qldoc2
C++: More QLDoc
2 parents b24fba8 + b515c09 commit f2ef088

File tree

9 files changed

+97
-9
lines changed

9 files changed

+97
-9
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import semmle.code.cpp.Location
6-
import semmle.code.cpp.Member
76
import semmle.code.cpp.Class
87
import semmle.code.cpp.Parameter
98
import semmle.code.cpp.exprs.Call

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
/**
2+
* DEPRECATED: import `semmle.code.cpp.Element` and/or `semmle.code.cpp.Type` directly as required.
3+
*/
4+
15
import semmle.code.cpp.Element
26
import semmle.code.cpp.Type

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides classes for working with name qualifiers such as the `N::` in
3+
* `N::f()`.
4+
*/
5+
16
import cpp
27

38
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides classes for modeling namespaces, `using` directives and `using` declarations.
3+
*/
4+
15
import semmle.code.cpp.Element
26
import semmle.code.cpp.Type
37
import semmle.code.cpp.metrics.MetricNamespace

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides a class for reasoning about nested field accesses, for example
3+
* the access `myLine.start.x`.
4+
*/
5+
16
import cpp
27

38
/**
@@ -25,7 +30,7 @@ private Expr getUltimateQualifier(FieldAccess fa) {
2530
}
2631

2732
/**
28-
* Accesses to nested fields.
33+
* A nested field access, for example the access `myLine.start.x`.
2934
*/
3035
class NestedFieldAccess extends FieldAccess {
3136
Expr ultimateQualifier;
@@ -35,6 +40,30 @@ class NestedFieldAccess extends FieldAccess {
3540
getTarget() = getANestedField(ultimateQualifier.getType().stripType())
3641
}
3742

38-
/** Gets the ultimate qualifier of this nested field access. */
43+
/**
44+
* Gets the outermost qualifier of this nested field access. In the
45+
* following example, the access to `myLine.start.x` has outermost qualifier
46+
* `myLine`:
47+
* ```
48+
* struct Point
49+
* {
50+
* float x, y;
51+
* };
52+
*
53+
* struct Line
54+
* {
55+
* Point start, end;
56+
* };
57+
*
58+
* void init()
59+
* {
60+
* Line myLine;
61+
*
62+
* myLine.start.x = 0.0f;
63+
*
64+
* // ...
65+
* }
66+
* ```
67+
*/
3968
Expr getUltimateQualifier() { result = ultimateQualifier }
4069
}

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

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/**
2+
* Provides a hierarchy of classes for modeling C/C++ types.
3+
*/
4+
15
import semmle.code.cpp.Element
2-
import semmle.code.cpp.Member
36
import semmle.code.cpp.Function
47
private import semmle.code.cpp.internal.ResolveClass
58

@@ -1080,22 +1083,46 @@ class DerivedType extends Type, @derivedtype {
10801083

10811084
override Type stripType() { result = getBaseType().stripType() }
10821085

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() {
10841093
this.hasSpecifier("__autoreleasing") or
10851094
this.(PointerType).getBaseType().hasSpecifier("__autoreleasing")
10861095
}
10871096

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() {
10891104
this.hasSpecifier("__strong") or
10901105
this.(PointerType).getBaseType().hasSpecifier("__strong")
10911106
}
10921107

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() {
10941115
this.hasSpecifier("__unsafe_unretained") or
10951116
this.(PointerType).getBaseType().hasSpecifier("__unsafe_unretained")
10961117
}
10971118

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() {
10991126
this.hasSpecifier("__weak") or
11001127
this.(PointerType).getBaseType().hasSpecifier("__weak")
11011128
}
@@ -1316,6 +1343,10 @@ class ArrayType extends DerivedType {
13161343

13171344
override string getCanonicalQLClass() { result = "ArrayType" }
13181345

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

13211352
/**
@@ -1568,12 +1599,21 @@ class RoutineType extends Type, @routinetype {
15681599

15691600
override string getName() { result = "..()(..)" }
15701601

1602+
/**
1603+
* Gets the type of the `n`th parameter to this routine.
1604+
*/
15711605
Type getParameterType(int n) {
15721606
routinetypeargs(underlyingElement(this), n, unresolveElement(result))
15731607
}
15741608

1609+
/**
1610+
* Gets the type of a parameter to this routine.
1611+
*/
15751612
Type getAParameterType() { routinetypeargs(underlyingElement(this), _, unresolveElement(result)) }
15761613

1614+
/**
1615+
* Gets the return type of this routine.
1616+
*/
15771617
Type getReturnType() { routinetypes(underlyingElement(this), unresolveElement(result)) }
15781618

15791619
override string explain() {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import semmle.code.cpp.Declaration
22
import semmle.code.cpp.Type
3-
import semmle.code.cpp.Member
43
import semmle.code.cpp.Function
54
private import semmle.code.cpp.internal.ResolveClass
65

cpp/ql/src/semmle/code/cpp/stmts/Block.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides a class to model C/C++ block statements, enclosed by `{` and `}`.
3+
*/
4+
15
import semmle.code.cpp.Element
26
import semmle.code.cpp.stmts.Stmt
37

cpp/ql/src/semmle/code/cpp/stmts/Stmt.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides a hierarchy of classes for modeling C/C++ statements.
3+
*/
4+
15
import semmle.code.cpp.Element
26
private import semmle.code.cpp.Enclosing
37
private import semmle.code.cpp.internal.ResolveClass

0 commit comments

Comments
 (0)