Module: AdLint::Cc1::NegativePathsTracing

Includes:
ContextTracing
Included in:
DefinableContextTracing, NullabilityContextTracing, UndefinableContextTracing
Defined in:
lib/adlint/cc1/trace.rb

Instance Method Summary collapse

Methods included from ContextTracing

#sample_positive_transition, #traceable_negative_contribs, #traceable_positive_contribs

Instance Method Details

#trace_negative_paths(report, loc, traced) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/adlint/cc1/trace.rb', line 61

def trace_negative_paths(report, loc, traced)
  trans = traceable_negative_contribs.map { |mval| mval.transition }
  branches = trans.map { |tr| tr.last.tag.at }.flatten
  sorted_branches = sort_branches_by_groups(branches)
  branches = branches.to_set

  rch_groups = []
  unr_groups = []

  sorted_branches.each_key.with_object([]) { |gr, msgs|
    case
    when gr.branches_to_trunk.any? { |upper| branches.include?(upper) }
      next
    when gr.complete? && gr.branches.size == sorted_branches[gr].size
      unr_groups.push(gr)
    else
      rch_groups.push(gr)
      sorted_branches[gr].each do |br|
        emit_negative_ctrlexpr(msgs, report, loc, traced, br.ctrlexpr)
      end
    end
  } + emit_remaining_paths(report, loc, traced, rch_groups, unr_groups)
end