Skip to content

Commit 8896fa5

Browse files
Merge pull request github#1924 from geoffw0/quickfix
CPP: Tiny qldoc fixes.
2 parents 70caa9b + 3df31e6 commit 8896fa5

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

cpp/ql/src/jsf/4.10 Classes/AV Rule 81.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ReferenceCopyAssignmentOperator extends MemberFunction {
5151

5252
/**
5353
* A call to a function called swap. Note: could be a member,
54-
* std::swap or a function overloading std::swap (not in std::)
54+
* `std::swap` or a function overloading `std::swap` (not in `std::`)
5555
* so keep it simple
5656
*/
5757
FunctionCall getASwapCall() {

cpp/ql/src/jsf/4.21 Operators/AV Rule 159.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/*
1212
* See More Effective C++ item 7.
13-
* Note: Meyers allows unary & to be overloaded but not comma
13+
* Note: Meyers allows unary `&` to be overloaded but not comma.
1414
*/
1515

1616
import cpp

cpp/ql/src/jsf/4.28 Portable Code/AV Rule 213.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import cpp
1515
/*
1616
* Interpretation and deviations:
1717
* - if the higher operator has precedence > arithmetic then it is fine
18-
* RATIONALE: exprs like f(), *x, &x are easily understood to bind tightly
18+
* RATIONALE: exprs like `f()`, `*x`, `&x` are easily understood to bind tightly
1919
* - if the higher operator is the RHS of an assign then it is fine
2020
* RATIONALE: cf. MISRA, too many cases excluded otherwise
2121
* - comparison operators can be mixed with arithmetic
22-
* RATIONALE: x==y+z is common and unambiguous
22+
* RATIONALE: `x==y+z` is common and unambiguous
2323
*/
2424

2525
predicate arithmeticPrecedence(int p) { p = 12 or p = 13 }

cpp/ql/src/semmle/code/cpp/controlflow/Guards.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private predicate compares_eq(
156156

157157
/**
158158
* If `test => part` and `part => left == right + k` then `test => left == right + k`.
159-
* Similarly for the case where `test` is false.
159+
* Similarly for the case where `test` is false.
160160
*/
161161
private predicate logical_comparison_eq(
162162
BinaryLogicalOperation test, Expr left, Expr right, int k, boolean areEqual, boolean testIsTrue
@@ -275,7 +275,7 @@ private predicate compares_ge(
275275

276276
/**
277277
* If `test => part` and `part => left < right + k` then `test => left < right + k`.
278-
* Similarly for the case where `test` evaluates false.
278+
* Similarly for the case where `test` evaluates false.
279279
*/
280280
private predicate logical_comparison_lt(
281281
BinaryLogicalOperation test, Expr left, Expr right, int k, boolean isLt, boolean testIsTrue
@@ -362,7 +362,7 @@ private predicate add_lt(
362362
)
363363
}
364364

365-
/** The int value of integer constant expression. */
365+
/** The `int` value of integer constant expression. */
366366
private int int_value(Expr e) {
367367
e.getUnderlyingType() instanceof IntegralType and
368368
result = e.getValue().toInt()

cpp/ql/src/semmle/code/cpp/controlflow/SSA.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class SsaDefinition extends ControlFlowNodeBase {
2929

3030
/**
3131
* Gets a string representation of the SSA variable represented by the pair
32-
* (this, v).
32+
* `(this, v)`.
3333
*/
3434
string toString(LocalScopeVariable v) { exists(StandardSSA x | result = x.toString(this, v)) }
3535

36-
/** Gets a use of the SSA variable represented by the pair (this, v). */
36+
/** Gets a use of the SSA variable represented by the pair `(this, v)`. */
3737
VariableAccess getAUse(LocalScopeVariable v) {
3838
exists(StandardSSA x | result = x.getAUse(this, v))
3939
}

cpp/ql/src/semmle/code/cpp/padding/Padding.qll

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import cpp
22

33
/**
44
* Align the specified offset up to the specified alignment boundary.
5-
* The result is the smallest integer i such that (i % alignment) = 0
6-
* and (i >= offset)
5+
* The result is the smallest integer `i` such that `(i % alignment) = 0`
6+
* and `(i >= offset)`.
77
*/
88
bindingset[offset, alignment]
99
private int alignUp(int offset, int alignment) {
@@ -30,16 +30,16 @@ abstract class Architecture extends string {
3030
/** Gets the size of a pointer, in bits. */
3131
abstract int pointerSize();
3232

33-
/** Gets the size of a 'long int', in bits. */
33+
/** Gets the size of a `long int`, in bits. */
3434
abstract int longSize();
3535

36-
/** Gets the size of a 'long double', in bits. */
36+
/** Gets the size of a `long double`, in bits. */
3737
abstract int longDoubleSize();
3838

39-
/** Gets the size of a 'long long', in bits. */
39+
/** Gets the size of a `long long`, in bits. */
4040
abstract int longLongSize();
4141

42-
/** Gets the size of a 'wchar_t', in bits. */
42+
/** Gets the size of a `wchar_t`, in bits. */
4343
abstract int wideCharSize();
4444

4545
/** Gets the alignment boundary for doubles, in bits. */
@@ -479,8 +479,10 @@ class PaddedType extends Class {
479479
int typeBitSize(Architecture arch) {
480480
if this instanceof Union
481481
then
482-
// A correct implementation for unions would be
482+
// A correct implementation for unions would be:
483+
// ```
483484
// result = max(fieldSize(_, arch))
485+
// ```
484486
// but that uses a recursive aggregate, which isn't supported in
485487
// QL. We therefore use this slightly more complex implementation
486488
// instead.

cpp/ql/src/semmle/code/cpp/rangeanalysis/RangeSSA.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This library is a clone of semmle.code.cpp.controlflow.SSA, with
33
* only one difference: extra phi definitions are added after
44
* guards. For example:
5-
*
5+
* ```
66
* x = f();
77
* if (x < 10) {
88
* // Block 1
@@ -11,12 +11,12 @@
1111
* // Block 2
1212
* ...
1313
* }
14-
*
14+
* ```
1515
* In standard SSA, basic blocks 1 and 2 do not need phi definitions
16-
* for x, because they are dominated by the definition of x on the
17-
* first line. In RangeSSA, however, we add phi definitions for x at
16+
* for `x`, because they are dominated by the definition of `x` on the
17+
* first line. In RangeSSA, however, we add phi definitions for `x` at
1818
* the beginning of blocks 1 and 2. This is useful for range analysis
19-
* because it enables us to deduce a more accurate range for x in the
19+
* because it enables us to deduce a more accurate range for `x` in the
2020
* two branches of the if-statement.
2121
*/
2222

@@ -74,19 +74,19 @@ class RangeSsaDefinition extends ControlFlowNodeBase {
7474

7575
/**
7676
* A string representation of the SSA variable represented by the pair
77-
* (this, v).
77+
* `(this, v)`.
7878
*/
7979
string toString(LocalScopeVariable v) { exists(RangeSSA x | result = x.toString(this, v)) }
8080

81-
/** Gets a use of the SSA variable represented by the pair (this, v) */
81+
/** Gets a use of the SSA variable represented by the pair `(this, v)`. */
8282
VariableAccess getAUse(LocalScopeVariable v) { exists(RangeSSA x | result = x.getAUse(this, v)) }
8383

84-
/** Gets the control flow node for this definition */
84+
/** Gets the control flow node for this definition. */
8585
ControlFlowNode getDefinition() { result = this }
8686

8787
BasicBlock getBasicBlock() { result.contains(getDefinition()) }
8888

89-
/** Whether this definition is a phi node for variable v */
89+
/** Whether this definition is a phi node for variable `v`. */
9090
predicate isPhiNode(LocalScopeVariable v) {
9191
exists(RangeSSA x | x.phi_node(v, this.(BasicBlock)))
9292
}
@@ -136,7 +136,7 @@ class RangeSsaDefinition extends ControlFlowNodeBase {
136136
)
137137
}
138138

139-
/** Gets the expression assigned to this SsaDefinition */
139+
/** Gets the expression assigned to this SsaDefinition. */
140140
Expr getDefiningValue(LocalScopeVariable v) {
141141
exists(ControlFlowNode def | def = this.getDefinition() |
142142
def = v.getInitializer().getExpr() and def = result

0 commit comments

Comments
 (0)