Skip to content

Commit c7e4853

Browse files
authored
Merge pull request #19269 from jketema/non-second-level-limits
C++: Do not limit second level scopes to the top-level
2 parents 1c1ccda + 9396f0e commit c7e4853

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplSpecific.qll

+2
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ module CppDataFlow implements InputSig<Location> {
3131
predicate viableImplInCallContext = Private::viableImplInCallContext/2;
3232

3333
predicate neverSkipInPathGraph = Private::neverSkipInPathGraph/1;
34+
35+
int defaultFieldFlowBranchLimit() { result = 3 }
3436
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

+2-6
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,6 @@ predicate validParameterAliasStep(Node node1, Node node2) {
16521652
)
16531653
}
16541654

1655-
private predicate isTopLevel(Cpp::Stmt s) { any(Function f).getBlock().getAStmt() = s }
1656-
16571655
private Cpp::Stmt getAChainedBranch(Cpp::IfStmt s) {
16581656
result = s.getThen()
16591657
or
@@ -1684,11 +1682,9 @@ private Instruction getAnInstruction(Node n) {
16841682
}
16851683

16861684
private newtype TDataFlowSecondLevelScope =
1687-
TTopLevelIfBranch(Cpp::Stmt s) {
1688-
exists(Cpp::IfStmt ifstmt | s = getAChainedBranch(ifstmt) and isTopLevel(ifstmt))
1689-
} or
1685+
TTopLevelIfBranch(Cpp::Stmt s) { s = getAChainedBranch(_) } or
16901686
TTopLevelSwitchCase(Cpp::SwitchCase s) {
1691-
exists(Cpp::SwitchStmt switchstmt | s = switchstmt.getASwitchCase() and isTopLevel(switchstmt))
1687+
exists(Cpp::SwitchStmt switchstmt | s = switchstmt.getASwitchCase())
16921688
}
16931689

16941690
/**

0 commit comments

Comments
 (0)