Skip to content

Commit 90c75cd

Browse files
authored
Merge pull request #478 from felicity-semmle/cpp/SD-2777-jsf-note
C++: Add JSF note to qhelp for sub-set of JSF queries
2 parents 696178e + d4bcc1e commit 90c75cd

File tree

11 files changed

+49
-11
lines changed

11 files changed

+49
-11
lines changed

cpp/ql/src/Critical/NotInitialised.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
*/
1010
import cpp
1111

12-
// This query is the JSF version
13-
//
14-
// (see also InitialisationNotRun.ql and GlobalUseBeforeInit.ql)
12+
// See also InitialisationNotRun.ql and GlobalUseBeforeInit.ql
1513

1614
// Holds if s defines variable v (conservative)
1715
predicate defines(ControlFlowNode s, Variable lv) {

cpp/ql/src/jsf/4.05 Libraries/AV Rule 24.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds calls to the standard library functions <code>abort, exit, getenv</code> and <code>system</code>.
13+
This query highlights calls to the standard library functions <code>abort, exit, getenv</code> and <code>system</code>.
1014
The functions <code>abort</code> and <code>exit</code> should not be called as they immediately terminate the program
1115
and will bypass all the normal error and exception handling routines in the software. This is especially important in
1216
software which is run on systems without an interactive OS, as restarting the software may require a complete reboot

cpp/ql/src/jsf/4.10 Classes/AV Rule 85.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule ensures that all operators with opposites (e.g. == and !=) are both defined, and
13+
This query ensures that all operators with opposites (e.g. == and !=) are both defined, and
1014
that one of them is defined in terms of the other. This just enforces the consistency of meaning
1115
of the operators.
1216
</p>

cpp/ql/src/jsf/4.13 Functions/AV Rule 111.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds return statements that return pointers to an object allocated on the stack. The lifetime
13+
This query highlights return statements that return pointers to an object allocated on the stack. The lifetime
1014
of a stack allocated memory location only lasts until the function returns, , and
1115
the contents of that memory become undefined after that. Clearly, using a pointer to stack
1216
memory after the function has already returned will have undefined results.

cpp/ql/src/jsf/4.15 Declarations and Definitions/AV Rule 135.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds identifiers in an inner scope that hide (have the same name as) an identifier in an outer scope.
13+
This query highlights identifiers in an inner scope that hide (have the same name as) an identifier in an outer scope.
1014
This should be avoided as it can cause confusion about the actual variable being used in an expression.
1115
</p>
1216

cpp/ql/src/jsf/4.15 Declarations and Definitions/AV Rule 140.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds variables with the <code>register</code> storage class specifier. Modern compilers are now capable of
13+
This query highlights variables with the <code>register</code> storage class specifier. Modern compilers are now capable of
1014
optimal register placement, and overriding it could lead to worse performance.
1115
</p>
1216

cpp/ql/src/jsf/4.17 Types/AV Rule 147.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds portions of code that can expose the floating point implementation of the underlying
13+
This query highlights portions of code that can expose the floating point implementation of the underlying
1014
machine. Manually manipulating the bits in the float is prone to mistakes and is unportable. Floating point
1115
implementations can vary across architectures, and bit-field packing can differ across compilers,
1216
making manual bit-manipulation of floats inadvisable.

cpp/ql/src/jsf/4.18 Constants/AV Rule 151.1.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds string literals that are assigned to a non-<code>const</code> variable. String literals
13+
This query highlights string literals that are assigned to a non-<code>const</code> variable. String literals
1014
should not be changed, since they are usually stored in the data section, and depending on the architecture,
1115
writing to the data section will cause undefined behavior, such as memory corruption or memory write error.
1216
</p>

cpp/ql/src/jsf/4.20 Unions and Bit Fields/AV Rule 154.qhelp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
913
This rule finds bit fields with members that are not explicitly declared to be unsigned.
1014
The sign of plain char, short, int, or long bit field is implementation-specific, and declaring

cpp/ql/src/jsf/4.21 Operators/AV Rule 165.qhelp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66

77
<overview>
8+
9+
<!-- Mention that this rule may not be applicable in projects that don't follow the JSF standard. -->
10+
<include src="cpp/jsfNote.qhelp" />
11+
812
<p>
9-
This rule finds unsigned values that are being negated. Behavior is undefined in such cases.
13+
This query finds unsigned values that are being negated. Behavior is undefined in such cases.
1014
Negating integer values produces the two's complement of that number, which cannot represent negative
1115
values of large unsigned values (values where the sign bit is used) and are most likely to be interpreted
1216
as a smaller positive integer instead.

0 commit comments

Comments
 (0)