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

Skip to content

Commit af364e6

Browse files
committed
C++/C#: Move sanity check inside InstructionSanity module and accept tests
1 parent d9753b0 commit af364e6

31 files changed

Lines changed: 59 additions & 68 deletions

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ module InstructionSanity {
266266
funcText = Language::getIdentityString(func.getFunction())
267267
)
268268
}
269-
}
270269

271-
query predicate switchInstructionWithoutDefaultEdge(
272-
SwitchInstruction switchInstr, string message, IRFunction func, string funcText
273-
) {
274-
not exists(switchInstr.getDefaultSuccessor()) and
275-
message =
276-
"SwitchInstruction " + switchInstr.toString() + " without a DefaultEdge in function '$@'." and
277-
func = switchInstr.getEnclosingIRFunction() and
278-
funcText = Language::getIdentityString(func.getFunction())
270+
query predicate switchInstructionWithoutDefaultEdge(
271+
SwitchInstruction switchInstr, string message, IRFunction func, string funcText
272+
) {
273+
not exists(switchInstr.getDefaultSuccessor()) and
274+
message =
275+
"SwitchInstruction " + switchInstr.toString() + " without a DefaultEdge in function '$@'." and
276+
func = switchInstr.getEnclosingIRFunction() and
277+
funcText = Language::getIdentityString(func.getFunction())
278+
}
279279
}
280280

281281
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ module InstructionSanity {
266266
funcText = Language::getIdentityString(func.getFunction())
267267
)
268268
}
269-
}
270269

271-
query predicate switchInstructionWithoutDefaultEdge(
272-
SwitchInstruction switchInstr, string message, IRFunction func, string funcText
273-
) {
274-
not exists(switchInstr.getDefaultSuccessor()) and
275-
message =
276-
"SwitchInstruction " + switchInstr.toString() + " without a DefaultEdge in function '$@'." and
277-
func = switchInstr.getEnclosingIRFunction() and
278-
funcText = Language::getIdentityString(func.getFunction())
270+
query predicate switchInstructionWithoutDefaultEdge(
271+
SwitchInstruction switchInstr, string message, IRFunction func, string funcText
272+
) {
273+
not exists(switchInstr.getDefaultSuccessor()) and
274+
message =
275+
"SwitchInstruction " + switchInstr.toString() + " without a DefaultEdge in function '$@'." and
276+
func = switchInstr.getEnclosingIRFunction() and
277+
funcText = Language::getIdentityString(func.getFunction())
278+
}
279279
}
280280

281281
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ module InstructionSanity {
266266
funcText = Language::getIdentityString(func.getFunction())
267267
)
268268
}
269-
}
270269

271-
query predicate switchInstructionWithoutDefaultEdge(
272-
SwitchInstruction switchInstr, string message, IRFunction func, string funcText
273-
) {
274-
not exists(switchInstr.getDefaultSuccessor()) and
275-
message =
276-
"SwitchInstruction " + switchInstr.toString() + " without a DefaultEdge in function '$@'." and
277-
func = switchInstr.getEnclosingIRFunction() and
278-
funcText = Language::getIdentityString(func.getFunction())
270+
query predicate switchInstructionWithoutDefaultEdge(
271+
SwitchInstruction switchInstr, string message, IRFunction func, string funcText
272+
) {
273+
not exists(switchInstr.getDefaultSuccessor()) and
274+
message =
275+
"SwitchInstruction " + switchInstr.toString() + " without a DefaultEdge in function '$@'." and
276+
func = switchInstr.getEnclosingIRFunction() and
277+
funcText = Language::getIdentityString(func.getFunction())
278+
}
279279
}
280280

281281
/**

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
switchInstructionWithoutDefaultEdge
21
astGuards
32
| test.c:7:9:7:13 | ... > ... |
43
| test.c:17:8:17:12 | ... < ... |

cpp/ql/test/library-tests/dataflow/dataflow-tests/test_ir.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
switchInstructionWithoutDefaultEdge
2-
#select
31
| BarrierGuard.cpp:9:10:9:15 | source | BarrierGuard.cpp:5:19:5:24 | source |
42
| BarrierGuard.cpp:15:10:15:15 | source | BarrierGuard.cpp:13:17:13:22 | source |
53
| BarrierGuard.cpp:25:10:25:15 | source | BarrierGuard.cpp:21:17:21:22 | source |

cpp/ql/test/library-tests/ir/constant_func/constant_func.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
switchInstructionWithoutDefaultEdge
2-
#select
31
| constant_func.cpp:1:5:1:18 | IR: ReturnConstant | 7 |
42
| constant_func.cpp:5:5:5:21 | IR: ReturnConstantPhi | 7 |
53
| constant_func.cpp:25:5:25:25 | IR: ReturnConstantPhiLoop | 7 |
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
switchInstructionWithoutDefaultEdge
2-
#select
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
switchInstructionWithoutDefaultEdge
2-
#select

cpp/ql/test/library-tests/ir/ir/aliased_ssa_sanity.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ containsLoopOfForwardEdges
1919
lostReachability
2020
backEdgeCountMismatch
2121
useNotDominatedByDefinition
22+
switchInstructionWithoutDefaultEdge
2223
missingCanonicalLanguageType
2324
multipleCanonicalLanguageTypes
2425
missingIRType

cpp/ql/test/library-tests/ir/ir/aliased_ssa_sanity_unsound.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ containsLoopOfForwardEdges
1919
lostReachability
2020
backEdgeCountMismatch
2121
useNotDominatedByDefinition
22+
switchInstructionWithoutDefaultEdge
2223
missingCanonicalLanguageType
2324
multipleCanonicalLanguageTypes
2425
missingIRType

0 commit comments

Comments
 (0)