Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64e2277

Browse files
committed
C++: Don't use @param in QLDoc
It superficially looks like `@param` is supported in QLDoc, but this is mostly an accident of how its parser works. Attributes starting with `@` are only intended to be used in the top-level QLDoc of a query, and there can only be one of each attribute. If there are multiple `@param` entries, the QLDoc parser will only keep the first one. Even though `parseConvSpec` in `Scanf.qll` documented multiple parameters, only the first one would be shown in an IDE. The corresponding predicate in `Print.qll` documented only its first parameter, perhaps because of an autoformatting accident earlier in time. I've attempted to reconstruct documentation for its other parameters based on its sibling in `Scanf.qll`.
1 parent 8524b95 commit 64e2277

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,15 @@ class FormatLiteral extends Literal {
296296
}
297297

298298
/**
299-
* Holds if the arguments are a parsing of a conversion specifier to this format string.
299+
* Holds if the arguments are a parsing of a conversion specifier to this
300+
* format string, where `n` is which conversion specifier to parse, `spec` is
301+
* the whole conversion specifier, `params` is the argument to be converted
302+
* in case it's not positional, `flags` contains additional format flags,
303+
* `width` is the maximum width option of this input, `len` is the length
304+
* flag of this input, and `conv` is the conversion character of this input.
300305
*
301-
* @param n which conversion specifier to parse
306+
* Each parameter is the empty string if no value is given by the conversion
307+
* specifier.
302308
*/
303309
predicate parseConvSpec(
304310
int n, string spec, string params, string flags, string width, string prec, string len,

cpp/ql/src/semmle/code/cpp/commons/Scanf.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,14 @@ class ScanfFormatLiteral extends Expr {
227227
}
228228

229229
/**
230-
* Holds if the arguments are a parsing of a conversion specifier to this format string.
231-
* @param n which conversion specifier to parse
232-
* @param spec the whole conversion specifier
233-
* @param width the maximum width option of this input (empty string if none is given)
234-
* @param len the length flag of this input (empty string if none is given)
235-
* @param conv the conversion character of this input
230+
* Holds if the arguments are a parsing of a conversion specifier to this
231+
* format string, where `n` is which conversion specifier to parse, `spec` is
232+
* the whole conversion specifier, `width` is the maximum width option of
233+
* this input, `len` is the length flag of this input, and `conv` is the
234+
* conversion character of this input.
235+
*
236+
* Each parameter is the empty string if no value is given by the conversion
237+
* specifier.
236238
*/
237239
predicate parseConvSpec(int n, string spec, string width, string len, string conv) {
238240
exists(int offset, string fmt, string rst, string regexp |

cpp/ql/src/semmle/code/cpp/security/TaintTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ predicate tainted(Expr source, Element tainted) {
376376
* This version gives the same results as tainted but also includes
377377
* data flow through global variables.
378378
*
379-
* @param globalVar the name of the last global variable used to move the
379+
* The parameter `globalVar` is the name of the last global variable used to move the
380380
* value from source to tainted.
381381
*/
382382
predicate taintedIncludingGlobalVars(Expr source, Element tainted, string globalVar) {

0 commit comments

Comments
 (0)