Skip to content

Commit 7027cd3

Browse files
committed
C#: Speedup isGuardedByNode()
1 parent 72384e5 commit 7027cd3

File tree

1 file changed

+9
-5
lines changed
  • csharp/ql/src/semmle/code/csharp/controlflow

1 file changed

+9
-5
lines changed

csharp/ql/src/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,18 +1271,22 @@ module Internal {
12711271
exists(ConditionOnExprComparisonConfig c | c.same(sub, guarded.getElement()))
12721272
}
12731273

1274+
pragma[noinline]
1275+
private predicate isGuardedByNode2(ControlFlow::Nodes::ElementNode guarded, Ssa::Definition def) {
1276+
isGuardedByNode1(guarded, _, _, _) and
1277+
exists(BasicBlock bb | bb = guarded.getBasicBlock() |
1278+
def = guarded.getElement().(AccessOrCallExpr).getAnSsaQualifier(bb.getANode())
1279+
)
1280+
}
1281+
12741282
cached
12751283
predicate isGuardedByNode(
12761284
ControlFlow::Nodes::ElementNode guarded, Guard g, AccessOrCallExpr sub, AbstractValue v
12771285
) {
12781286
isGuardedByNode1(guarded, g, sub, v) and
12791287
sub = g.getAChildExpr*() and
12801288
forall(Ssa::Definition def | def = sub.getAnSsaQualifier(_) |
1281-
exists(ControlFlow::Node cfn |
1282-
def = guarded.getElement().(AccessOrCallExpr).getAnSsaQualifier(cfn)
1283-
|
1284-
cfn.getBasicBlock() = guarded.getBasicBlock()
1285-
)
1289+
isGuardedByNode2(guarded, def)
12861290
)
12871291
}
12881292

0 commit comments

Comments
 (0)