C#: Generic control flow graph splitting

Refactor existing logic for splitting control flow nodes belonging to a `finally`
block. A `Split` defines (1) when to enter the split, (2) when to stay in the split,
and (3) when to leave the split. With only these definitions, control flow splitting
is achieved by tagging each control flow element with the set of splits that apply
to it.
This commit is contained in:
Tom Hvitved
2018-08-03 14:00:24 +02:00
parent 1365761f72
commit a705b3afa5
3 changed files with 727 additions and 532 deletions

View File

@@ -123,11 +123,6 @@ class Completion extends TCompletion {
this instanceof NormalCompletion or
this instanceof ContinueCompletion
}
/** Holds if this completion is a valid completion for exiting a callable. */
predicate isValidCallableExitCompletion() {
not this instanceof GotoCompletion
}
}
/** Holds if expression `e` has the Boolean constant value `value`. */

View File

@@ -1,5 +1,19 @@
import csharp
import semmle.code.csharp.controlflow.ControlFlowGraph
import Internal
from FinallySplitControlFlowNode f
class MyFinallySplitControlFlowNode extends ControlFlowElementNode {
MyFinallySplitControlFlowNode() {
exists(FinallySplitting::FinallySplitType type |
type = this.getASplit().(FinallySplit).getType() |
not type instanceof ControlFlowEdgeSuccessor
)
}
TryStmt getTryStmt() {
this.getElement() = FinallySplitting::getAFinallyDescendant(result)
}
}
from MyFinallySplitControlFlowNode f
select f.getTryStmt(), f