Skip to content

Commit 4390e4c

Browse files
committed
C++: Fix handling of unreached instructions in IRGuards
1 parent d6e30cd commit 4390e4c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ private class GuardConditionFromIR extends GuardCondition {
223223
or
224224
instr = tce.getInstruction(ConditionValueFalseTempAddressTag())
225225
)
226+
or
227+
// Exclude unreached instructions, as their AST is the whole function and not a block.
228+
instr instanceof UnreachedInstruction
226229
}
227230
}
228231

cpp/ql/test/library-tests/controlflow/guards-ir/tests.expected

-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ astGuardsControl
257257
| test.c:175:13:175:32 | ... == ... | false | 175 | 175 |
258258
| test.c:175:13:175:32 | ... == ... | true | 175 | 175 |
259259
| test.c:181:9:181:9 | x | false | 183 | 184 |
260-
| test.c:181:9:181:9 | x | false | 186 | 180 |
261260
| test.c:181:9:181:9 | x | true | 181 | 182 |
262261
| test.c:181:9:181:9 | x | true | 186 | 180 |
263262
| test.cpp:18:8:18:10 | call to get | true | 19 | 19 |

0 commit comments

Comments
 (0)