On Tue, 2024-07-02 at 18:02 -0400, David Malcolm wrote: > On Tue, 2024-07-02 at 16:17 +0000, Qing Zhao wrote:
[...snip...] > > > + path.add_event (cur_ch->condition, NULL_TREE, 0, > > + "when the condition is evaluated to %s", > > + cur_ch->is_true_path ? "true" : "false"); > > add_event's 2nd param is the function in which the event occurs, > which > you may want to set to cfun, and set the stack depth to 1, rather ^^^^ cfun's decl, that is, sorry. [...snip...] > > Or, all those > > if (for_array_bound) > warned = warning_at (richloc, OPT_Warray_bounds_, > /* etc */); > > could become: > > if (for_array_bound) > { > copy_history_diagnostic_path path (location, stmt); > warned = warning_at (richloc, OPT_Warray_bounds_, > /* etc */); > } Or rather: if (for_array_bound) { copy_history_location richloc (location, stmt); warned = warning_at (&richloc, OPT_Warray_bounds_, /* etc */); } where the copy_history_location is a new rich_location subclass, and it only populates the path if it's asked for one (when we're actually emitting the diagnostic). > or somesuch, explicitly deferring creation of the path until we're > actually about to emit a warning, and putting the logic in > copy_history_diagnostic_path's ctor. [...snip...] Dave