Ruby: CFG: make VariableReferencePattern a PreOrder node

This commit is contained in:
Arthur Baars
2021-12-07 16:22:48 +01:00
parent e9e3ef3ea2
commit 660e52f2bf
3 changed files with 11 additions and 9 deletions

View File

@@ -227,6 +227,8 @@ private predicate inMatchingContext(AstNode n) {
or
n instanceof CasePattern
or
n = any(VariableReferencePattern p).getVariableAccess()
or
n = any(CasePattern c).getDesugared()
or
n.(Trees::DefaultValueParameterTree).hasDefaultValue()

View File

@@ -722,7 +722,7 @@ module Trees {
override ControlFlowTree getChildElement(int i) { result = this.getPattern() and i = 0 }
}
private class VariableReferencePatternTree extends StandardPostOrderTree, VariableReferencePattern {
private class VariableReferencePatternTree extends StandardPreOrderTree, VariableReferencePattern {
override ControlFlowTree getChildElement(int i) { result = this.getVariableAccess() and i = 0 }
}

View File

@@ -1046,14 +1046,14 @@ case.rb:
#-----| match -> exit case_match_various (normal)
# 74| in ... then ...
#-----| -> foo
#-----| -> ^...
# 74| ^...
#-----| no-match -> in ... then ...
#-----| match -> exit case_match_various (normal)
#-----| -> foo
# 74| foo
#-----| -> ^...
#-----| no-match -> in ... then ...
#-----| match -> exit case_match_various (normal)
# 75| in ... then ...
#-----| -> "string"
@@ -1154,15 +1154,15 @@ case.rb:
#-----| -> 5
# 83| 5
#-----| no-match -> foo
#-----| no-match -> ^...
#-----| match -> exit case_match_various (normal)
# 83| ^...
#-----| no-match -> "string"
#-----| match -> exit case_match_various (normal)
#-----| -> foo
# 83| foo
#-----| -> ^...
#-----| no-match -> "string"
#-----| match -> exit case_match_various (normal)
# 83| "string"
#-----| no-match -> in ... then ...