class AdLint::Exam::CBuiltin::W0488::AmbiguousExpressionDetector
Public Class Methods
new(phase_ctxt, expr)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9773 def initialize(phase_ctxt, expr) @phase_ctxt = phase_ctxt @target_expr = expr @enclusure_exprs = [expr] @ary_subs_exprs = Hash.new(0) @funcall_exprs = Hash.new(0) @memb_exprs = Hash.new(0) end
Public Instance Methods
execute()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9782 def execute @target_expr.accept(self) end
visit_array_subscript_expression(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9792 def visit_array_subscript_expression(node) node.expression.accept(self) @ary_subs_exprs[current_encl_expr] += 1 AmbiguousExpressionDetector.new(@phase_ctxt, node.array_subscript).execute end
visit_bit_access_by_pointer_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_bit_access_by_pointer_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9822 def visit_bit_access_by_pointer_expression(node) super @memb_exprs[current_encl_expr] += 1 end
visit_bit_access_by_value_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_bit_access_by_value_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9817 def visit_bit_access_by_value_expression(node) super @memb_exprs[current_encl_expr] += 1 end
visit_conditional_expression(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9841 def visit_conditional_expression(node) cond_expr = node.condition then_expr = node.then_expression else_expr = node.else_expression AmbiguousExpressionDetector.new(@phase_ctxt, cond_expr).execute AmbiguousExpressionDetector.new(@phase_ctxt, then_expr).execute AmbiguousExpressionDetector.new(@phase_ctxt, else_expr).execute end
visit_function_call_expression(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9799 def visit_function_call_expression(node) node.expression.accept(self) @funcall_exprs[current_encl_expr] += 1 node.argument_expressions.each do |expr| AmbiguousExpressionDetector.new(@phase_ctxt, expr).execute end end
visit_grouped_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_grouped_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9786 def visit_grouped_expression(node) @enclusure_exprs.push(node) super @enclusure_exprs.pop end
visit_logical_and_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_logical_and_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9827 def visit_logical_and_expression(node) super if include_ambiguous_expr? W(current_encl_expr.head_location) end end
visit_logical_or_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_logical_or_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9834 def visit_logical_or_expression(node) super if include_ambiguous_expr? W(current_encl_expr.head_location) end end
visit_member_access_by_pointer_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_member_access_by_pointer_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9812 def visit_member_access_by_pointer_expression(node) super @memb_exprs[current_encl_expr] += 1 end
visit_member_access_by_value_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_member_access_by_value_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9807 def visit_member_access_by_value_expression(node) super @memb_exprs[current_encl_expr] += 1 end
Private Instance Methods
current_encl_expr()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9857 def current_encl_expr @enclusure_exprs.last end
include_ambiguous_expr?()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9851 def include_ambiguous_expr? @ary_subs_exprs[current_encl_expr] > 0 || @funcall_exprs[current_encl_expr] > 0 || @memb_exprs[current_encl_expr] > 0 end
suppressors()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9869 def suppressors @phase_ctxt[:suppressors] end