From fd147705427d7aa4d31e3448cdebdea354d1db6b Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Tue, 15 Dec 2020 14:49:50 +0100 Subject: [PATCH] CFG: drop getObject from flow of singleton method --- .../controlflow/internal/ControlFlowGraphImpl.qll | 8 ++------ ql/test/library-tests/controlflow/graph/Cfg.expected | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index cc4f3d06811..c9c7364e1cb 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -1203,15 +1203,11 @@ module Trees { private class SingletonMethodTree extends RescueEnsureBlockTree, SingletonMethod { final override AstNode getChildNode(int i, boolean rescuable) { - result = this.getObject() and + result = this.getParameters() and i = 0 and rescuable = false or - result = this.getParameters() and - i = 1 and - rescuable = false - or - result = this.getChild(i - 2) and + result = this.getChild(i - 1) and rescuable = true } diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index 88146edbf0c..204f8781111 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -50,7 +50,7 @@ cfg.rb: #-----| -> String # 149| enter method -#-----| -> silly +#-----| -> SplatParameter # 153| enter two_parameters #-----| -> a @@ -1543,9 +1543,6 @@ cfg.rb: # 148| new #-----| -> Call -# 149| silly -#-----| -> SplatParameter - # 149| SplatParameter #-----| -> x