class AdLint::Exam::CBuiltin::W0502::AmbiguousExpressionDetector
Public Class Methods
new(phase_ctxt, expr)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11896 def initialize(phase_ctxt, expr) @phase_ctxt = phase_ctxt @target_expr = expr @encl_expr_stack = [expr] @arith_exprs = Hash.new(0) @shift_exprs = Hash.new(0) @relat_exprs = Hash.new(0) @equal_exprs = Hash.new(0) @and_exprs = Hash.new(0) @xor_exprs = Hash.new(0) @or_exprs = Hash.new(0) @land_exprs = Hash.new(0) end
Public Instance Methods
execute()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11910 def execute @target_expr.accept(self) end
visit_additive_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_additive_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11936 def visit_additive_expression(node) super @arith_exprs[current_encl_expr] += 1 end
visit_and_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_and_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11965 def visit_and_expression(node) super @and_exprs[current_encl_expr] += 1 if current_arith_exprs + current_shift_exprs + current_relat_exprs + current_equal_exprs > 0 W(current_encl_expr.head_location) end end
visit_array_subscript_expression(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11920 def visit_array_subscript_expression(node) AmbiguousExpressionDetector.new(@phase_ctxt, node.array_subscript).execute end
visit_conditional_expression(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12013 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_equality_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_equality_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11957 def visit_equality_expression(node) super @equal_exprs[current_encl_expr] += 1 if current_arith_exprs + current_shift_exprs + current_relat_exprs > 0 W(current_encl_expr.head_location) end end
visit_exclusive_or_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_exclusive_or_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11974 def visit_exclusive_or_expression(node) super @xor_exprs[current_encl_expr] += 1 if current_arith_exprs + current_shift_exprs + current_relat_exprs + current_equal_exprs + current_and_exprs > 0 W(current_encl_expr.head_location) end end
visit_function_call_expression(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11925 def visit_function_call_expression(node) 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 11914 def visit_grouped_expression(node) @encl_expr_stack.push(node) super @encl_expr_stack.pop end
visit_inclusive_or_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_inclusive_or_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11983 def visit_inclusive_or_expression(node) super @or_exprs[current_encl_expr] += 1 if current_arith_exprs + current_shift_exprs + current_relat_exprs + current_equal_exprs + current_and_exprs + current_xor_exprs > 0 W(current_encl_expr.head_location) end 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 11993 def visit_logical_and_expression(node) super @land_exprs[current_encl_expr] += 1 if current_arith_exprs + current_shift_exprs + current_relat_exprs + current_equal_exprs + current_and_exprs + current_xor_exprs + current_or_exprs > 0 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 12003 def visit_logical_or_expression(node) super if current_arith_exprs + current_shift_exprs + current_relat_exprs + current_equal_exprs + current_and_exprs + current_xor_exprs + current_or_exprs + current_land_exprs > 0 W(current_encl_expr.head_location) end end
visit_multiplicative_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_multiplicative_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11931 def visit_multiplicative_expression(node) super @arith_exprs[current_encl_expr] += 1 end
visit_relational_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_relational_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11949 def visit_relational_expression(node) super @relat_exprs[current_encl_expr] += 1 if current_arith_exprs + current_shift_exprs > 0 W(current_encl_expr.head_location) end end
visit_shift_expression(node)
click to toggle source
Calls superclass method
AdLint::Cc1::SyntaxTreeVisitor#visit_shift_expression
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 11941 def visit_shift_expression(node) super @shift_exprs[current_encl_expr] += 1 if current_arith_exprs > 0 W(current_encl_expr.head_location) end end
Private Instance Methods
current_and_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12039 def current_and_exprs @and_exprs[current_encl_expr] end
current_arith_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12023 def current_arith_exprs @arith_exprs[current_encl_expr] end
current_encl_expr()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12055 def current_encl_expr @encl_expr_stack.last end
current_equal_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12035 def current_equal_exprs @equal_exprs[current_encl_expr] end
current_land_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12051 def current_land_exprs @land_exprs[current_encl_expr] end
current_or_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12047 def current_or_exprs @or_exprs[current_encl_expr] end
current_relat_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12031 def current_relat_exprs @relat_exprs[current_encl_expr] end
current_shift_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12027 def current_shift_exprs @shift_exprs[current_encl_expr] end
current_xor_exprs()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12043 def current_xor_exprs @xor_exprs[current_encl_expr] end
suppressors()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 12067 def suppressors @phase_ctxt[:suppressors] end