Commit 1fb9d82
committed
Fix false positives in RULE-0-0-1 from disconnected non-Stmt CFG nodes
The codeql/cpp-all library (particularly version 5.0.0) can produce orphan
BasicBlock nodes in the CFG that are completely disconnected (no predecessors
and no successors). These nodes represent expressions, variable accesses, or
function name nodes rather than actual statements. When they appear in
functions with virtual calls returning complex types (like expected<void, E>),
the isReachable predicate cannot reach them and they get incorrectly flagged
as unreachable statements.
Add isDisconnectedNonStmtBlock predicate to filter out these CFG artifacts.
The predicate specifically targets blocks that:
- Have no predecessors AND no successors (completely isolated)
- Are not function entry points
- Are not Stmt instances (the rule is about unreachable *statements*)
This preserves detection of legitimate unreachable statements (e.g., code
after infinite loops or noreturn calls) which are Stmt nodes with zero
predecessors but may have successors.
Verified: eliminates ~1182 false positives on eclipse-score/communication
codebase while all existing test cases continue to pass.
Fixes #11431 parent 883a46f commit 1fb9d82
3 files changed
Lines changed: 55 additions & 1 deletion
File tree
- change_notes
- cpp/misra
- src/rules/RULE-0-0-1
- test/rules/RULE-0-0-1
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
64 | 79 | | |
65 | 80 | | |
66 | 81 | | |
67 | 82 | | |
68 | 83 | | |
69 | | - | |
| 84 | + | |
| 85 | + | |
70 | 86 | | |
71 | 87 | | |
72 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
250 | 286 | | |
0 commit comments