Skip to content

Commit 90b4eb9

Browse files
committed
C#: Use Gvn comparison instead of StructuralComparisonConfiguration in UnsafeLazyInitialization.
1 parent 74b8e73 commit 90b4eb9

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

csharp/ql/src/Concurrency/UnsafeLazyInitialization.ql

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,12 @@
1414
import csharp
1515
import semmle.code.csharp.commons.StructuralComparison
1616

17-
class DoubleCheckedLock extends StructuralComparisonConfiguration {
18-
DoubleCheckedLock() { this = "double checked lock" }
19-
20-
override predicate candidate(ControlFlowElement x, ControlFlowElement y) {
21-
exists(IfStmt unlockedIf, IfStmt lockedIf, LockStmt lock |
22-
x = unlockedIf.getCondition() and
23-
y = lockedIf.getCondition() and
24-
lock = unlockedIf.getThen().stripSingletonBlocks() and
25-
lockedIf.getParent*() = lock.getBlock()
26-
)
27-
}
28-
}
29-
30-
predicate doubleCheckedLock(Field field, IfStmt ifs) {
31-
exists(DoubleCheckedLock config, LockStmt lock, Expr eq1, Expr eq2 | ifs.getCondition() = eq1 |
32-
lock = ifs.getThen().stripSingletonBlocks() and
33-
config.same(eq1, eq2) and
34-
field.getAnAccess() = eq1.getAChildExpr*()
17+
predicate doubleCheckedLock(Field field, IfStmt unlockedIf) {
18+
exists(LockStmt lock, IfStmt lockedIf |
19+
lock = unlockedIf.getThen().stripSingletonBlocks() and
20+
lockedIf.getParent*() = lock.getBlock() and
21+
sameGvn(unlockedIf.getCondition(), lockedIf.getCondition()) and
22+
field.getAnAccess() = unlockedIf.getCondition().getAChildExpr*()
3523
)
3624
}
3725

0 commit comments

Comments
 (0)