module AdLint::Cc1::NullabilityContextTracing
Public Instance Methods
emit_context_messages(report, loc)
click to toggle source
# File lib/adlint/cc1/trace.rb, line 177 def emit_context_messages(report, loc) traced = Set.new msgs = trace_positive_paths(report, loc, traced) + trace_negative_paths(report, loc, traced) unless msgs.empty? [report.C(:C1000, Location.new)] + msgs.sort { |a, b| a.location <=> b.location } else [] end end
Private Instance Methods
trace_positive_paths(report, loc, traced)
click to toggle source
# File lib/adlint/cc1/trace.rb, line 191 def trace_positive_paths(report, loc, traced) # TODO: Evidence of the test result might have two or more contributors. # All the evidences should be complemented by context messages? unless pos_trans = sample_positive_transition return [] end pos_trans.each_with_object([]) do |ss, msgs| branch = ss.tag.at.find { |br| br.ctrlexpr.to_expr } while branch if expr = branch.ctrlexpr.to_expr and expr.location && expr.location < loc unless traced.include?(expr) msgs.push(report.C(:C1001, expr.location)) traced.add(expr) end end branch = branch.trunk end src = ss.tag.by.find { |node| node.location && node.location < loc && !traced.include?(node) } if src case when ss.value.test_must_be_null.true? msgs.push(report.C(:C1004, src.location)) traced.add(src) when ss.value.test_may_be_null.true? msgs.push(report.C(:C1005, src.location)) traced.add(src) end end end end