Skip to content

Commit ac3c3ae

Browse files
committed
C++: Do not limit second level scopes to the top-level
1 parent 8b95e0e commit ac3c3ae

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
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)