C#: Avoid recomputing ControlFlowTree::Range outside the CFG construction stage

This commit is contained in:
Tom Hvitved
2021-05-21 09:44:41 +02:00
parent 088a1a9707
commit 0d14b9413d
3 changed files with 5 additions and 5 deletions

View File

@@ -403,7 +403,7 @@ private module JoinBlockPredecessors {
private import semmle.code.csharp.controlflow.internal.ControlFlowGraphImpl
int getId(JoinBlockPredecessor jbp) {
exists(ControlFlowTree::Range t | ControlFlowTree::idOf(t, result) |
exists(ControlFlowTree::Range_ t | ControlFlowTree::idOf(t, result) |
t = jbp.getFirstNode().getElement()
or
t = jbp.(EntryBasicBlock).getCallable()

View File

@@ -77,7 +77,7 @@ class CfgScope extends Element, @top_level_exprorstmt_parent {
}
module ControlFlowTree {
private class Range_ = @callable or @control_flow_element;
class Range_ = @callable or @control_flow_element;
class Range extends Element, Range_ {
Range() { this = getAChild*(any(CfgScope scope)) }
@@ -88,9 +88,9 @@ module ControlFlowTree {
result = p.(AssignOperation).getExpandedAssignment()
}
private predicate id(Range x, Range y) { x = y }
private predicate id(Range_ x, Range_ y) { x = y }
predicate idOf(Range x, int y) = equivalenceRelation(id/2)(x, y)
predicate idOf(Range_ x, int y) = equivalenceRelation(id/2)(x, y)
}
abstract private class ControlFlowTree extends ControlFlowTree::Range {

View File

@@ -49,7 +49,7 @@ module Private {
}
int getId(PhiInputEdgeBlock bb) {
exists(CfgImpl::ControlFlowTree::Range t | CfgImpl::ControlFlowTree::idOf(t, result) |
exists(CfgImpl::ControlFlowTree::Range_ t | CfgImpl::ControlFlowTree::idOf(t, result) |
t = bb.getFirstNode().getElement()
or
t = bb.(CS::ControlFlow::BasicBlocks::EntryBlock).getCallable()