mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
C++: respond to doc comments
This commit is contained in:
@@ -6,15 +6,15 @@
|
||||
|
||||
<overview>
|
||||
<p>
|
||||
Code following a goto or break statement will not be executed, unless there is a label or switch
|
||||
case. When the code is necessary, this leads to logical errors or resource leaks. If the code is
|
||||
unnecessary, it may confuse readers.
|
||||
Code immediately following a <code>goto</code> or <code>break</code> statement will not be executed,
|
||||
unless there is a label or switch case. When the code is necessary, this leads to logical errors or
|
||||
resource leaks. If the code is unnecessary, it may confuse readers.
|
||||
</p>
|
||||
</overview>
|
||||
<recommendation>
|
||||
<p>
|
||||
If the unreachable code is necessary, move the goto or break statement to after the code.
|
||||
Otherwise, delete the unreachable code.
|
||||
If the unreachable code is necessary, move the <code>goto</code> or <code>break</code> statement to
|
||||
after the code. Otherwise, delete the unreachable code.
|
||||
</p>
|
||||
|
||||
</recommendation>
|
||||
@@ -22,7 +22,7 @@ Otherwise, delete the unreachable code.
|
||||
</example>
|
||||
<references>
|
||||
<li>
|
||||
The CERT C Secure Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/MSC12-C.+Detect+and+remove+code+that+has+no+effect+or+is+never+executed">MSC12-C. Detect and remove code that has no effect or is never executed</a>
|
||||
The CERT C Secure Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/MSC12-C.+Detect+and+remove+code+that+has+no+effect+or+is+never+executed">MSC12-C. Detect and remove code that has no effect or is never executed</a>.
|
||||
</li>
|
||||
</references>
|
||||
</qhelp>
|
||||
|
||||
@@ -29,4 +29,4 @@ where b.getStmt(i) = js
|
||||
and not s.(BreakStmt).getBreakable() instanceof SwitchStmt
|
||||
// the jump isn't a goto into the body of the next statement
|
||||
and not exists (LabelStmt ls | s.(Loop).getStmt().getAChild*() = ls | ls.getName() = js.(GotoStmt).getName())
|
||||
select js, "This statement makes $@ dead.", s, s.toString()
|
||||
select js, "This statement makes $@ unreachable.", s, s.toString()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
| test.cpp:2:2:2:12 | goto ... | This statement makes $@ dead. | test.cpp:3:2:3:5 | ExprStmt | ExprStmt |
|
||||
| test.cpp:9:3:9:8 | break; | This statement makes $@ dead. | test.cpp:10:3:10:6 | ExprStmt | ExprStmt |
|
||||
| test.cpp:37:3:37:8 | break; | This statement makes $@ dead. | test.cpp:38:3:38:11 | return ... | return ... |
|
||||
| test.cpp:2:2:2:12 | goto ... | This statement makes $@ unreachable. | test.cpp:3:2:3:5 | ExprStmt | ExprStmt |
|
||||
| test.cpp:9:3:9:8 | break; | This statement makes $@ unreachable. | test.cpp:10:3:10:6 | ExprStmt | ExprStmt |
|
||||
| test.cpp:37:3:37:8 | break; | This statement makes $@ unreachable. | test.cpp:38:3:38:11 | return ... | return ... |
|
||||
|
||||
Reference in New Issue
Block a user