Skip to content

Commit 4a1981e

Browse files
committed
C#: Use Gvn comparison instead of StructuralComparisonConfiguration in NestedLoopsSameVariable.
1 parent b4f2fc6 commit 4a1981e

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

csharp/ql/src/Likely Bugs/NestedLoopsSameVariable.ql

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ import csharp
1515
import semmle.code.csharp.commons.ComparisonTest
1616
import semmle.code.csharp.commons.StructuralComparison as SC
1717

18-
/** A structural comparison configuration for comparing the conditions of nested `for` loops. */
19-
class NestedForConditions extends SC::StructuralComparisonConfiguration {
20-
NestedForConditions() { this = "Compare nested for conditions" }
21-
22-
override predicate candidate(ControlFlowElement e1, ControlFlowElement e2) {
23-
exists(NestedForLoopSameVariable nested |
24-
e1 = nested.getInnerForStmt().getCondition() and
25-
e2 = nested.getOuterForStmt().getCondition()
26-
)
27-
}
28-
}
29-
3018
private predicate hasChild(Stmt outer, Element child) {
3119
outer = child.getParent() and
3220
(outer instanceof ForStmt or outer = any(ForStmt f).getBody())
@@ -61,9 +49,7 @@ class NestedForLoopSameVariable extends ForStmt {
6149
}
6250

6351
private predicate haveSameCondition() {
64-
exists(NestedForConditions config |
65-
config.same(this.getInnerForStmt().getCondition(), this.getOuterForStmt().getCondition())
66-
)
52+
SC::sameGvn(this.getInnerForStmt().getCondition(), this.getOuterForStmt().getCondition())
6753
}
6854

6955
private predicate haveSameUpdate() {

0 commit comments

Comments
 (0)