We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 147ac37 commit a402ce5Copy full SHA for a402ce5
1 file changed
csharp/ql/src/Language Abuse/UselessNullCoalescingExpression.ql
@@ -15,13 +15,21 @@
15
import csharp
16
import semmle.code.csharp.commons.StructuralComparison
17
18
+pragma[nomagic]
19
+private predicate relevant(Expr left, Expr right) {
20
+ exists(NullCoalescingOperation nce |
21
+ left = nce.getLeftOperand() and
22
+ right = nce.getRightOperand()
23
+ )
24
+}
25
+
26
pragma[noinline]
27
private predicate same(AssignableAccess x, AssignableAccess y) {
- exists(NullCoalescingOperation nc |
- x = nc.getLeftOperand() and
- y = nc.getRightOperand().getAChildExpr*()
- ) and
- sameGvn(x, y)
28
+ exists(Expr e |
29
+ relevant(x, e) and
30
+ y = e.getAChildExpr*() and
31
+ sameGvn(x, y)
32
33
}
34
35
private predicate uselessNullCoalescingOperation(NullCoalescingOperation nce) {
0 commit comments