CFG: flow for rescue-modifier

This commit is contained in:
Arthur Baars
2020-12-03 12:46:29 +01:00
parent d619bdd8f9
commit 3807e1be38
2 changed files with 23 additions and 0 deletions

View File

@@ -57,6 +57,8 @@ abstract class Completion extends TCompletion {
this = TBooleanCompletion(_)
)
or
n = any(RescueModifier parent).getBody() and this = TRaiseCompletion()
or
not n instanceof NonReturningCall and
not completionIsValidForStmt(n, _) and
not mustHaveBooleanCompletion(n) and

View File

@@ -598,6 +598,27 @@ private module Trees {
final override AstNode getChildNode(int i) { result = this.getChild() and i = 0 }
}
private class RescueModifierTree extends PreOrderTree, RescueModifier {
final override predicate propagatesAbnormal(AstNode child) { child = this.getHandler() }
final override predicate last(AstNode last, Completion c) {
last(this.getBody(), last, c) and
not c instanceof RaiseCompletion
or
last(this.getHandler(), last, c)
}
final override predicate succ(AstNode pred, AstNode succ, Completion c) {
pred = this and
first(this.getBody(), succ) and
c instanceof SimpleCompletion
or
last(this.getBody(), pred, c) and
c instanceof RaiseCompletion and
first(this.getHandler(), succ)
}
}
private class ReturnTree extends StandardPostOrderTree, Return {
final override AstNode getChildNode(int i) { result = this.getChild() and i = 0 }
}