Skip to content

Commit 5199829

Browse files
committed
C++: Fix some Ql4Ql violations.
1 parent 3185298 commit 5199829

File tree

33 files changed

+111
-85
lines changed

33 files changed

+111
-85
lines changed

cpp/ql/lib/Options.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CustomOptions extends Options {
3535
override predicate returnsNull(Call call) { Options.super.returnsNull(call) }
3636

3737
/**
38-
* Holds if a call to this function will never return.
38+
* Holds if a call to the function `f` will never return.
3939
*
4040
* By default, this holds for `exit`, `_exit`, `abort`, `__assert_fail`,
4141
* `longjmp`, `error`, `__builtin_unreachable` and any function with a

cpp/ql/lib/experimental/semmle/code/cpp/rangeanalysis/RangeAnalysis.qll

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,11 @@ private predicate boundFlowStep(Instruction i, NonPhiOperand op, int delta, bool
298298
else
299299
if strictlyNegative(x)
300300
then upper = true and delta = -1
301-
else
302-
if negative(x)
303-
then upper = true and delta = 0
304-
else none()
301+
else (
302+
negative(x) and
303+
upper = true and
304+
delta = 0
305+
)
305306
)
306307
or
307308
exists(Operand x |
@@ -321,10 +322,11 @@ private predicate boundFlowStep(Instruction i, NonPhiOperand op, int delta, bool
321322
else
322323
if strictlyNegative(x)
323324
then upper = false and delta = 1
324-
else
325-
if negative(x)
326-
then upper = false and delta = 0
327-
else none()
325+
else (
326+
negative(x) and
327+
upper = false and
328+
delta = 0
329+
)
328330
)
329331
or
330332
i.(RemInstruction).getRightOperand() = op and positive(op) and delta = -1 and upper = true

cpp/ql/lib/semmle/code/cpp/Concept.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class ConceptIdExpr extends Expr, @concept_id {
198198
final Locatable getATemplateArgumentKind() { result = this.getTemplateArgumentKind(_) }
199199

200200
/**
201-
* Gets the `i`th template argument passed to the concept.
201+
* Gets template argument at index `index` passed to the concept, if any.
202202
*
203203
* For example, if:
204204
* ```cpp
@@ -219,7 +219,7 @@ class ConceptIdExpr extends Expr, @concept_id {
219219
}
220220

221221
/**
222-
* Gets the kind of the `i`th template argument value passed to the concept.
222+
* Gets the kind of the template argument value at index `index` passed to the concept, if any.
223223
*
224224
* For example, if:
225225
* ```cpp

cpp/ql/lib/semmle/code/cpp/Declaration.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ class Declaration extends Locatable, @declaration {
223223
final Locatable getATemplateArgumentKind() { result = this.getTemplateArgumentKind(_) }
224224

225225
/**
226-
* Gets the `i`th template argument used to instantiate this declaration from a
227-
* template.
226+
* Gets the template argument at index `index` used to instantiate this declaration from a
227+
* template, if any.
228228
*
229229
* For example:
230230
*
@@ -245,9 +245,9 @@ class Declaration extends Locatable, @declaration {
245245
}
246246

247247
/**
248-
* Gets the `i`th template argument value used to instantiate this declaration
249-
* from a template. When called on a template, this will return the `i`th template
250-
* parameter value if it exists.
248+
* Gets the template argument value at index `index` used to instantiate this declaration
249+
* from a template. When called on a template, this will return the template
250+
* parameter value at index `index` if it exists.
251251
*
252252
* For example:
253253
*

cpp/ql/lib/semmle/code/cpp/commons/Printf.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ class FormatLiteral extends Literal instanceof StringLiteral {
877877
}
878878

879879
/**
880-
* Gets the char type required by the nth conversion specifier.
880+
* Gets the char type required by the `n`th conversion specifier.
881881
* - in the base case this is the default for the formatting function
882882
* (e.g. `char` for `printf`, `char` or `wchar_t` for `wprintf`).
883883
* - the `%C` format character reverses wideness.
@@ -922,7 +922,7 @@ class FormatLiteral extends Literal instanceof StringLiteral {
922922
}
923923

924924
/**
925-
* Gets the string type required by the nth conversion specifier.
925+
* Gets the string type required by the `n`th conversion specifier.
926926
* - in the base case this is the default for the formatting function
927927
* (e.g. `char *` for `printf`, `char *` or `wchar_t *` for `wprintf`).
928928
* - the `%S` format character reverses wideness on some platforms.

cpp/ql/lib/semmle/code/cpp/controlflow/Dominance.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ predicate postDominates(ControlFlowNode postDominator, ControlFlowNode node) {
101101
*/
102102

103103
/**
104-
* Holds if `dominator` is an immediate dominator of `node` in the control-flow
104+
* Holds if `dom` is an immediate dominator of `node` in the control-flow
105105
* graph of basic blocks.
106106
*/
107107
predicate bbIDominates(BasicBlock dom, BasicBlock node) =
@@ -117,7 +117,7 @@ private predicate bb_predecessor(BasicBlock succ, BasicBlock pred) { bb_successo
117117
private predicate bb_exit(ExitBasicBlock exit) { any() }
118118

119119
/**
120-
* Holds if `postDominator` is an immediate post-dominator of `node` in the control-flow
120+
* Holds if `pDom` is an immediate post-dominator of `node` in the control-flow
121121
* graph of basic blocks.
122122
*/
123123
predicate bbIPostDominates(BasicBlock pDom, BasicBlock node) =

cpp/ql/lib/semmle/code/cpp/controlflow/internal/CFG.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,8 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
10421042
* - `MicrosoftTryFinallyStmt`: On the edge following the `__finally` block for
10431043
* the case where an exception was thrown and needs to be propagated.
10441044
*/
1045-
DestructorCall getSynthesisedDestructorCallAfterNode(Node n, int i) {
1046-
synthetic_destructor_call(n, i, result)
1045+
DestructorCall getSynthesisedDestructorCallAfterNode(Node node, int index) {
1046+
synthetic_destructor_call(node, index, result)
10471047
}
10481048

10491049
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ class ContentSet instanceof Content {
829829

830830
/**
831831
* Holds if this element is at the specified location.
832-
* The location spans column `startcolumn` of line `startline` to
833-
* column `endcolumn` of line `endline` in file `filepath`.
832+
* The location spans column `sc` of line `sl` to
833+
* column `ec` of line `el` in file `path`.
834834
* For more information, see
835835
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
836836
*/

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,8 +2268,8 @@ class ContentSet instanceof Content {
22682268

22692269
/**
22702270
* Holds if this element is at the specified location.
2271-
* The location spans column `startcolumn` of line `startline` to
2272-
* column `endcolumn` of line `endline` in file `filepath`.
2271+
* The location spans column `sc` of line `sl` to
2272+
* column `ec` of line `el` in file `path`.
22732273
* For more information, see
22742274
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
22752275
*/

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedFunction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CppType getEllipsisVariablePRValueType() {
5050
CppType getEllipsisVariableGLValueType() { result = getTypeForGLValue(any(UnknownType t)) }
5151

5252
/**
53-
* Holds if the function returns a value, as opposed to returning `void`.
53+
* Holds if the function `func` returns a value, as opposed to returning `void`.
5454
*/
5555
predicate hasReturnValue(Function func) { not func.getUnspecifiedType() instanceof VoidType }
5656

0 commit comments

Comments
 (0)