From aa0c1491a6ef7f98252a938bcaa2efd16eb358e3 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Wed, 16 Dec 2020 10:13:45 +0000 Subject: [PATCH 1/3] Update tree-sitter-ruby to pick up improvements to calls --- Cargo.lock | 2 +- extractor/Cargo.toml | 2 +- generator/Cargo.toml | 2 +- .../codeql_ruby/ast/internal/TreeSitter.qll | 41 +++------- ql/src/ruby.dbscheme | 79 +++++++++---------- 5 files changed, 52 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f546f46805f..a493f322a57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -535,7 +535,7 @@ dependencies = [ [[package]] name = "tree-sitter-ruby" version = "0.17.0" -source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git?rev=694f81cbc552d2c2e928d909652544e0a2d60613#694f81cbc552d2c2e928d909652544e0a2d60613" +source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git?rev=49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448#49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448" dependencies = [ "cc", "tree-sitter", diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index 098fca91551..180e767b53b 100644 --- a/extractor/Cargo.toml +++ b/extractor/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" flate2 = "1.0" node-types = { path = "../node-types" } tree-sitter = "0.17" -tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "694f81cbc552d2c2e928d909652544e0a2d60613" } +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448" } clap = "2.33" tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 246d675d21f..e751b444fe7 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -10,4 +10,4 @@ edition = "2018" node-types = { path = "../node-types" } tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } -tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "694f81cbc552d2c2e928d909652544e0a2d60613" } +tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "49c5f6e9cc9ea1a3b9fb5414ba0c2d697acb2448" } diff --git a/ql/src/codeql_ruby/ast/internal/TreeSitter.qll b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll index 0a9604b919b..19f1d4ea65e 100644 --- a/ql/src/codeql_ruby/ast/internal/TreeSitter.qll +++ b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll @@ -270,18 +270,25 @@ module Generated { class Call extends @call, AstNode { override string getAPrimaryQlClass() { result = "Call" } - override Location getLocation() { call_def(this, _, _, _, _, result) } + override Location getLocation() { call_def(this, _, _, _, result) } - AstNode getMethod() { call_def(this, _, _, result, _, _) } + ArgumentList getArguments() { call_arguments(this, result) } - AstNode getReceiver() { call_def(this, _, _, _, result, _) } + AstNode getBlock() { call_block(this, result) } - override AstNode getParent() { call_def(this, result, _, _, _, _) } + AstNode getMethod() { call_def(this, _, _, result, _) } - override int getParentIndex() { call_def(this, _, result, _, _, _) } + AstNode getReceiver() { call_receiver(this, result) } + + override AstNode getParent() { call_def(this, result, _, _, _) } + + override int getParentIndex() { call_def(this, _, result, _, _) } override AstNode getAFieldOrChild() { - call_def(this, _, _, result, _, _) or call_def(this, _, _, _, result, _) + call_arguments(this, result) or + call_block(this, result) or + call_def(this, _, _, result, _) or + call_receiver(this, result) } } @@ -819,28 +826,6 @@ module Generated { } } - class MethodCall extends @method_call, AstNode { - override string getAPrimaryQlClass() { result = "MethodCall" } - - override Location getLocation() { method_call_def(this, _, _, _, result) } - - ArgumentList getArguments() { method_call_arguments(this, result) } - - AstNode getBlock() { method_call_block(this, result) } - - AstNode getMethod() { method_call_def(this, _, _, result, _) } - - override AstNode getParent() { method_call_def(this, result, _, _, _) } - - override int getParentIndex() { method_call_def(this, _, result, _, _) } - - override AstNode getAFieldOrChild() { - method_call_arguments(this, result) or - method_call_block(this, result) or - method_call_def(this, _, _, result, _) - } - } - class MethodParameters extends @method_parameters, AstNode { override string getAPrimaryQlClass() { result = "MethodParameters" } diff --git a/ql/src/ruby.dbscheme b/ql/src/ruby.dbscheme index 165fbc121ad..a65eeaa018d 100644 --- a/ql/src/ruby.dbscheme +++ b/ql/src/ruby.dbscheme @@ -48,13 +48,13 @@ sourceLocationPrefix( @underscore_arg = @assignment | @binary | @conditional | @operator_assignment | @range | @unary | @underscore_primary -@underscore_lhs = @call | @element_reference | @method_call | @scope_resolution | @token_false | @token_nil | @token_true | @underscore_variable +@underscore_lhs = @call | @element_reference | @scope_resolution | @token_false | @token_nil | @token_true | @underscore_variable @underscore_method_name = @setter | @symbol | @token_class_variable | @token_constant | @token_global_variable | @token_identifier | @token_instance_variable | @token_operator @underscore_primary = @array | @begin | @break | @case__ | @chained_string | @class | @for | @hash | @if | @lambda | @method | @module | @next | @parenthesized_statements | @rational | @redo | @regex | @retry | @return | @singleton_class | @singleton_method | @string__ | @string_array | @subshell | @symbol | @symbol_array | @token_character | @token_complex | @token_float | @token_heredoc_beginning | @token_integer | @unary | @underscore_lhs | @unless | @until | @while | @yield -@underscore_statement = @alias | @assignment | @begin_block | @binary | @break | @call | @end_block | @if_modifier | @method_call | @next | @operator_assignment | @rescue_modifier | @return | @unary | @undef | @underscore_arg | @unless_modifier | @until_modifier | @while_modifier | @yield +@underscore_statement = @alias | @assignment | @begin_block | @binary | @break | @call | @end_block | @if_modifier | @next | @operator_assignment | @rescue_modifier | @return | @unary | @undef | @underscore_arg | @unless_modifier | @until_modifier | @while_modifier | @yield @underscore_variable = @token_class_variable | @token_constant | @token_global_variable | @token_identifier | @token_instance_variable | @token_self | @token_super @@ -68,7 +68,7 @@ alias_def( int loc: @location ref ); -@argument_list_child_type = @block_argument | @break | @call | @hash_splat_argument | @method_call | @next | @pair | @return | @splat_argument | @underscore_arg | @yield +@argument_list_child_type = @block_argument | @break | @call | @hash_splat_argument | @next | @pair | @return | @splat_argument | @underscore_arg | @yield #keyset[argument_list, index] argument_list_child( @@ -85,7 +85,7 @@ argument_list_def( int loc: @location ref ); -@array_child_type = @block_argument | @break | @call | @hash_splat_argument | @method_call | @next | @pair | @return | @splat_argument | @underscore_arg | @yield +@array_child_type = @block_argument | @break | @call | @hash_splat_argument | @next | @pair | @return | @splat_argument | @underscore_arg | @yield #keyset[array, index] array_child( @@ -104,7 +104,7 @@ array_def( @assignment_left_type = @left_assignment_list | @underscore_lhs -@assignment_right_type = @break | @call | @method_call | @next | @return | @right_assignment_list | @splat_argument | @underscore_arg | @yield +@assignment_right_type = @break | @call | @next | @return | @right_assignment_list | @splat_argument | @underscore_arg | @yield #keyset[parent, parent_index] assignment_def( @@ -184,11 +184,11 @@ begin_block_def( int loc: @location ref ); -@binary_left_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@binary_left_type = @break | @call | @next | @return | @underscore_arg | @yield @binary_operator_type = @reserved_word -@binary_right_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@binary_right_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] binary_def( @@ -271,9 +271,26 @@ break_def( int loc: @location ref ); -@call_method_type = @argument_list | @token_constant | @token_identifier | @token_operator +call_arguments( + unique int call: @call ref, + unique int argument_list: @argument_list ref +); -@call_receiver_type = @method_call | @underscore_primary +@call_block_type = @block | @do_block + +call_block( + unique int call: @call ref, + unique int call_block_type: @call_block_type ref +); + +@call_method_type = @argument_list | @scope_resolution | @token_operator | @underscore_variable + +@call_receiver_type = @call | @underscore_primary + +call_receiver( + unique int call: @call ref, + unique int call_receiver_type: @call_receiver_type ref +); #keyset[parent, parent_index] call_def( @@ -281,7 +298,6 @@ call_def( int parent: @ast_node_parent ref, int parent_index: int ref, int method: @call_method_type ref, - int receiver: @call_receiver_type ref, int loc: @location ref ); @@ -426,7 +442,7 @@ do_block_def( int loc: @location ref ); -@element_reference_child_type = @block_argument | @break | @call | @hash_splat_argument | @method_call | @next | @pair | @return | @splat_argument | @underscore_arg | @yield +@element_reference_child_type = @block_argument | @break | @call | @hash_splat_argument | @next | @pair | @return | @splat_argument | @underscore_arg | @yield #keyset[element_reference, index] element_reference_child( @@ -638,7 +654,7 @@ if_def( int loc: @location ref ); -@if_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@if_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] if_modifier_def( @@ -755,29 +771,6 @@ method_def( int loc: @location ref ); -method_call_arguments( - unique int method_call: @method_call ref, - unique int argument_list: @argument_list ref -); - -@method_call_block_type = @block | @do_block - -method_call_block( - unique int method_call: @method_call ref, - unique int method_call_block_type: @method_call_block_type ref -); - -@method_call_method_type = @call | @scope_resolution | @underscore_variable - -#keyset[parent, parent_index] -method_call_def( - unique int id: @method_call, - int parent: @ast_node_parent ref, - int parent_index: int ref, - int method: @method_call_method_type ref, - int loc: @location ref -); - @method_parameters_child_type = @block_parameter | @destructured_parameter | @hash_splat_parameter | @keyword_parameter | @optional_parameter | @splat_parameter | @token_identifier #keyset[method_parameters, index] @@ -830,7 +823,7 @@ next_def( @operator_assignment_operator_type = @reserved_word -@operator_assignment_right_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@operator_assignment_right_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] operator_assignment_def( @@ -989,7 +982,7 @@ rescue_def( int loc: @location ref ); -@rescue_modifier_handler_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@rescue_modifier_handler_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] rescue_modifier_def( @@ -1197,7 +1190,7 @@ subshell_def( int loc: @location ref ); -@superclass_child_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@superclass_child_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] superclass_def( @@ -1257,7 +1250,7 @@ then_def( int loc: @location ref ); -@unary_operand_type = @break | @call | @method_call | @next | @parenthesized_statements | @return | @token_float | @token_integer | @underscore_arg | @yield +@unary_operand_type = @break | @call | @next | @parenthesized_statements | @return | @token_float | @token_integer | @underscore_arg | @yield @unary_operator_type = @reserved_word @@ -1307,7 +1300,7 @@ unless_def( int loc: @location ref ); -@unless_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@unless_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] unless_modifier_def( @@ -1329,7 +1322,7 @@ until_def( int loc: @location ref ); -@until_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@until_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] until_modifier_def( @@ -1371,7 +1364,7 @@ while_def( int loc: @location ref ); -@while_modifier_condition_type = @break | @call | @method_call | @next | @return | @underscore_arg | @yield +@while_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield #keyset[parent, parent_index] while_modifier_def( @@ -1436,7 +1429,7 @@ case @token.kind of ; -@ast_node = @alias | @argument_list | @array | @assignment | @bare_string | @bare_symbol | @begin | @begin_block | @binary | @block | @block_argument | @block_parameter | @block_parameters | @break | @call | @case__ | @chained_string | @class | @conditional | @destructured_left_assignment | @destructured_parameter | @do | @do_block | @element_reference | @else | @elsif | @end_block | @ensure | @exception_variable | @exceptions | @for | @hash | @hash_splat_argument | @hash_splat_parameter | @heredoc_body | @if | @if_modifier | @in | @interpolation | @keyword_parameter | @lambda | @lambda_parameters | @left_assignment_list | @method | @method_call | @method_parameters | @module | @next | @operator_assignment | @optional_parameter | @pair | @parenthesized_statements | @pattern | @program | @range | @rational | @redo | @regex | @rescue | @rescue_modifier | @rest_assignment | @retry | @return | @right_assignment_list | @scope_resolution | @setter | @singleton_class | @singleton_method | @splat_argument | @splat_parameter | @string__ | @string_array | @subshell | @superclass | @symbol | @symbol_array | @then | @token | @unary | @undef | @unless | @unless_modifier | @until | @until_modifier | @when | @while | @while_modifier | @yield +@ast_node = @alias | @argument_list | @array | @assignment | @bare_string | @bare_symbol | @begin | @begin_block | @binary | @block | @block_argument | @block_parameter | @block_parameters | @break | @call | @case__ | @chained_string | @class | @conditional | @destructured_left_assignment | @destructured_parameter | @do | @do_block | @element_reference | @else | @elsif | @end_block | @ensure | @exception_variable | @exceptions | @for | @hash | @hash_splat_argument | @hash_splat_parameter | @heredoc_body | @if | @if_modifier | @in | @interpolation | @keyword_parameter | @lambda | @lambda_parameters | @left_assignment_list | @method | @method_parameters | @module | @next | @operator_assignment | @optional_parameter | @pair | @parenthesized_statements | @pattern | @program | @range | @rational | @redo | @regex | @rescue | @rescue_modifier | @rest_assignment | @retry | @return | @right_assignment_list | @scope_resolution | @setter | @singleton_class | @singleton_method | @splat_argument | @splat_parameter | @string__ | @string_array | @subshell | @superclass | @symbol | @symbol_array | @then | @token | @unary | @undef | @unless | @unless_modifier | @until | @until_modifier | @when | @while | @while_modifier | @yield @ast_node_parent = @ast_node | @file From e98a84c8b5818fd226b8ee1f1b2b4bcb60e994b4 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Wed, 16 Dec 2020 12:01:30 +0000 Subject: [PATCH 2/3] Update CFG to match changes to Call/MethodCall --- .../internal/ControlFlowGraphImpl.qll | 16 +- .../controlflow/internal/NonReturning.qll | 4 +- .../controlflow/graph/Cfg.expected | 473 +++++++++--------- 3 files changed, 236 insertions(+), 257 deletions(-) diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index d55a1c2f97e..c07b0224aad 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -319,10 +319,13 @@ module Trees { } private class CallTree extends StandardPostOrderTree, Call { + // this.getBlock() is not included as it uses a different scope final override AstNode getChildNode(int i) { - result = this.getReceiver() and i = 0 + result = this.getArguments() and i = 0 or - result = this.getMethod() and i = 1 + result = this.getReceiver() and i = 1 + or + result = this.getMethod() and i = 2 } } @@ -769,15 +772,6 @@ module Trees { override predicate isHidden() { any() } } - private class MethodCallTree extends StandardPostOrderTree, MethodCall { - // this.getBlock() is not included as it uses a different scope - final override AstNode getChildNode(int i) { - result = this.getArguments() and i = 0 - or - result = this.getMethod() and i = 1 - } - } - private class MethodParametersTree extends StandardPreOrderTree, MethodParameters { final override AstNode getChildNode(int i) { result = this.getChild(i) } diff --git a/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll b/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll index acba5a0ed26..fb180487a70 100644 --- a/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll +++ b/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll @@ -9,13 +9,13 @@ abstract class NonReturningCall extends AstNode { abstract Completion getACompletion(); } -private class RaiseCall extends NonReturningCall, MethodCall { +private class RaiseCall extends NonReturningCall, Call { RaiseCall() { this.getMethod().toString() = "raise" } override RaiseCompletion getACompletion() { not result instanceof NestedCompletion } } -private class ExitCall extends NonReturningCall, MethodCall { +private class ExitCall extends NonReturningCall, Call { ExitCall() { this.getMethod().toString() in ["abort", "exit"] } override ExitCompletion getACompletion() { not result instanceof NestedCompletion } diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index c49786eaee9..c8c601d8f3d 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -186,11 +186,11 @@ break_ensure.rb: # 8| nil? #-----| -> Call -# 9| MethodCall +# 9| Call #-----| -> If # 9| puts -#-----| -> MethodCall +#-----| -> Call # 9| String #-----| -> puts @@ -256,17 +256,17 @@ break_ensure.rb: # 20| [ensure: break] nil? #-----| -> [ensure: break] Call -# 21| MethodCall +# 21| Call #-----| -> If -# 21| [ensure: break] MethodCall +# 21| [ensure: break] Call #-----| -> [ensure: break] If # 21| puts -#-----| -> MethodCall +#-----| -> Call # 21| [ensure: break] puts -#-----| -> [ensure: break] MethodCall +#-----| -> [ensure: break] Call # 21| String #-----| -> puts @@ -351,11 +351,11 @@ break_ensure.rb: # 36| [ensure: return] Break #-----| return -> exit m3 (normal) -# 41| MethodCall +# 41| Call #-----| -> exit m3 (normal) # 41| puts -#-----| -> MethodCall +#-----| -> Call # 41| String #-----| -> puts @@ -386,11 +386,11 @@ break_ensure.rb: # 47| 1 #-----| -> Binary -# 48| MethodCall +# 48| Call #-----| raise -> [ensure: raise] Ensure # 48| raise -#-----| -> MethodCall +#-----| -> Call # 48| String #-----| -> raise @@ -463,11 +463,11 @@ case.rb: #-----| false -> If #-----| true -> String -# 3| MethodCall +# 3| Call #-----| -> If # 3| puts -#-----| -> MethodCall +#-----| -> Call # 3| String #-----| -> puts @@ -479,11 +479,11 @@ case.rb: #-----| match -> String #-----| no-match -> exit if_in_case (normal) -# 4| MethodCall +# 4| Call #-----| -> exit if_in_case (normal) # 4| puts -#-----| -> MethodCall +#-----| -> Call # 4| String #-----| -> puts @@ -537,11 +537,11 @@ cfg.rb: # 9| BareString #-----| -> StringArray -# 12| MethodCall +# 12| Call #-----| -> 41 # 12| puts -#-----| -> MethodCall +#-----| -> Call # 12| 4 #-----| -> puts @@ -549,11 +549,11 @@ cfg.rb: # 15| BeginBlock #-----| -> String -# 16| MethodCall +# 16| Call #-----| -> exit BEGIN block (normal) # 16| puts -#-----| -> MethodCall +#-----| -> Call # 16| String #-----| -> puts @@ -561,11 +561,11 @@ cfg.rb: # 19| EndBlock #-----| -> String -# 20| MethodCall +# 20| Call #-----| -> exit END block (normal) # 20| puts -#-----| -> MethodCall +#-----| -> Call # 20| String #-----| -> puts @@ -579,11 +579,8 @@ cfg.rb: # 23| 1 #-----| -> Binary -# 25| MethodCall -#-----| -> Symbol - # 25| Call -#-----| -> MethodCall +#-----| -> Symbol # 25| 2 #-----| -> times @@ -594,20 +591,20 @@ cfg.rb: # 25| x #-----| -> x -# 25| MethodCall +# 25| Call #-----| -> exit block (normal) # 25| puts -#-----| -> MethodCall +#-----| -> Call # 25| x #-----| -> puts -# 27| MethodCall +# 27| Call #-----| -> Proc # 27| puts -#-----| -> MethodCall +#-----| -> Call # 27| BlockArgument #-----| -> puts @@ -615,11 +612,8 @@ cfg.rb: # 27| Symbol #-----| -> BlockArgument -# 29| MethodCall -#-----| -> While - # 29| Call -#-----| -> MethodCall +#-----| -> While # 29| Proc #-----| -> new @@ -657,11 +651,8 @@ cfg.rb: # 35| false #-----| false -> If -# 39| MethodCall -#-----| -> Case - # 39| Call -#-----| -> MethodCall +#-----| -> Case # 39| self #-----| -> puts @@ -685,11 +676,11 @@ cfg.rb: #-----| match -> String #-----| no-match -> When -# 42| MethodCall +# 42| Call #-----| -> Case # 42| puts -#-----| -> MethodCall +#-----| -> Call # 42| String #-----| -> puts @@ -709,20 +700,20 @@ cfg.rb: #-----| match -> String #-----| no-match -> String -# 43| MethodCall +# 43| Call #-----| -> Case # 43| puts -#-----| -> MethodCall +#-----| -> Call # 43| String #-----| -> puts -# 44| MethodCall +# 44| Call #-----| -> Case # 44| puts -#-----| -> MethodCall +#-----| -> Call # 44| String #-----| -> puts @@ -743,11 +734,11 @@ cfg.rb: # 48| 1 #-----| -> Binary -# 48| MethodCall +# 48| Call #-----| -> String # 48| puts -#-----| -> MethodCall +#-----| -> Call # 48| String #-----| -> puts @@ -775,11 +766,11 @@ cfg.rb: # 49| 1 #-----| -> Binary -# 49| MethodCall +# 49| Call #-----| -> String # 49| puts -#-----| -> MethodCall +#-----| -> Call # 49| String #-----| -> puts @@ -911,20 +902,20 @@ cfg.rb: # 63| b #-----| -> DestructuredParameter -# 64| MethodCall +# 64| Call #-----| -> b # 64| puts -#-----| -> MethodCall +#-----| -> Call # 64| a #-----| -> puts -# 65| MethodCall +# 65| Call #-----| -> exit pattern (normal) # 65| puts -#-----| -> MethodCall +#-----| -> Call # 65| b #-----| -> puts @@ -947,11 +938,11 @@ cfg.rb: # 67| 3 #-----| -> Array -# 68| MethodCall +# 68| Call #-----| -> 42 # 68| puts -#-----| -> MethodCall +#-----| -> Call # 68| ElementReference #-----| -> puts @@ -962,11 +953,11 @@ cfg.rb: # 68| 2 #-----| -> ElementReference -# 70| MethodCall +# 70| Call #-----| -> exit print (normal) # 70| puts -#-----| -> MethodCall +#-----| -> Call # 70| String #-----| -> puts @@ -1018,11 +1009,11 @@ cfg.rb: # 78| ; #-----| -> String -# 83| MethodCall +# 83| Call #-----| -> Ensure # 83| puts -#-----| -> MethodCall +#-----| -> Call # 83| String #-----| -> puts @@ -1030,11 +1021,11 @@ cfg.rb: # 84| Ensure #-----| -> String -# 85| MethodCall +# 85| Call #-----| -> x # 85| puts -#-----| -> MethodCall +#-----| -> Call # 85| String #-----| -> puts @@ -1089,11 +1080,11 @@ cfg.rb: # 91| Next #-----| next -> For -# 92| MethodCall +# 92| Call #-----| -> For # 92| puts -#-----| -> MethodCall +#-----| -> Call # 92| x #-----| -> puts @@ -1177,11 +1168,11 @@ cfg.rb: # 101| HashSplatParameter #-----| -> value -# 102| MethodCall +# 102| Call #-----| -> kwargs # 102| puts -#-----| -> MethodCall +#-----| -> Call # 102| value #-----| -> puts @@ -1216,11 +1207,11 @@ cfg.rb: # 107| String #-----| -> table -# 108| MethodCall +# 108| Call #-----| -> b # 108| puts -#-----| -> MethodCall +#-----| -> Call # 108| ParenthesizedStatements #-----| -> puts @@ -1246,11 +1237,11 @@ cfg.rb: # 113| IfModifier #-----| -> Class -# 113| MethodCall +# 113| Call #-----| -> IfModifier # 113| puts -#-----| -> MethodCall +#-----| -> Call # 113| String #-----| -> puts @@ -1443,11 +1434,11 @@ cfg.rb: # 133| 0 #-----| -> Binary -# 133| MethodCall +# 133| Call #-----| -> 1 # 133| puts -#-----| -> MethodCall +#-----| -> Call # 133| String #-----| -> puts @@ -1509,26 +1500,23 @@ cfg.rb: # 140| itself #-----| -> Call -# 143| MethodCall +# 143| Call #-----| -> super # 143| puts -#-----| -> MethodCall +#-----| -> Call # 143| String #-----| -> puts -# 144| MethodCall +# 144| Call #-----| -> exit print (normal) # 144| puts -#-----| -> MethodCall - -# 144| MethodCall -#-----| -> puts +#-----| -> Call # 144| Call -#-----| -> MethodCall +#-----| -> puts # 144| super #-----| -> print @@ -1557,11 +1545,11 @@ cfg.rb: # 149| SplatParameter #-----| -> x -# 150| MethodCall +# 150| Call #-----| -> exit method (normal) # 150| puts -#-----| -> MethodCall +#-----| -> Call # 150| x #-----| -> puts @@ -1572,11 +1560,11 @@ cfg.rb: # 153| b #-----| -> exit two_parameters (normal) -# 155| MethodCall +# 155| Call #-----| -> __FILE__ # 155| two_parameters -#-----| -> MethodCall +#-----| -> Call # 155| SplatArgument #-----| -> two_parameters @@ -1666,20 +1654,20 @@ cfg.rb: # 167| 10 #-----| -> Binary -# 167| MethodCall +# 167| Call #-----| -> Unless # 167| puts -#-----| -> MethodCall +#-----| -> Call # 167| String #-----| -> puts -# 167| MethodCall +# 167| Call #-----| -> Unless # 167| puts -#-----| -> MethodCall +#-----| -> Call # 167| String #-----| -> puts @@ -1687,11 +1675,11 @@ cfg.rb: # 169| UnlessModifier #-----| -> Until -# 169| MethodCall +# 169| Call #-----| -> UnlessModifier # 169| puts -#-----| -> MethodCall +#-----| -> Call # 169| String #-----| -> puts @@ -1728,11 +1716,11 @@ cfg.rb: # 171| 10 #-----| -> OperatorAssignment -# 171| MethodCall +# 171| Call #-----| -> x # 171| puts -#-----| -> MethodCall +#-----| -> Call # 171| String #-----| -> puts @@ -1752,11 +1740,11 @@ cfg.rb: # 174| ParenthesizedStatements #-----| -> i -# 174| MethodCall +# 174| Call #-----| -> i # 174| puts -#-----| -> MethodCall +#-----| -> Call # 174| String #-----| -> puts @@ -1827,11 +1815,11 @@ cfg.rb: # 179| Redo #-----| redo -> x -# 180| MethodCall +# 180| Call #-----| -> x # 180| puts -#-----| -> MethodCall +#-----| -> Call # 180| x #-----| -> puts @@ -1842,11 +1830,11 @@ cfg.rb: # 183| ParenthesizedStatements #-----| -> i -# 183| MethodCall +# 183| Call #-----| -> i # 183| puts -#-----| -> MethodCall +#-----| -> Call # 183| String #-----| -> puts @@ -1875,20 +1863,20 @@ cfg.rb: # 186| 42 -# 189| MethodCall +# 189| Call #-----| -> exit top-level (normal) # 189| run_block -#-----| -> MethodCall +#-----| -> Call # 189| x #-----| -> x -# 189| MethodCall +# 189| Call #-----| -> exit block (normal) # 189| puts -#-----| -> MethodCall +#-----| -> Call # 189| x #-----| -> puts @@ -1910,20 +1898,20 @@ exit.rb: # 2| 2 #-----| -> Binary -# 3| MethodCall +# 3| Call #-----| exit -> exit m1 (abnormal) # 3| exit -#-----| -> MethodCall +#-----| -> Call # 3| 1 #-----| -> exit -# 5| MethodCall +# 5| Call #-----| -> exit m1 (normal) # 5| puts -#-----| -> MethodCall +#-----| -> Call # 5| String #-----| -> puts @@ -1944,20 +1932,20 @@ exit.rb: # 9| 2 #-----| -> Binary -# 10| MethodCall +# 10| Call #-----| exit -> exit m2 (abnormal) # 10| abort -#-----| -> MethodCall +#-----| -> Call # 10| String #-----| -> abort -# 12| MethodCall +# 12| Call #-----| -> exit m2 (normal) # 12| puts -#-----| -> MethodCall +#-----| -> Call # 12| String #-----| -> puts @@ -1979,11 +1967,11 @@ ifs.rb: # 2| 2 #-----| -> Binary -# 3| MethodCall +# 3| Call #-----| -> If # 3| puts -#-----| -> MethodCall +#-----| -> Call # 3| String #-----| -> puts @@ -2045,20 +2033,20 @@ ifs.rb: # 4| 5 #-----| -> Binary -# 5| MethodCall +# 5| Call #-----| -> Elsif # 5| puts -#-----| -> MethodCall +#-----| -> Call # 5| String #-----| -> puts -# 7| MethodCall +# 7| Call #-----| -> Elsif # 7| puts -#-----| -> MethodCall +#-----| -> Call # 7| String #-----| -> puts @@ -2141,11 +2129,11 @@ ifs.rb: # 22| 1 #-----| -> Binary -# 25| MethodCall +# 25| Call #-----| -> exit m3 (normal) # 25| puts -#-----| -> MethodCall +#-----| -> Call # 25| x #-----| -> puts @@ -2274,11 +2262,11 @@ loops.rb: # 2| 0 #-----| -> Binary -# 3| MethodCall +# 3| Call #-----| -> x # 3| puts -#-----| -> MethodCall +#-----| -> Call # 3| x #-----| -> puts @@ -2308,11 +2296,11 @@ loops.rb: # 9| 0 #-----| -> Binary -# 10| MethodCall +# 10| Call #-----| -> x # 10| puts -#-----| -> MethodCall +#-----| -> Call # 10| x #-----| -> puts @@ -2374,29 +2362,26 @@ loops.rb: # 17| Redo #-----| redo -> x -# 19| MethodCall +# 19| Call #-----| -> x # 19| puts -#-----| -> MethodCall +#-----| -> Call # 19| String #-----| -> puts -# 21| MethodCall +# 21| Call #-----| -> exit m2 (normal) # 21| puts -#-----| -> MethodCall +#-----| -> Call # 21| String #-----| -> puts -# 25| MethodCall -#-----| -> exit m3 (normal) - # 25| Call -#-----| -> MethodCall +#-----| -> exit m3 (normal) # 25| Array #-----| -> each @@ -2416,11 +2401,11 @@ loops.rb: # 25| x #-----| -> x -# 26| MethodCall +# 26| Call #-----| -> exit do block (normal) # 26| puts -#-----| -> MethodCall +#-----| -> Call # 26| x #-----| -> puts @@ -2466,20 +2451,20 @@ raise.rb: # 8| 2 #-----| -> Binary -# 9| MethodCall +# 9| Call #-----| raise -> exit m1 (abnormal) # 9| raise -#-----| -> MethodCall +#-----| -> Call # 9| String #-----| -> raise -# 11| MethodCall +# 11| Call #-----| -> exit m1 (normal) # 11| puts -#-----| -> MethodCall +#-----| -> Call # 11| String #-----| -> puts @@ -2494,11 +2479,11 @@ raise.rb: #-----| false -> If #-----| true -> ExceptionA -# 17| MethodCall +# 17| Call #-----| raise -> Rescue # 17| raise -#-----| -> MethodCall +#-----| -> Call # 17| ExceptionA #-----| -> raise @@ -2510,20 +2495,20 @@ raise.rb: #-----| match -> String #-----| raise -> exit m2 (abnormal) -# 20| MethodCall +# 20| Call #-----| -> String # 20| puts -#-----| -> MethodCall +#-----| -> Call # 20| String #-----| -> puts -# 22| MethodCall +# 22| Call #-----| -> exit m2 (normal) # 22| puts -#-----| -> MethodCall +#-----| -> Call # 22| String #-----| -> puts @@ -2538,11 +2523,11 @@ raise.rb: #-----| false -> If #-----| true -> ExceptionA -# 28| MethodCall +# 28| Call #-----| raise -> Rescue # 28| raise -#-----| -> MethodCall +#-----| -> Call # 28| ExceptionA #-----| -> raise @@ -2550,20 +2535,20 @@ raise.rb: # 30| Rescue #-----| -> String -# 31| MethodCall +# 31| Call #-----| -> String # 31| puts -#-----| -> MethodCall +#-----| -> Call # 31| String #-----| -> puts -# 33| MethodCall +# 33| Call #-----| -> exit m3 (normal) # 33| puts -#-----| -> MethodCall +#-----| -> Call # 33| String #-----| -> puts @@ -2578,11 +2563,11 @@ raise.rb: #-----| false -> If #-----| true -> ExceptionA -# 39| MethodCall +# 39| Call #-----| raise -> Rescue # 39| raise -#-----| -> MethodCall +#-----| -> Call # 39| ExceptionA #-----| -> raise @@ -2593,20 +2578,20 @@ raise.rb: # 41| e #-----| -> String -# 42| MethodCall +# 42| Call #-----| -> String # 42| puts -#-----| -> MethodCall +#-----| -> Call # 42| String #-----| -> puts -# 44| MethodCall +# 44| Call #-----| -> exit m4 (normal) # 44| puts -#-----| -> MethodCall +#-----| -> Call # 44| String #-----| -> puts @@ -2621,11 +2606,11 @@ raise.rb: #-----| false -> If #-----| true -> ExceptionA -# 50| MethodCall +# 50| Call #-----| raise -> Rescue # 50| raise -#-----| -> MethodCall +#-----| -> Call # 50| ExceptionA #-----| -> raise @@ -2636,11 +2621,11 @@ raise.rb: # 52| e #-----| -> String -# 54| MethodCall +# 54| Call #-----| -> exit m5 (normal) # 54| puts -#-----| -> MethodCall +#-----| -> Call # 54| String #-----| -> puts @@ -2655,11 +2640,11 @@ raise.rb: #-----| false -> If #-----| true -> ExceptionA -# 60| MethodCall +# 60| Call #-----| raise -> Rescue # 60| raise -#-----| -> MethodCall +#-----| -> Call # 60| ExceptionA #-----| -> raise @@ -2678,20 +2663,20 @@ raise.rb: # 62| e #-----| -> String -# 63| MethodCall +# 63| Call #-----| -> String # 63| puts -#-----| -> MethodCall +#-----| -> Call # 63| String #-----| -> puts -# 65| MethodCall +# 65| Call #-----| -> exit m6 (normal) # 65| puts -#-----| -> MethodCall +#-----| -> Call # 65| String #-----| -> puts @@ -2712,11 +2697,11 @@ raise.rb: # 69| 2 #-----| -> Binary -# 70| MethodCall +# 70| Call #-----| raise -> [ensure: raise] Ensure # 70| raise -#-----| -> MethodCall +#-----| -> Call # 70| String #-----| -> raise @@ -2740,11 +2725,11 @@ raise.rb: # 72| String #-----| -> Return -# 74| MethodCall +# 74| Call #-----| -> Ensure # 74| puts -#-----| -> MethodCall +#-----| -> Call # 74| String #-----| -> puts @@ -2758,23 +2743,23 @@ raise.rb: # 75| [ensure: raise] Ensure #-----| -> [ensure: raise] String -# 76| MethodCall +# 76| Call #-----| -> exit m7 (normal) -# 76| [ensure: return] MethodCall +# 76| [ensure: return] Call #-----| return -> exit m7 (normal) -# 76| [ensure: raise] MethodCall +# 76| [ensure: raise] Call #-----| raise -> exit m7 (abnormal) # 76| puts -#-----| -> MethodCall +#-----| -> Call # 76| [ensure: return] puts -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 76| [ensure: raise] puts -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 76| String #-----| -> puts @@ -2788,11 +2773,11 @@ raise.rb: # 79| x #-----| -> String -# 80| MethodCall +# 80| Call #-----| -> x # 80| puts -#-----| -> MethodCall +#-----| -> Call # 80| String #-----| -> puts @@ -2810,11 +2795,11 @@ raise.rb: # 82| 2 #-----| -> Binary -# 83| MethodCall +# 83| Call #-----| raise -> [ensure: raise] Ensure # 83| raise -#-----| -> MethodCall +#-----| -> Call # 83| String #-----| -> raise @@ -2838,11 +2823,11 @@ raise.rb: # 85| String #-----| -> Return -# 87| MethodCall +# 87| Call #-----| -> Ensure # 87| puts -#-----| -> MethodCall +#-----| -> Call # 87| String #-----| -> puts @@ -2856,23 +2841,23 @@ raise.rb: # 88| [ensure: raise] Ensure #-----| -> [ensure: raise] String -# 89| MethodCall +# 89| Call #-----| -> String -# 89| [ensure: return] MethodCall +# 89| [ensure: return] Call #-----| return -> exit m8 (normal) -# 89| [ensure: raise] MethodCall +# 89| [ensure: raise] Call #-----| raise -> exit m8 (abnormal) # 89| puts -#-----| -> MethodCall +#-----| -> Call # 89| [ensure: return] puts -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 89| [ensure: raise] puts -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 89| String #-----| -> puts @@ -2883,11 +2868,11 @@ raise.rb: # 89| [ensure: raise] String #-----| -> [ensure: raise] puts -# 91| MethodCall +# 91| Call #-----| -> exit m8 (normal) # 91| puts -#-----| -> MethodCall +#-----| -> Call # 91| String #-----| -> puts @@ -2901,11 +2886,11 @@ raise.rb: # 94| b2 #-----| -> String -# 95| MethodCall +# 95| Call #-----| -> x # 95| puts -#-----| -> MethodCall +#-----| -> Call # 95| String #-----| -> puts @@ -2923,11 +2908,11 @@ raise.rb: # 97| 2 #-----| -> Binary -# 98| MethodCall +# 98| Call #-----| raise -> [ensure: raise] Ensure # 98| raise -#-----| -> MethodCall +#-----| -> Call # 98| String #-----| -> raise @@ -2951,11 +2936,11 @@ raise.rb: # 100| String #-----| -> Return -# 102| MethodCall +# 102| Call #-----| -> Ensure # 102| puts -#-----| -> MethodCall +#-----| -> Call # 102| String #-----| -> puts @@ -2969,23 +2954,23 @@ raise.rb: # 103| [ensure: raise] Ensure #-----| -> [ensure: raise] String -# 104| MethodCall +# 104| Call #-----| -> b1 -# 104| [ensure: return] MethodCall +# 104| [ensure: return] Call #-----| -> [ensure: return] b1 -# 104| [ensure: raise] MethodCall +# 104| [ensure: raise] Call #-----| -> [ensure: raise] b1 # 104| puts -#-----| -> MethodCall +#-----| -> Call # 104| [ensure: return] puts -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 104| [ensure: raise] puts -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 104| String #-----| -> puts @@ -3017,23 +3002,23 @@ raise.rb: #-----| false -> [ensure: raise] If #-----| true -> [ensure: raise] String -# 107| MethodCall +# 107| Call #-----| raise -> [ensure(1): raise] Ensure -# 107| [ensure: return] MethodCall +# 107| [ensure: return] Call #-----| raise -> [ensure: return, ensure(1): raise] Ensure -# 107| [ensure: raise] MethodCall +# 107| [ensure: raise] Call #-----| raise -> [ensure: raise, ensure(1): raise] Ensure # 107| raise -#-----| -> MethodCall +#-----| -> Call # 107| [ensure: return] raise -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 107| [ensure: raise] raise -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 107| String #-----| -> raise @@ -3062,41 +3047,41 @@ raise.rb: # 109| [ensure: raise, ensure(1): raise] Ensure #-----| -> [ensure: raise, ensure(1): raise] String -# 110| MethodCall +# 110| Call #-----| -> String -# 110| [ensure(1): raise] MethodCall +# 110| [ensure(1): raise] Call #-----| raise -> [ensure: raise] Ensure -# 110| [ensure: return] MethodCall +# 110| [ensure: return] Call #-----| return -> [ensure: return] Ensure -# 110| [ensure: return, ensure(1): raise] MethodCall +# 110| [ensure: return, ensure(1): raise] Call #-----| raise -> [ensure: raise] Ensure -# 110| [ensure: raise] MethodCall +# 110| [ensure: raise] Call #-----| raise -> [ensure: raise] Ensure -# 110| [ensure: raise, ensure(1): raise] MethodCall +# 110| [ensure: raise, ensure(1): raise] Call #-----| raise -> [ensure: raise] Ensure # 110| puts -#-----| -> MethodCall +#-----| -> Call # 110| [ensure(1): raise] puts -#-----| -> [ensure(1): raise] MethodCall +#-----| -> [ensure(1): raise] Call # 110| [ensure: return] puts -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 110| [ensure: return, ensure(1): raise] puts -#-----| -> [ensure: return, ensure(1): raise] MethodCall +#-----| -> [ensure: return, ensure(1): raise] Call # 110| [ensure: raise] puts -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 110| [ensure: raise, ensure(1): raise] puts -#-----| -> [ensure: raise, ensure(1): raise] MethodCall +#-----| -> [ensure: raise, ensure(1): raise] Call # 110| String #-----| -> puts @@ -3116,11 +3101,11 @@ raise.rb: # 110| [ensure: raise, ensure(1): raise] String #-----| -> [ensure: raise, ensure(1): raise] puts -# 113| MethodCall +# 113| Call #-----| -> Ensure # 113| puts -#-----| -> MethodCall +#-----| -> Call # 113| String #-----| -> puts @@ -3134,23 +3119,23 @@ raise.rb: # 114| [ensure: raise] Ensure #-----| -> [ensure: raise] String -# 115| MethodCall +# 115| Call #-----| -> b2 -# 115| [ensure: return] MethodCall +# 115| [ensure: return] Call #-----| -> [ensure: return] b2 -# 115| [ensure: raise] MethodCall +# 115| [ensure: raise] Call #-----| -> [ensure: raise] b2 # 115| puts -#-----| -> MethodCall +#-----| -> Call # 115| [ensure: return] puts -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 115| [ensure: raise] puts -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 115| String #-----| -> puts @@ -3182,23 +3167,23 @@ raise.rb: #-----| false -> [ensure: raise] If #-----| true -> [ensure: raise] String -# 117| MethodCall +# 117| Call #-----| raise -> exit m9 (abnormal) -# 117| [ensure: return] MethodCall +# 117| [ensure: return] Call #-----| raise -> exit m9 (abnormal) -# 117| [ensure: raise] MethodCall +# 117| [ensure: raise] Call #-----| raise -> exit m9 (abnormal) # 117| raise -#-----| -> MethodCall +#-----| -> Call # 117| [ensure: return] raise -#-----| -> [ensure: return] MethodCall +#-----| -> [ensure: return] Call # 117| [ensure: raise] raise -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 117| String #-----| -> raise @@ -3213,11 +3198,11 @@ raise.rb: #-----| no-match -> String #-----| match -> Ensure -# 121| MethodCall +# 121| Call #-----| raise -> exit m10 (abnormal) # 121| raise -#-----| -> MethodCall +#-----| -> Call # 121| String #-----| -> raise @@ -3225,11 +3210,11 @@ raise.rb: # 124| Ensure #-----| -> String -# 125| MethodCall +# 125| Call #-----| -> exit m10 (normal) # 125| puts -#-----| -> MethodCall +#-----| -> Call # 125| String #-----| -> puts @@ -3244,11 +3229,11 @@ raise.rb: #-----| false -> If #-----| true -> ExceptionA -# 131| MethodCall +# 131| Call #-----| raise -> Rescue # 131| raise -#-----| -> MethodCall +#-----| -> Call # 131| ExceptionA #-----| -> raise @@ -3267,11 +3252,11 @@ raise.rb: #-----| match -> String #-----| raise -> [ensure: raise] Ensure -# 135| MethodCall +# 135| Call #-----| -> Ensure # 135| puts -#-----| -> MethodCall +#-----| -> Call # 135| String #-----| -> puts @@ -3282,17 +3267,17 @@ raise.rb: # 136| [ensure: raise] Ensure #-----| -> [ensure: raise] String -# 137| MethodCall +# 137| Call #-----| -> String -# 137| [ensure: raise] MethodCall +# 137| [ensure: raise] Call #-----| raise -> exit m11 (abnormal) # 137| puts -#-----| -> MethodCall +#-----| -> Call # 137| [ensure: raise] puts -#-----| -> [ensure: raise] MethodCall +#-----| -> [ensure: raise] Call # 137| String #-----| -> puts @@ -3300,11 +3285,11 @@ raise.rb: # 137| [ensure: raise] String #-----| -> [ensure: raise] puts -# 139| MethodCall +# 139| Call #-----| -> exit m11 (normal) # 139| puts -#-----| -> MethodCall +#-----| -> Call # 139| String #-----| -> puts @@ -3319,11 +3304,11 @@ raise.rb: #-----| false -> If #-----| true -> String -# 144| MethodCall +# 144| Call #-----| raise -> [ensure: raise] Ensure # 144| raise -#-----| -> MethodCall +#-----| -> Call # 144| String #-----| -> raise From 0518d51b510a0cc096886c2419c83bd3fbcab606 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Wed, 16 Dec 2020 12:40:57 +0000 Subject: [PATCH 3/3] Update CFG: call receiers are evaluated before arguments --- .../controlflow/internal/ControlFlowGraphImpl.qll | 4 ++-- ql/test/library-tests/controlflow/graph/Cfg.expected | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index c07b0224aad..adff80357b8 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -321,9 +321,9 @@ module Trees { private class CallTree extends StandardPostOrderTree, Call { // this.getBlock() is not included as it uses a different scope final override AstNode getChildNode(int i) { - result = this.getArguments() and i = 0 + result = this.getReceiver() and i = 0 or - result = this.getReceiver() and i = 1 + result = this.getArguments() and i = 1 or result = this.getMethod() and i = 2 } diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index c8c601d8f3d..ca1694f09fc 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -646,7 +646,7 @@ cfg.rb: #-----| -> Break # 35| If -#-----| -> 42 +#-----| -> self # 35| false #-----| false -> If @@ -655,13 +655,13 @@ cfg.rb: #-----| -> Case # 39| self -#-----| -> puts +#-----| -> 42 # 39| puts #-----| -> Call # 39| 42 -#-----| -> self +#-----| -> puts # 41| Case #-----| -> 10