File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -1520,16 +1520,17 @@ private EdgeKind caseOrDefaultEdge() {
1520
1520
private int countNumberOfBranchesUsingParameter ( SwitchInstruction switch , ParameterNode p ) {
1521
1521
exists ( Ssa:: SourceVariable sv |
1522
1522
parameterNodeHasSourceVariable ( p , sv ) and
1523
- // Count the number of cases that use the parameter. We do this by finding the phi node
1524
- // that merges the uses/defs of the parameter. There might be multiple such phi nodes, so
1525
- // we pick the one with the highest edge count.
1523
+ // Count the number of cases that use the parameter.
1526
1524
result =
1527
- max ( SsaPhiNode phi |
1528
- switch .getSuccessor ( caseOrDefaultEdge ( ) ) .getBlock ( ) .dominanceFrontier ( ) =
1529
- phi .getBasicBlock ( ) and
1530
- phi .getSourceVariable ( ) = sv
1531
- |
1532
- strictcount ( phi .getAnInput ( ) )
1525
+ strictcount ( IRBlock caseblock |
1526
+ exists ( IRBlock useblock |
1527
+ switch .getSuccessor ( caseOrDefaultEdge ( ) ) .getBlock ( ) = caseblock and
1528
+ caseblock .dominates ( useblock )
1529
+ |
1530
+ exists ( Ssa:: UseImpl use | use .hasIndexInBlock ( useblock , _, sv ) )
1531
+ or
1532
+ exists ( Ssa:: DefImpl def | def .hasIndexInBlock ( useblock , _, sv ) )
1533
+ )
1533
1534
)
1534
1535
)
1535
1536
}
You can’t perform that action at this time.
0 commit comments