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() {
15201520private int countNumberOfBranchesUsingParameter ( SwitchInstruction switch , ParameterNode p ) {
15211521 exists ( Ssa:: SourceVariable sv |
15221522 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.
15261524 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+ )
15331534 )
15341535 )
15351536}
You can’t perform that action at this time.
0 commit comments