mirror of
https://github.com/github/codeql.git
synced 2026-02-20 00:43:44 +01:00
Ensure module/class/methods and their headers belong to the right CfgScope
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user