Ensure module/class/methods and their headers belong to the right CfgScope

This commit is contained in:
Arthur Baars
2021-02-04 15:29:09 +01:00
parent bfc5ee3149
commit 62802d53c8
2 changed files with 4 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ private import codeql_ruby.ast.internal.Expr
private import codeql_ruby.ast.internal.Method
private import codeql_ruby.ast.internal.Pattern
private Generated::AstNode parentOf(Generated::AstNode n) {
Generated::AstNode parentOf(Generated::AstNode n) {
exists(Generated::AstNode parent | parent = n.getParent() |
if
n =

View File

@@ -33,6 +33,7 @@
private import codeql_ruby.ast.internal.TreeSitter::Generated
private import AstNodes
private import codeql_ruby.ast.internal.Variable
private import codeql_ruby.controlflow.ControlFlowGraph
private import Completion
private import SuccessorTypes
@@ -146,7 +147,7 @@ module CfgScope {
}
private AstNode parent(AstNode n) {
result.getAFieldOrChild() = n and
result = parentOf(n) and
not n instanceof CfgScope
}
@@ -1262,7 +1263,7 @@ cached
private module Cached {
/** Gets the CFG scope of node `n`. */
cached
CfgScope getCfgScope(AstNode n) { result = unique(CfgScope scope | scope = parent+(n)) }
CfgScope getCfgScope(AstNode n) { result = unique(CfgScope scope | scope = parent*(parentOf(n))) }
private predicate isAbnormalExitType(SuccessorType t) {
t instanceof RaiseSuccessor or t instanceof ExitSuccessor