]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/analyzer/ChangeLog
Daily bump.
[thirdparty/gcc.git] / gcc / analyzer / ChangeLog
1 2023-07-19 David Malcolm <dmalcolm@redhat.com>
2
3 PR analyzer/110700
4 * region-model-manager.cc
5 (region_model_manager::get_or_create_int_cst): Assert that we have
6 an integral or pointer type.
7 * sm-taint.cc (taint_state_machine::check_for_tainted_divisor):
8 Don't check non-integral types.
9
10 2023-06-29 benjamin priour <priour.be@gmail.com>
11
12 PR analyzer/110198
13 * region-model-manager.cc
14 (region_model_manager::get_or_create_initial_value): Take an
15 optional boolean value to bypass poisoning checks
16 * region-model-manager.h: Update declaration of the above function.
17 * region-model.cc (region_model::get_store_value): No longer returns
18 on OOB, but rather gives a boolean to get_or_create_initial_value.
19 (region_model::check_region_access): Update docstring.
20 (region_model::check_region_for_write): Update docstring.
21
22 2023-06-24 David Malcolm <dmalcolm@redhat.com>
23
24 * access-diagram.cc: Add #define INCLUDE_VECTOR.
25 * bounds-checking.cc: Likewise.
26
27 2023-06-22 David Malcolm <dmalcolm@redhat.com>
28
29 PR analyzer/106626
30 * access-diagram.cc: New file.
31 * access-diagram.h: New file.
32 * analyzer.h (class region_offset): Add default ctor.
33 (region_offset::make_byte_offset): New decl.
34 (region_offset::concrete_p): New.
35 (region_offset::get_concrete_byte_offset): New.
36 (region_offset::calc_symbolic_bit_offset): New decl.
37 (region_offset::calc_symbolic_byte_offset): New decl.
38 (region_offset::dump_to_pp): New decl.
39 (region_offset::dump): New decl.
40 (operator<, operator<=, operator>, operator>=): New decls for
41 region_offset.
42 * analyzer.opt
43 (-param=analyzer-text-art-string-ellipsis-threshold=): New.
44 (-param=analyzer-text-art-string-ellipsis-head-len=): New.
45 (-param=analyzer-text-art-string-ellipsis-tail-len=): New.
46 (-param=analyzer-text-art-ideal-canvas-width=): New.
47 (fanalyzer-debug-text-art): New.
48 * bounds-checking.cc: Include "intl.h", "diagnostic-diagram.h",
49 and "analyzer/access-diagram.h".
50 (class out_of_bounds::oob_region_creation_event_capacity): New.
51 (out_of_bounds::out_of_bounds): Add "model" and "sval_hint"
52 params.
53 (out_of_bounds::mark_interesting_stuff): Use the base region.
54 (out_of_bounds::add_region_creation_events): Use
55 oob_region_creation_event_capacity.
56 (out_of_bounds::get_dir): New pure vfunc.
57 (out_of_bounds::maybe_show_notes): New.
58 (out_of_bounds::maybe_show_diagram): New.
59 (out_of_bounds::make_access_diagram): New.
60 (out_of_bounds::m_model): New field.
61 (out_of_bounds::m_sval_hint): New field.
62 (out_of_bounds::m_region_creation_event_id): New field.
63 (concrete_out_of_bounds::concrete_out_of_bounds): Update for new
64 fields.
65 (concrete_past_the_end::concrete_past_the_end): Likewise.
66 (concrete_past_the_end::add_region_creation_events): Use
67 oob_region_creation_event_capacity.
68 (concrete_buffer_overflow::concrete_buffer_overflow): Update for
69 new fields.
70 (concrete_buffer_overflow::emit): Replace call to
71 maybe_describe_array_bounds with maybe_show_notes.
72 (concrete_buffer_overflow::get_dir): New.
73 (concrete_buffer_over_read::concrete_buffer_over_read): Update for
74 new fields.
75 (concrete_buffer_over_read::emit): Replace call to
76 maybe_describe_array_bounds with maybe_show_notes.
77 (concrete_buffer_overflow::get_dir): New.
78 (concrete_buffer_underwrite::concrete_buffer_underwrite): Update
79 for new fields.
80 (concrete_buffer_underwrite::emit): Replace call to
81 maybe_describe_array_bounds with maybe_show_notes.
82 (concrete_buffer_underwrite::get_dir): New.
83 (concrete_buffer_under_read::concrete_buffer_under_read): Update
84 for new fields.
85 (concrete_buffer_under_read::emit): Replace call to
86 maybe_describe_array_bounds with maybe_show_notes.
87 (concrete_buffer_under_read::get_dir): New.
88 (symbolic_past_the_end::symbolic_past_the_end): Update for new
89 fields.
90 (symbolic_buffer_overflow::symbolic_buffer_overflow): Likewise.
91 (symbolic_buffer_overflow::emit): Call maybe_show_notes.
92 (symbolic_buffer_overflow::get_dir): New.
93 (symbolic_buffer_over_read::symbolic_buffer_over_read): Update for
94 new fields.
95 (symbolic_buffer_over_read::emit): Call maybe_show_notes.
96 (symbolic_buffer_over_read::get_dir): New.
97 (region_model::check_symbolic_bounds): Add "sval_hint" param. Pass
98 it and sized_offset_reg to diagnostics.
99 (region_model::check_region_bounds): Add "sval_hint" param, passing
100 it to diagnostics.
101 * diagnostic-manager.cc
102 (diagnostic_manager::emit_saved_diagnostic): Pass logger to
103 pending_diagnostic::emit.
104 * engine.cc: Add logger param to pending_diagnostic::emit
105 implementations.
106 * infinite-recursion.cc: Likewise.
107 * kf-analyzer.cc: Likewise.
108 * kf.cc: Likewise. Add nullptr for new param of
109 check_region_for_write.
110 * pending-diagnostic.h: Likewise in decl.
111 * region-model-manager.cc
112 (region_model_manager::get_or_create_int_cst): Convert param from
113 poly_int64 to const poly_wide_int_ref &.
114 (region_model_manager::maybe_fold_binop): Support type being NULL
115 when checking for floating-point types.
116 Check for (X + Y) - X => Y. Be less strict about types when folding
117 associative ops. Check for (X + Y) * CST => (X * CST) + (Y * CST).
118 * region-model-manager.h
119 (region_model_manager::get_or_create_int_cst): Convert param from
120 poly_int64 to const poly_wide_int_ref &.
121 * region-model.cc: Add logger param to pending_diagnostic::emit
122 implementations.
123 (region_model::check_external_function_for_access_attr): Update
124 for new param of check_region_for_write.
125 (region_model::deref_rvalue): Use nullptr rather than NULL.
126 (region_model::get_capacity): Handle RK_STRING.
127 (region_model::check_region_access): Add "sval_hint" param; pass it to
128 check_region_bounds.
129 (region_model::check_region_for_write): Add "sval_hint" param;
130 pass it to check_region_access.
131 (region_model::check_region_for_read): Add NULL for new param to
132 check_region_access.
133 (region_model::set_value): Pass rhs_sval to
134 check_region_for_write.
135 (region_model::get_representative_path_var_1): Handle SK_CONSTANT
136 in the check for infinite recursion.
137 * region-model.h (region_model::check_region_for_write): Add
138 "sval_hint" param.
139 (region_model::check_region_access): Likewise.
140 (region_model::check_symbolic_bounds): Likewise.
141 (region_model::check_region_bounds): Likewise.
142 * region.cc (region_offset::make_byte_offset): New.
143 (region_offset::calc_symbolic_bit_offset): New.
144 (region_offset::calc_symbolic_byte_offset): New.
145 (region_offset::dump_to_pp): New.
146 (region_offset::dump): New.
147 (struct linear_op): New.
148 (operator<, operator<=, operator>, operator>=): New, for
149 region_offset.
150 (region::get_next_offset): New.
151 (region::get_relative_symbolic_offset): Use ptrdiff_type_node.
152 (field_region::get_relative_symbolic_offset): Likewise.
153 (element_region::get_relative_symbolic_offset): Likewise.
154 (bit_range_region::get_relative_symbolic_offset): Likewise.
155 * region.h (region::get_next_offset): New decl.
156 * sm-fd.cc: Add logger param to pending_diagnostic::emit
157 implementations.
158 * sm-file.cc: Likewise.
159 * sm-malloc.cc: Likewise.
160 * sm-pattern-test.cc: Likewise.
161 * sm-sensitive.cc: Likewise.
162 * sm-signal.cc: Likewise.
163 * sm-taint.cc: Likewise.
164 * store.cc (bit_range::contains_p): Allow "out" to be null.
165 * store.h (byte_range::get_start_bit_offset): New.
166 (byte_range::get_next_bit_offset): New.
167 * varargs.cc: Add logger param to pending_diagnostic::emit
168 implementations.
169
170 2023-06-10 Tim Lange <mail@tim-lange.me>
171
172 PR analyzer/109577
173 * constraint-manager.cc (class sval_finder): Visitor to find
174 childs in svalue trees.
175 (constraint_manager::sval_constrained_p): Add new function to
176 check whether a sval might be part of an constraint.
177 * constraint-manager.h: Add sval_constrained_p function.
178 * region-model.cc (class size_visitor): Reverse behavior to not
179 emit a warning on not explicitly considered cases.
180 (region_model::check_region_size):
181 Adapt to size_visitor changes.
182
183 2023-06-09 David Malcolm <dmalcolm@redhat.com>
184
185 PR analyzer/110112
186 * region-model.cc (region_model::get_initial_value_for_global):
187 Move code to region::calc_initial_value_at_main.
188 * region.cc (region::get_initial_value_at_main): New function.
189 (region::calc_initial_value_at_main): New function, based on code
190 in region_model::get_initial_value_for_global.
191 (region::region): Initialize m_cached_init_sval_at_main.
192 (decl_region::get_svalue_for_constructor): Add a cache, splitting
193 out body to...
194 (decl_region::calc_svalue_for_constructor): ...this new function.
195 * region.h (region::get_initial_value_at_main): New decl.
196 (region::calc_initial_value_at_main): New decl.
197 (region::m_cached_init_sval_at_main): New field.
198 (decl_region::decl_region): Initialize m_ctor_svalue.
199 (decl_region::calc_svalue_for_constructor): New decl.
200 (decl_region::m_ctor_svalue): New field.
201
202 2023-06-08 Benjamin Priour <vultkayn@gcc.gnu.org>
203
204 * bounds-checking.cc (region_model::check_symbolic_bounds): Returns whether the BASE_REG
205 region access was OOB.
206 (region_model::check_region_bounds): Likewise.
207 * region-model.cc (region_model::get_store_value): Creates an
208 unknown svalue on OOB-read access to REG.
209 (region_model::check_region_access): Returns whether an unknown svalue needs be created.
210 (region_model::check_region_for_read): Passes check_region_access return value.
211 * region-model.h: Update prior function definitions.
212
213 2023-06-02 David Malcolm <dmalcolm@redhat.com>
214
215 PR analyzer/109015
216 * kf.cc (class kf_atomic_exchange): New.
217 (class kf_atomic_exchange_n): New.
218 (class kf_atomic_fetch_op): New.
219 (class kf_atomic_op_fetch): New.
220 (class kf_atomic_load): New.
221 (class kf_atomic_load_n): New.
222 (class kf_atomic_store_n): New.
223 (register_atomic_builtins): New function.
224 (register_known_functions): Call register_atomic_builtins.
225
226 2023-06-02 David Malcolm <dmalcolm@redhat.com>
227
228 * store.cc (store::eval_alias_1): Regions in different memory
229 spaces can't alias.
230
231 2023-05-18 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
232
233 * region-model-manager.cc (get_code_for_cast): Use _P defines from
234 tree.h.
235 (region_model_manager::get_or_create_cast): Ditto.
236 (region_model_manager::get_region_for_global): Ditto.
237 * region-model.cc (region_model::get_lvalue_1): Ditto.
238 * region.cc (decl_region::maybe_get_constant_value): Ditto.
239
240 2023-03-22 David Malcolm <dmalcolm@redhat.com>
241
242 PR analyzer/109239
243 * program-point.cc: Include "analyzer/inlining-iterator.h".
244 (program_point::effectively_intraprocedural_p): New function.
245 * program-point.h (program_point::effectively_intraprocedural_p):
246 New decl.
247 * sm-malloc.cc (deref_before_check::emit): Use it when rejecting
248 interprocedural cases, so that we reject interprocedural cases
249 that have become intraprocedural due to inlining.
250
251 2023-03-18 David Malcolm <dmalcolm@redhat.com>
252
253 PR analyzer/109094
254 * region-model.cc (region_model::on_longjmp): Pass false for
255 new "eval_return_svalue" param of pop_frame.
256 (region_model::pop_frame): Add new "eval_return_svalue" param and
257 use it to suppress the call to get_rvalue on the result when
258 needed by on_longjmp.
259 * region-model.h (region_model::pop_frame): Add new
260 "eval_return_svalue" param.
261
262 2023-03-10 David Malcolm <dmalcolm@redhat.com>
263
264 PR analyzer/109059
265 * region-model.cc (region_model::mark_region_as_unknown): Gather a
266 set of maybe-live svalues and call on_maybe_live_values with it.
267 * store.cc (binding_map::remove_overlapping_bindings): Add new
268 "maybe_live_values" param; add any removed svalues to it.
269 (binding_cluster::clobber_region): Add NULL as new param of
270 remove_overlapping_bindings.
271 (binding_cluster::mark_region_as_unknown): Add "maybe_live_values"
272 param and pass it to remove_overlapping_bindings.
273 (binding_cluster::maybe_get_compound_binding): Add NULL for new
274 param of binding_map::remove_overlapping_bindings.
275 (binding_cluster::remove_overlapping_bindings): Add
276 "maybe_live_values" param and pass to
277 binding_map::remove_overlapping_bindings.
278 (store::set_value): Capture a set of maybe-live svalues, and call
279 on_maybe_live_values with it.
280 (store::on_maybe_live_values): New.
281 (store::mark_region_as_unknown): Add "maybe_live_values" param
282 and pass it to binding_cluster::mark_region_as_unknown.
283 (store::remove_overlapping_bindings): Pass NULL for new param of
284 binding_cluster::remove_overlapping_bindings.
285 * store.h (binding_map::remove_overlapping_bindings): Add
286 "maybe_live_values" param.
287 (binding_cluster::mark_region_as_unknown): Likewise.
288 (binding_cluster::remove_overlapping_bindings): Likewise.
289 (store::mark_region_as_unknown): Likewise.
290 (store::on_maybe_live_values): New decl.
291
292 2023-03-10 David Malcolm <dmalcolm@redhat.com>
293
294 PR analyzer/108475
295 PR analyzer/109060
296 * sm-malloc.cc (deref_before_check::deref_before_check):
297 Initialize new field m_deref_expr. Assert that arg is non-NULL.
298 (deref_before_check::emit): Reject cases where the spelling of the
299 thing that was dereferenced differs from that of what is checked,
300 or if the dereference expression was not found. Remove code to
301 handle NULL m_arg.
302 (deref_before_check::describe_state_change): Remove code to handle
303 NULL m_arg.
304 (deref_before_check::describe_final_event): Likewise.
305 (deref_before_check::sufficiently_similar_p): New.
306 (deref_before_check::m_deref_expr): New field.
307 (malloc_state_machine::maybe_complain_about_deref_before_check):
308 Don't warn if the diag_ptr is NULL.
309
310 2023-03-03 David Malcolm <dmalcolm@redhat.com>
311
312 * kf.cc (class kf_sprintf): New.
313 (register_known_functions): Register it.
314
315 2023-03-02 David Malcolm <dmalcolm@redhat.com>
316
317 PR analyzer/108968
318 * region-model.cc (region_model::get_rvalue_1): Handle VAR_DECLs
319 with a DECL_HARD_REGISTER by returning UNKNOWN.
320
321 2023-03-02 Hans-Peter Nilsson <hp@axis.com>
322
323 * kf.cc (register_known_functions): Add __errno function for newlib.
324
325 2023-03-01 David Malcolm <dmalcolm@redhat.com>
326
327 PR analyzer/107565
328 * region-model.cc (region_model::on_call_pre): Flatten logic by
329 returning early. Consolidate logic for detecting const and pure
330 functions. When considering whether an unhandled built-in
331 function has side-effects, consider all kinds of builtin, rather
332 than just BUILT_IN_NORMAL, and don't require
333 gimple_builtin_call_types_compatible_p.
334
335 2023-03-01 David Malcolm <dmalcolm@redhat.com>
336
337 PR analyzer/108935
338 * infinite-recursion.cc (contains_unknown_p): New.
339 (sufficiently_different_region_binding_p): New function, splitting
340 out inner loop from...
341 (sufficiently_different_p): ...here. Extend detection of unknown
342 svalues to also include svalues that contain unknown. Treat
343 changes in frames below the entry to the recursion as being
344 sufficiently different to reject being an infinite recursion.
345
346 2023-02-21 David Malcolm <dmalcolm@redhat.com>
347
348 PR analyzer/108830
349 * analyzer.opt (fanalyzer-suppress-followups): New option.
350 * engine.cc (impl_region_model_context::warn): Terminate the path
351 if the diagnostic's terminate_path_p vfunc returns true and
352 -fanalyzer-suppress-followups is true (the default).
353 (impl_sm_context::warn): Likewise, for both overloads.
354 * pending-diagnostic.h (pending_diagnostic::terminate_path_p): New
355 vfunc.
356 * program-state.cc (program_state::on_edge): Terminate the path if
357 the ctxt requests it during updating the edge.
358 * region-model.cc (poisoned_value_diagnostic::terminate_path_p):
359 New vfunc.
360 * sm-malloc.cc (null_deref::terminate_path_p): New vfunc.
361 (null_arg::terminate_path_p): New vfunc.
362
363 2023-02-16 David Malcolm <dmalcolm@redhat.com>
364
365 PR analyzer/108806
366 * constraint-manager.cc (bounded_range::dump_to_pp): Use
367 bounded_range::singleton_p.
368 (constraint_manager::add_bounded_ranges): Handle singleton ranges
369 by adding an EQ_EXPR constraint.
370 (constraint_manager::impossible_derived_conditions_p): New.
371 (constraint_manager::eval_condition): Reject EQ_EXPR when it would
372 imply impossible derived conditions.
373 (selftest::test_bits): New.
374 (selftest::run_constraint_manager_tests): Run it.
375 * constraint-manager.h (bounded_range::singleton_p): New.
376 (constraint_manager::impossible_derived_conditions_p): New decl.
377 * region-model.cc (region_model::get_rvalue_1): Handle
378 BIT_AND_EXPR, BIT_IOR_EXPR, and BIT_XOR_EXPR.
379
380 2023-02-15 David Malcolm <dmalcolm@redhat.com>
381
382 PR analyzer/108664
383 PR analyzer/108666
384 PR analyzer/108725
385 * diagnostic-manager.cc (epath_finder::get_best_epath): Add
386 "target_stmt" param.
387 (epath_finder::explore_feasible_paths): Likewise.
388 (epath_finder::process_worklist_item): Likewise.
389 (saved_diagnostic::calc_best_epath): Pass m_stmt to
390 epath_finder::get_best_epath.
391 * engine.cc (feasibility_state::maybe_update_for_edge): Move
392 per-stmt logic to...
393 (feasibility_state::update_for_stmt): ...this new function.
394 * exploded-graph.h (feasibility_state::update_for_stmt): New decl.
395 * feasible-graph.cc (feasible_node::get_state_at_stmt): New.
396 * feasible-graph.h: Include "analyzer/exploded-graph.h".
397 (feasible_node::get_state_at_stmt): New decl.
398 * infinite-recursion.cc
399 (infinite_recursion_diagnostic::check_valid_fpath_p): Update for
400 vfunc signature change.
401 * pending-diagnostic.h (pending_diagnostic::check_valid_fpath_p):
402 Convert first param to a reference. Add stmt param.
403 * region-model.cc: Include "analyzer/feasible-graph.h".
404 (poisoned_value_diagnostic::poisoned_value_diagnostic): Add
405 "check_expr" param.
406 (poisoned_value_diagnostic::check_valid_fpath_p): New.
407 (poisoned_value_diagnostic::m_check_expr): New field.
408 (region_model::check_for_poison): Attempt to supply a check_expr
409 to the diagnostic
410 (region_model::deref_rvalue): Add NULL for new check_expr param
411 of poisoned_value_diagnostic.
412 (region_model::get_or_create_region_for_heap_alloc): Don't reuse
413 regions that are marked as TOUCHED.
414
415 2023-02-10 David Malcolm <dmalcolm@redhat.com>
416
417 PR analyzer/108745
418 * sm-malloc.cc (deref_before_check::emit): Reject the warning if
419 the check occurs within a macro defintion.
420
421 2023-02-09 David Malcolm <dmalcolm@redhat.com>
422
423 PR analyzer/108733
424 * state-purge.cc (get_candidate_for_purging): Add ADDR_EXPR
425 and MEM_REF.
426
427 2023-02-08 David Malcolm <dmalcolm@redhat.com>
428
429 PR analyzer/108704
430 * state-purge.cc (state_purge_per_decl::process_point_backwards):
431 Don't stop processing the decl if it's fully overwritten by
432 this stmt if it's also used by this stmt.
433
434 2023-02-07 David Malcolm <dmalcolm@redhat.com>
435
436 PR analyzer/108661
437 * sm-fd.cc (class kf_read): New.
438 (register_known_fd_functions): Register "read".
439 * sm-file.cc (class kf_fread): Update comment.
440
441 2023-02-02 David Malcolm <dmalcolm@redhat.com>
442
443 PR analyzer/108633
444 * sm-fd.cc (fd_state_machine::check_for_fd_attrs): Add missing
445 "continue".
446 (fd_state_machine::on_listen): Don't issue phase-mismatch or
447 type-mismatch warnings for the "invalid" state.
448
449 2023-02-01 David Malcolm <dmalcolm@redhat.com>
450
451 PR analyzer/108616
452 * pending-diagnostic.cc (fixup_location_in_macro_p): Add "alloca"
453 to macros that we shouldn't unwind inside.
454
455 2023-01-26 David Malcolm <dmalcolm@redhat.com>
456
457 PR analyzer/108524
458 * analyzer.h (class feasible_node): New forward decl.
459 * diagnostic-manager.cc (epath_finder::get_best_epath): Add "pd"
460 param.
461 (epath_finder::explore_feasible_paths): Likewise.
462 (epath_finder::process_worklist_item): Likewise. Use it to call
463 pending_diagnostic::check_valid_fpath_p on the final fpath to
464 give pending_diagnostic a way to add additional restrictions on
465 feasibility.
466 (saved_diagnostic::calc_best_epath): Pass pending_diagnostic to
467 epath_finder::get_best_epath.
468 * infinite-recursion.cc: Include "analyzer/feasible-graph.h".
469 (infinite_recursion_diagnostic::check_valid_fpath_p): New.
470 (infinite_recursion_diagnostic::fedge_uses_conjured_svalue_p): New.
471 (infinite_recursion_diagnostic::expr_uses_conjured_svalue_p): New.
472 * pending-diagnostic.h (pending_diagnostic::check_valid_fpath_p):
473 New vfunc.
474
475 2023-01-19 David Malcolm <dmalcolm@redhat.com>
476
477 PR analyzer/108455
478 * analyzer.h (class checker_event): New forward decl.
479 (class state_change_event): Indent.
480 (class warning_event): New forward decl.
481 * checker-event.cc (state_change_event::state_change_event): Add
482 "enode" param.
483 (warning_event::get_desc): Update for new param of
484 evdesc::final_event ctor.
485 * checker-event.h (state_change_event::state_change_event): Add
486 "enode" param.
487 (state_change_event::get_exploded_node): New accessor.
488 (state_change_event::m_enode): New field.
489 (warning_event::warning_event): New "enode" param.
490 (warning_event::get_exploded_node): New accessor.
491 (warning_event::m_enode): New field.
492 * diagnostic-manager.cc
493 (state_change_event_creator::on_global_state_change): Pass
494 src_node to state_change_event ctor.
495 (state_change_event_creator::on_state_change): Likewise.
496 (null_assignment_sm_context::set_next_state): Pass NULL for
497 new param of state_change_event ctor.
498 * infinite-recursion.cc
499 (infinite_recursion_diagnostic::add_final_event): Update for new
500 param of warning_event ctor.
501 * pending-diagnostic.cc (pending_diagnostic::add_final_event):
502 Pass enode to warning_event ctor.
503 * pending-diagnostic.h (evdesc::final_event): Add reference to
504 warning_event.
505 * sm-malloc.cc: Include "analyzer/checker-event.h" and
506 "analyzer/exploded-graph.h".
507 (deref_before_check::deref_before_check): Initialize new fields.
508 (deref_before_check::emit): Reject warnings in which we were
509 unable to determine the enodes of the dereference and the check.
510 Reject warnings interprocedural warnings. Reject warnings in which
511 the dereference doesn't dominate the check.
512 (deref_before_check::describe_state_change): Set m_deref_enode.
513 (deref_before_check::describe_final_event): Set m_check_enode.
514 (deref_before_check::m_deref_enode): New field.
515 (deref_before_check::m_check_enode): New field.
516
517 2023-01-13 David Malcolm <dmalcolm@redhat.com>
518
519 PR analyzer/105273
520 * region-model.cc (has_nondefault_case_for_value_p): New.
521 (has_nondefault_cases_for_all_enum_values_p): New.
522 (region_model::apply_constraints_for_gswitch): Skip
523 implicitly-created "default" when switching on an enum
524 and all enum values have non-default cases.
525 (rejected_default_case::dump_to_pp): New.
526 * region-model.h (region_model_context::possibly_tainted_p): New
527 decl.
528 (class rejected_default_case): New.
529 * sm-taint.cc (region_model_context::possibly_tainted_p): New.
530 * supergraph.cc (switch_cfg_superedge::dump_label_to_pp): Dump
531 when implicitly_created_default_p.
532 (switch_cfg_superedge::implicitly_created_default_p): New.
533 * supergraph.h
534 (switch_cfg_superedge::implicitly_created_default_p): New decl.
535
536 2023-01-11 David Malcolm <dmalcolm@redhat.com>
537
538 PR analyzer/108252
539 * kf.cc (class kf_strdup): New.
540 (class kf_strndup): New.
541 (register_known_functions): Register them.
542 * region-model.cc (region_model::on_call_pre): Use
543 &HEAP_ALLOCATED_REGION for the default result of an external
544 function with the "malloc" attribute, rather than CONJURED_SVALUE.
545 (region_model::get_or_create_region_for_heap_alloc): Allow
546 "size_in_bytes" to be NULL.
547 * store.cc (store::set_value): When handling *UNKNOWN = VAL,
548 mark VAL as "maybe bound".
549
550 2022-12-16 David Malcolm <dmalcolm@redhat.com>
551
552 PR analyzer/106479
553 * kf.cc (kf_memcpy_memmove::impl_call_pre): Pass in source region
554 to region_model::check_for_poison.
555 * region-model-asm.cc (region_model::on_asm_stmt): Pass NULL
556 region to region_model::check_for_poison.
557 * region-model.cc (region_model::check_for_poison): Add
558 "src_region" param, and pass it to poisoned_value_diagnostic.
559 (region_model::on_assignment): Pass NULL region to
560 region_model::check_for_poison.
561 (region_model::get_rvalue): Likewise.
562 * region-model.h (region_model::check_for_poison): Add
563 "src_region" param.
564 * sm-fd.cc (fd_state_machine::on_accept): Pass in source region
565 to region_model::check_for_poison.
566 * varargs.cc (kf_va_copy::impl_call_pre): Pass NULL region to
567 region_model::check_for_poison.
568 (kf_va_arg::impl_call_pre): Pass in source region to
569 region_model::check_for_poison.
570
571 2022-12-14 David Malcolm <dmalcolm@redhat.com>
572
573 PR analyzer/108065
574 * region.cc (decl_region::get_svalue_for_initializer): Bail out to
575 avoid calling binding_key::make with an empty region.
576 * store.cc (binding_map::apply_ctor_val_to_range): Likewise.
577 (binding_map::apply_ctor_pair_to_child_region): Likewise.
578 (binding_cluster::bind): Likewise.
579 (binding_cluster::purge_region): Likewise.
580 (binding_cluster::maybe_get_compound_binding): Likewise.
581 (binding_cluster::maybe_get_simple_value): Likewise.
582
583 2022-12-09 David Malcolm <dmalcolm@redhat.com>
584
585 * analyzer.h (class known_function): Expand comment.
586 * region-model-impl-calls.cc: Rename to...
587 * kf.cc: ...this.
588 * known-function-manager.h (class known_function_manager): Add
589 leading comment.
590
591 2022-12-09 David Malcolm <dmalcolm@redhat.com>
592
593 PR analyzer/108003
594 * call-summary.cc
595 (call_summary_replay::convert_region_from_summary_1): Convert
596 heap_regs_in_use from auto_sbitmap to auto_bitmap.
597 * region-model-manager.cc
598 (region_model_manager::get_or_create_region_for_heap_alloc):
599 Convert from sbitmap to bitmap.
600 * region-model-manager.h: Likewise.
601 * region-model.cc
602 (region_model::get_or_create_region_for_heap_alloc): Convert from
603 auto_sbitmap to auto_bitmap.
604 (region_model::get_referenced_base_regions): Likewise.
605 * region-model.h: Include "bitmap.h" rather than "sbitmap.h".
606 (region_model::get_referenced_base_regions): Convert from
607 auto_sbitmap to auto_bitmap.
608
609 2022-12-09 David Malcolm <dmalcolm@redhat.com>
610
611 * region-model-impl-calls.cc (class kf_memcpy): Rename to...
612 (class kf_memcpy_memmove): ...this.
613 (kf_memcpy::impl_call_pre): Rename to...
614 (kf_memcpy_memmove::impl_call_pre): ...this, and check the src for
615 poison.
616 (register_known_functions): Update for above renaming, and
617 register BUILT_IN_MEMMOVE and BUILT_IN_MEMMOVE_CHK.
618
619 2022-12-06 David Malcolm <dmalcolm@redhat.com>
620
621 PR analyzer/107882
622 * region-model.cc (region_model::get_store_value): Return an
623 unknown value for empty regions.
624 (region_model::set_value): Bail on empty regions.
625 * region.cc (region::empty_p): New.
626 * region.h (region::empty_p): New decl.
627 * state-purge.cc (same_binding_p): Bail if either region is empty.
628 * store.cc (binding_key::make): Assert that a concrete binding's
629 bit_size must be > 0.
630 (binding_cluster::mark_region_as_unknown): Bail on empty regions.
631 (binding_cluster::get_binding): Likewise.
632 (binding_cluster::remove_overlapping_bindings): Likewise.
633 (binding_cluster::on_unknown_fncall): Don't conjure values for
634 empty regions.
635 (store::fill_region): Bail on empty regions.
636 * store.h (class concrete_binding): Update comment to reflect that
637 the range of bits must be non-empty.
638 (concrete_binding::concrete_binding): Assert that bit range is
639 non-empty.
640
641 2022-12-06 David Malcolm <dmalcolm@redhat.com>
642
643 PR analyzer/106325
644 * region-model-manager.cc
645 (region_model_manager::get_or_create_null_ptr): New.
646 * region-model-manager.h
647 (region_model_manager::get_or_create_null_ptr): New decl.
648 * region-model.cc (region_model::on_top_level_param): Add
649 "nonnull" param and make use of it.
650 (region_model::push_frame): When handling a top-level entrypoint
651 to the analysis, determine which params __attribute__((nonnull))
652 applies to, and pass to on_top_level_param.
653 * region-model.h (region_model::on_top_level_param): Add "nonnull"
654 param.
655
656 2022-12-06 David Malcolm <dmalcolm@redhat.com>
657
658 * analyzer.h (register_known_analyzer_functions): New decl.
659 (register_known_functions_lang_cp): New decl.
660 * call-details.cc: New file, split out from
661 region-model-impl-calls.cc.
662 * call-details.h: New file, split out from region-model.h.
663 * call-info.cc: Include "analyzer/call-details.h".
664 * call-summary.h: Likewise.
665 * kf-analyzer.cc: New file, split out from
666 region-model-impl-calls.cc.
667 * kf-lang-cp.cc: Likewise.
668 * known-function-manager.cc: Include "analyzer/call-details.h".
669 * region-model-impl-calls.cc: Move definitions of call_details's
670 member functions to call-details.cc. Move class kf_analyzer_* to
671 kf-analyzer.cc. Move kf_operator_new and kf_operator_delete to
672 kf-lang-cp.cc. Refresh #includes accordingly.
673 (register_known_functions): Replace registration of __analyzer_*
674 functions with a call to register_known_analyzer_functions.
675 Replace registration of C++ support functions with a call to
676 register_known_functions_lang_cp.
677 * region-model.h (class call_details): Move to new call-details.h.
678 * sm-fd.cc: Include "analyzer/call-details.h".
679 * sm-file.cc: Likewise.
680 * sm-malloc.cc: Likewise.
681 * varargs.cc: Likewise.
682
683 2022-12-02 David Malcolm <dmalcolm@redhat.com>
684
685 * analyzer.h (struct event_loc_info): New forward decl.
686 * bounds-checking.cc: Use event_loc_info throughout to bundle the
687 loc, fndecl, depth triples.
688 * call-info.cc: Likewise.
689 * checker-event.cc: Likewise.
690 * checker-event.h (struct event_loc_info): New decl. Use it
691 throughout to bundle the loc, fndecl, depth triples.
692 * checker-path.cc: Likewise.
693 * checker-path.h: Likewise.
694 * diagnostic-manager.cc: Likewise.
695 * engine.cc: Likewise.
696 * infinite-recursion.cc: Likewise.
697 * pending-diagnostic.cc: Likewise.
698 * pending-diagnostic.h: Likewise.
699 * region-model.cc: Likewise.
700 * sm-signal.cc: Likewise.
701 * varargs.cc: Likewise.
702
703 2022-12-02 David Malcolm <dmalcolm@redhat.com>
704
705 PR analyzer/107851
706 * analyzer.cc (make_label_text_n): Convert param "n" from int to
707 unsigned HOST_WIDE_INT.
708 * analyzer.h (make_label_text_n): Likewise for decl.
709 * bounds-checking.cc: Include "analyzer/checker-event.h" and
710 "analyzer/checker-path.h".
711 (out_of_bounds::add_region_creation_events): New.
712 (concrete_past_the_end::describe_region_creation_event): Replace
713 with...
714 (concrete_past_the_end::add_region_creation_events): ...this.
715 (symbolic_past_the_end::describe_region_creation_event): Delete.
716 * checker-event.cc (region_creation_event::region_creation_event):
717 Update for dropping all member data.
718 (region_creation_event::get_desc): Delete, splitting out into
719 region_creation_event_memory_space::get_desc,
720 region_creation_event_capacity::get_desc, and
721 region_creation_event_debug::get_desc.
722 (region_creation_event_memory_space::get_desc): New.
723 (region_creation_event_capacity::get_desc): New.
724 (region_creation_event_allocation_size::get_desc): New.
725 (region_creation_event_debug::get_desc): New.
726 * checker-event.h: Include "analyzer/program-state.h".
727 (enum rce_kind): Delete.
728 (class region_creation_event): Drop all member data.
729 (region_creation_event::region_creation_event): Make protected.
730 (region_creation_event::get_desc): Delete.
731 (class region_creation_event_memory_space): New.
732 (class region_creation_event_capacity): New.
733 (class region_creation_event_allocation_size): New.
734 (class region_creation_event_debug): New.
735 * checker-path.cc (checker_path::add_region_creation_events): Add
736 "pd" param. Call pending_diangnostic::add_region_creation_events.
737 Update for conversion of RCE_DEBUG to region_creation_event_debug.
738 * checker-path.h (checker_path::add_region_creation_events): Add
739 "pd" param.
740 * diagnostic-manager.cc (diagnostic_manager::build_emission_path):
741 Pass pending_diagnostic to
742 emission_path::add_region_creation_events.
743 (diagnostic_manager::build_emission_path): Pass path_builder to
744 add_event_on_final_node.
745 (diagnostic_manager::add_event_on_final_node): Add "pb" param.
746 Pass pending_diagnostic to
747 emission_path::add_region_creation_events.
748 (diagnostic_manager::add_events_for_eedge): Pass
749 pending_diagnostic to emission_path::add_region_creation_events.
750 * diagnostic-manager.h
751 (diagnostic_manager::add_event_on_final_node): Add "pb" param.
752 * pending-diagnostic.cc
753 (pending_diagnostic::add_region_creation_events): New.
754 * pending-diagnostic.h (struct region_creation): Delete.
755 (pending_diagnostic::describe_region_creation_event): Delete.
756 (pending_diagnostic::add_region_creation_events): New vfunc.
757 * region-model.cc: Include "analyzer/checker-event.h" and
758 "analyzer/checker-path.h".
759 (dubious_allocation_size::dubious_allocation_size): Initialize
760 m_has_allocation_event.
761 (dubious_allocation_size::describe_region_creation_event): Delete.
762 (dubious_allocation_size::describe_final_event): Update for
763 replacement of m_allocation_event with m_has_allocation_event.
764 (dubious_allocation_size::add_region_creation_events): New.
765 (dubious_allocation_size::m_allocation_event): Replace with...
766 (dubious_allocation_size::m_has_allocation_event): ...this.
767
768 2022-12-02 David Malcolm <dmalcolm@redhat.com>
769
770 PR analyzer/107948
771 * region-model-manager.cc
772 (region_model_manager::maybe_fold_binop): Fold (0 - VAL) to -VAL.
773 * region-model.cc (region_model::eval_condition): Handle e.g.
774 "-X <= 0" as equivalent to X >= 0".
775
776 2022-12-01 David Malcolm <dmalcolm@redhat.com>
777
778 PR analyzer/106626
779 * bounds-checking.cc
780 (symbolic_past_the_end::describe_final_event): Delete, moving to
781 symbolic_buffer_overflow::describe_final_event and
782 symbolic_buffer_over_read::describe_final_event, eliminating
783 composition of text strings via "byte_str" and "m_dir_str".
784 (symbolic_past_the_end::m_dir_str): Delete field.
785 (symbolic_buffer_overflow::symbolic_buffer_overflow): Drop
786 m_dir_str.
787 (symbolic_buffer_overflow::describe_final_event): New, as noted
788 above.
789 (symbolic_buffer_over_read::symbolic_buffer_overflow): Drop
790 m_dir_str.
791 (symbolic_buffer_over_read::describe_final_event): New, as noted
792 above.
793
794 2022-12-01 David Malcolm <dmalcolm@redhat.com>
795
796 * bounds-checking.cc (class out_of_bounds): Split out from...
797 (class concrete_out_of_bounds): New abstract subclass.
798 (class past_the_end): Rename to...
799 (class concrete_past_the_end): ...this, and make a subclass of
800 concrete_out_of_bounds.
801 (class buffer_overflow): Rename to...
802 (class concrete_buffer_overflow): ...this, and make a subclass of
803 concrete_past_the_end.
804 (class buffer_over_read): Rename to...
805 (class concrete_buffer_over_read): ...this, and make a subclass of
806 concrete_past_the_end.
807 (class buffer_underwrite): Rename to...
808 (class concrete_buffer_underwrite): ...this, and make a subclass
809 of concrete_out_of_bounds.
810 (class buffer_under_read): Rename to...
811 (class concrete_buffer_under_read): ...this, and make a subclass
812 of concrete_out_of_bounds.
813 (class symbolic_past_the_end): Convert to a subclass of
814 out_of_bounds.
815 (symbolic_buffer_overflow::get_kind): New.
816 (symbolic_buffer_over_read::get_kind): New.
817 (region_model::check_region_bounds): Update for renamings.
818 * engine.cc (impl_sm_context::set_next_state): Eliminate
819 "new_ctxt", passing NULL to get_rvalue instead.
820 (impl_sm_context::warn): Likewise.
821
822 2022-12-01 David Malcolm <dmalcolm@redhat.com>
823
824 PR analyzer/106626
825 * bounds-checking.cc (out_of_bounds::get_memory_space): New.
826 (buffer_overflow::emit): Use it.
827 (class buffer_overread): Rename to...
828 (class buffer_over_read): ...this.
829 (buffer_over_read::emit): Specify which memory space the read is
830 from, where known. Change "overread" to "over-read".
831 (class buffer_underflow): Rename to...
832 (class buffer_underwrite): ...this.
833 (buffer_underwrite::emit): Specify which memory space the write is
834 to, where known. Change "underflow" to "underwrite".
835 (class buffer_underread): Rename to...
836 (class buffer_under_read): Rename to...
837 (buffer_under_read::emit): Specify which memory space the read is
838 from, where known. Change "underread" to "under-read".
839 (symbolic_past_the_end::get_memory_space): New.
840 (symbolic_buffer_overflow::emit): Use it.
841 (class symbolic_buffer_overread): Rename to...
842 (class symbolic_buffer_over_read): ...this.
843 (symbolic_buffer_over_read::emit): Specify which memory space the
844 read is from, where known. Change "overread" to "over-read".
845 (region_model::check_symbolic_bounds): Update for class renaming.
846 (region_model::check_region_bounds): Likewise.
847
848 2022-12-01 David Malcolm <dmalcolm@redhat.com>
849
850 PR analyzer/106626
851 * bounds-checking.cc (out_of_bounds::maybe_describe_array_bounds):
852 New.
853 (buffer_overflow::emit): Call maybe_describe_array_bounds.
854 (buffer_overread::emit): Likewise.
855 (buffer_underflow::emit): Likewise.
856 (buffer_underread::emit): Likewise.
857
858 2022-12-01 David Malcolm <dmalcolm@redhat.com>
859
860 PR analyzer/106626
861 * bounds-checking.cc (buffer_overflow::emit): Use inform_n.
862 Update wording to clarify that we're talking about the size of
863 the bad access, rather than its position.
864 (buffer_overread::emit): Likewise.
865
866 2022-12-01 David Malcolm <dmalcolm@redhat.com>
867
868 * bounds-checking.cc: New file, taken from region-model.cc.
869 * region-model.cc (class out_of_bounds): Move to
870 bounds-checking.cc.
871 (class past_the_end): Likewise.
872 (class buffer_overflow): Likewise.
873 (class buffer_overread): Likewise.
874 (class buffer_underflow): Likewise.
875 (class buffer_underread): Likewise.
876 (class symbolic_past_the_end): Likewise.
877 (class symbolic_buffer_overflow): Likewise.
878 (class symbolic_buffer_overread): Likewise.
879 (region_model::check_symbolic_bounds): Likewise.
880 (maybe_get_integer_cst_tree): Likewise.
881 (region_model::check_region_bounds): Likewise.
882 * region-model.h: Add comment.
883
884 2022-12-01 David Malcolm <dmalcolm@redhat.com>
885
886 PR analyzer/107928
887 * sm-fd.cc (fd_state_machine::on_bind): Handle m_constant_fd in
888 the "success" outcome.
889 (fd_state_machine::on_connect): Likewise.
890 * sm-fd.dot: Add "constant_fd" state and its transitions.
891
892 2022-11-30 David Malcolm <dmalcolm@redhat.com>
893
894 * region-model-impl-calls.cc (class kf_fgets): Move to sm-file.cc.
895 (kf_fgets::impl_call_pre): Likewise.
896 (class kf_fread): Likewise.
897 (kf_fread::impl_call_pre): Likewise.
898 (class kf_getchar): Likewise.
899 (class kf_stdio_output_fn): Likewise.
900 (register_known_functions): Move registration of
901 BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC,
902 BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
903 BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
904 BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTCHAR,
905 BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_PUTS,
906 BUILT_IN_PUTS_UNLOCKED, BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF,
907 "getchar", "fgets", "fgets_unlocked", and "fread" to
908 register_known_file_functions.
909 * sm-file.cc (class kf_stdio_output_fn): Move here from
910 region-model-impl-calls.cc.
911 (class kf_fgets): Likewise.
912 (class kf_fread): Likewise.
913 (class kf_getchar): Likewise.
914 (register_known_file_functions): Move registration of
915 BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC,
916 BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
917 BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
918 BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTCHAR,
919 BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_PUTS,
920 BUILT_IN_PUTS_UNLOCKED, BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF,
921 "fgets", "fgets_unlocked", "fread", and "getchar" to here from
922 register_known_functions.
923
924 2022-11-30 David Malcolm <dmalcolm@redhat.com>
925
926 PR analyzer/103546
927 * analyzer.h (register_known_file_functions): New decl.
928 * program-state.cc (sm_state_map::replay_call_summary): Rejct
929 attempts to store sm-state for caller_sval that can't have
930 associated state.
931 * region-model-impl-calls.cc (register_known_functions): Call
932 register_known_file_functions.
933 * sm-fd.cc (class kf_isatty): New.
934 (register_known_fd_functions): Register it.
935 * sm-file.cc (class kf_ferror): New.
936 (class kf_fileno): New.
937 (class kf_getc): New.
938 (register_known_file_functions): New.
939
940 2022-11-30 David Malcolm <dmalcolm@redhat.com>
941
942 PR analyzer/105784
943 * region-model-manager.cc
944 (region_model_manager::maybe_fold_binop): For POINTER_PLUS_EXPR,
945 PLUS_EXPR and MINUS_EXPR, eliminate requirement that the final
946 type matches that of arg0 in favor of a cast.
947
948 2022-11-24 Martin Liska <mliska@suse.cz>
949
950 * varargs.cc: Fix Clang warnings.
951
952 2022-11-24 David Malcolm <dmalcolm@redhat.com>
953
954 PR analyzer/106473
955 * call-summary.cc
956 (call_summary_replay::convert_region_from_summary_1): Update for
957 change to creation of heap-allocated regions.
958 * program-state.cc (test_program_state_1): Likewise.
959 (test_program_state_merging): Likewise.
960 * region-model-impl-calls.cc (kf_calloc::impl_call_pre): Likewise.
961 (kf_malloc::impl_call_pre): Likewise.
962 (kf_operator_new::impl_call_pre): Likewise.
963 (kf_realloc::impl_call_postsuccess_with_move::update_model): Likewise.
964 * region-model-manager.cc
965 (region_model_manager::create_region_for_heap_alloc): Convert
966 to...
967 (region_model_manager::get_or_create_region_for_heap_alloc):
968 ...this, reusing an existing region if it's unreferenced in the
969 client state.
970 * region-model-manager.h (region_model_manager::get_num_regions): New.
971 (region_model_manager::create_region_for_heap_alloc): Convert to...
972 (region_model_manager::get_or_create_region_for_heap_alloc): ...this.
973 * region-model.cc (region_to_value_map::can_merge_with_p): Reject
974 merger when the values are different.
975 (region_model::create_region_for_heap_alloc): Convert to...
976 (region_model::get_or_create_region_for_heap_alloc): ...this.
977 (region_model::get_referenced_base_regions): New.
978 (selftest::test_state_merging): Update for change to creation of
979 heap-allocated regions.
980 (selftest::test_malloc_constraints): Likewise.
981 (selftest::test_malloc): Likewise.
982 * region-model.h: Include "sbitmap.h".
983 (region_model::create_region_for_heap_alloc): Convert to...
984 (region_model::get_or_create_region_for_heap_alloc): ...this.
985 (region_model::get_referenced_base_regions): New decl.
986 * store.cc (store::canonicalize): Don't purge a heap-allocated region
987 that's been marked as escaping.
988
989 2022-11-24 David Malcolm <dmalcolm@redhat.com>
990
991 * checker-path.cc (checker_path::inject_any_inlined_call_events):
992 Don't dump the address of the block when -fdump-noaddr.
993
994 2022-11-24 David Malcolm <dmalcolm@redhat.com>
995
996 * region-model.h (region_model::on_socket): Delete decl.
997 (region_model::on_bind): Likewise.
998 (region_model::on_listen): Likewise.
999 (region_model::on_accept): Likewise.
1000 (region_model::on_connect): Likewise.
1001 * sm-fd.cc (kf_socket::outcome_of_socket::update_model): Move body
1002 of region_model::on_socket into here, ...
1003 (region_model::on_socket): ...eliminating this function.
1004 (kf_bind::outcome_of_bind::update_model): Likewise for on_bind...
1005 (region_model::on_bind): ...eliminating this function.
1006 (kf_listen::outcome_of_listen::update_model): Likewise fo
1007 on_listen...
1008 (region_model::on_listen): ...eliminating this function.
1009 (kf_accept::outcome_of_accept::update_model): Likewise fo
1010 on_accept...
1011 (region_model::on_accept): ...eliminating this function.
1012 (kf_connect::outcome_of_connect::update_model): Likewise fo
1013 on_connect...
1014 (region_model::on_connect): ...eliminating this function.
1015
1016 2022-11-24 David Malcolm <dmalcolm@redhat.com>
1017
1018 * analyzer.h (register_known_fd_functions): New decl.
1019 * region-model-impl-calls.cc (class kf_accept): Move to sm-fd.cc.
1020 (class kf_bind): Likewise.
1021 (class kf_connect): Likewise.
1022 (class kf_listen): Likewise.
1023 (class kf_pipe): Likewise.
1024 (class kf_socket): Likewise.
1025 (register_known_functions): Remove registration of the above
1026 functions, instead calling register_known_fd_functions.
1027 * sm-fd.cc: Include "analyzer/call-info.h".
1028 (class kf_socket): Move here from region-model-impl-calls.cc.
1029 (class kf_bind): Likewise.
1030 (class kf_listen): Likewise.
1031 (class kf_accept): Likewise.
1032 (class kf_connect): Likewise.
1033 (class kf_pipe): Likewise.
1034 (register_known_fd_functions): New.
1035
1036 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1037
1038 PR analyzer/107788
1039 * known-function-manager.cc (known_function_manager::get_match):
1040 Don't look up fndecls by name when they're not in the root
1041 namespace.
1042
1043 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1044
1045 PR analyzer/107783
1046 * sm-fd.cc (fd_state_machine::check_for_new_socket_fd): Don't
1047 complain when old state is "fd-constant".
1048 (fd_state_machine::on_listen): Likewise.
1049 (fd_state_machine::on_accept): Likewise.
1050
1051 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1052
1053 PR analyzer/107807
1054 * region-model-impl-calls.cc (register_known_functions): Register
1055 "___errno" and "__error" as synonyms for "__errno_location".
1056
1057 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1058
1059 * analyzer.h (class internal_known_function): New.
1060 (register_varargs_builtins): New decl.
1061 * engine.cc (exploded_node::on_stmt_pre): Remove
1062 "out_terminate_path" param from call to region_model::on_stmt_pre.
1063 (feasibility_state::maybe_update_for_edge): Likewise.
1064 * known-function-manager.cc: Include "basic-block.h", "gimple.h",
1065 and "analyzer/region-model.h".
1066 (known_function_manager::known_function_manager): Initialize
1067 m_combined_fns_arr.
1068 (known_function_manager::~known_function_manager): Clean up
1069 m_combined_fns_arr.
1070 (known_function_manager::get_by_identifier): Make const.
1071 (known_function_manager::add): New overloaded definitions for
1072 enum built_in_function and enum internal_fn.
1073 (known_function_manager::get_by_fndecl): Delete.
1074 (known_function_manager::get_match): New.
1075 (known_function_manager::get_internal_fn): New.
1076 (known_function_manager::get_normal_builtin): New.
1077 * known-function-manager.h
1078 (known_function_manager::get_by_identifier): Make private and
1079 add const qualifier.
1080 (known_function_manager::get_by_fndecl): Delete.
1081 (known_function_manager::add): Add overloaded decls for
1082 enum built_in_function name and enum internal_fn.
1083 (known_function_manager::get_match): New decl.
1084 (known_function_manager::get_internal_fn): New decl.
1085 (known_function_manager::get_normal_builtin): New decl.
1086 (known_function_manager::m_combined_fns_arr): New field.
1087 * region-model-impl-calls.cc (call_details::arg_is_size_p): New.
1088 (class kf_alloca): New.
1089 (region_model::impl_call_alloca): Convert to...
1090 (kf_alloca::impl_call_pre): ...this.
1091 (kf_analyzer_dump_capacity::matches_call_types_p): Rewrite check
1092 to use call_details::arg_is_pointer_p.
1093 (region_model::impl_call_builtin_expect): Convert to...
1094 (class kf_expect): ...this.
1095 (class kf_calloc): New, adding check that both arguments are
1096 size_t.
1097 (region_model::impl_call_calloc): Convert to...
1098 (kf_calloc::impl_call_pre): ...this.
1099 (kf_connect::matches_call_types_p): Rewrite check to use
1100 call_details::arg_is_pointer_p.
1101 (region_model::impl_call_error): Convert to...
1102 (class kf_error): ...this, and...
1103 (kf_error::impl_call_pre): ...this.
1104 (class kf_fgets): New, adding checks that args 0 and 2 are
1105 pointers.
1106 (region_model::impl_call_fgets): Convert to...
1107 (kf_fgets::impl_call_pre): ...this.
1108 (class kf_fread): New, adding checks on the argument types.
1109 (region_model::impl_call_fread): Convert to...
1110 (kf_fread::impl_call_pre): ...this.
1111 (class kf_free): New, adding check that the argument is a pointer.
1112 (region_model::impl_call_free): Convert to...
1113 (kf_free::impl_call_post): ...this.
1114 (class kf_getchar): New.
1115 (class kf_malloc): New, adding check that the argument is a
1116 size_t.
1117 (region_model::impl_call_malloc): Convert to...
1118 (kf_malloc::impl_call_pre): ...this.
1119 (class kf_memcpy): New, adding checks on arguments.
1120 (region_model::impl_call_memcpy): Convert to...
1121 (kf_memcpy::impl_call_pre): ...this.
1122 (class kf_memset): New.
1123 (region_model::impl_call_memset): Convert to...
1124 (kf_memset::impl_call_pre): ...this.
1125 (kf_pipe::matches_call_types_p): Rewrite check to use
1126 call_details::arg_is_pointer_p.
1127 (kf_putenv::matches_call_types_p): Likewise.
1128 (class kf_realloc): New, adding checks on the argument types.
1129 (region_model::impl_call_realloc): Convert to...
1130 (kf_realloc::impl_call_post): ...this.
1131 (class kf_strchr): New.
1132 (region_model::impl_call_strchr): Convert to...
1133 (kf_strchr::impl_call_post): ...this.
1134 (class kf_stack_restore): New.
1135 (class kf_stack_save): New.
1136 (class kf_stdio_output_fn): New.
1137 (class kf_strcpy): New,
1138 (region_model::impl_call_strcpy): Convert to...
1139 (kf_strcpy::impl_call_pre): ...this.
1140 (class kf_strlen): New.
1141 (region_model::impl_call_strlen): Convert to...
1142 (kf_strlen::impl_call_pre): ...this.
1143 (class kf_ubsan_bounds): New.
1144 (region_model::impl_deallocation_call): Reimplement to avoid call
1145 to impl_call_free.
1146 (register_known_functions): Add handlers for IFN_BUILTIN_EXPECT
1147 and IFN_UBSAN_BOUNDS. Add handlers for BUILT_IN_ALLOCA,
1148 BUILT_IN_ALLOCA_WITH_ALIGN, BUILT_IN_CALLOC, BUILT_IN_EXPECT,
1149 BUILT_IN_EXPECT_WITH_PROBABILITY, BUILT_IN_FPRINTF,
1150 BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC,
1151 BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
1152 BUILT_IN_FREE, BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED,
1153 BUILT_IN_MALLOC, BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK,
1154 BUILT_IN_MEMSET, BUILT_IN_MEMSET_CHK, BUILT_IN_PRINTF,
1155 BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTCHAR,
1156 BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_PUTS,
1157 BUILT_IN_PUTS_UNLOCKED, BUILT_IN_REALLOC, BUILT_IN_STACK_RESTORE,
1158 BUILT_IN_STACK_SAVE, BUILT_IN_STRCHR, BUILT_IN_STRCPY,
1159 BUILT_IN_STRCPY_CHK, BUILT_IN_STRLEN, BUILT_IN_VFPRINTF, and
1160 BUILT_IN_VPRINTF. Call register_varargs_builtins. Add handlers
1161 for "getchar", "memset", "fgets", "fgets_unlocked", "fread",
1162 "error", and "error_at_line".
1163 * region-model.cc (region_model::on_stmt_pre): Drop
1164 "out_terminate_path" param.
1165 (region_model::get_known_function): Reimplement by calling
1166 known_function_manager::get_match, passing new "cd" param.
1167 Add overload taking enum internal_fn.
1168 (region_model::on_call_pre): Drop "out_terminate_path" param.
1169 Remove special-case handling of internal fns IFN_BUILTIN_EXPECT,
1170 IFN_UBSAN_BOUNDS, and IFN_VA_ARG, of built-in fns BUILT_IN_ALLOCA,
1171 BUILT_IN_ALLOCA_WITH_ALIGN, BUILT_IN_CALLOC, BUILT_IN_EXPECT,
1172 BUILT_IN_EXPECT_WITH_PROBABILITY, BUILT_IN_FREE, BUILT_IN_MALLOC,
1173 BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK, BUILT_IN_MEMSET,
1174 BUILT_IN_MEMSET_CHK, BUILT_IN_REALLOC, BUILT_IN_STRCHR,
1175 BUILT_IN_STRCPY, BUILT_IN_STRCPY_CHK, BUILT_IN_STRLEN,
1176 BUILT_IN_STACK_SAVE, BUILT_IN_STACK_RESTORE, BUILT_IN_FPRINTF,
1177 BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTC_UNLOCKED,
1178 BUILT_IN_FPUTC, BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS,
1179 BUILT_IN_FPUTS_UNLOCKED, BUILT_IN_FWRITE,
1180 BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
1181 BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTCHAR,
1182 BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTS, BUILT_IN_PUTS_UNLOCKED,
1183 BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF, BUILT_IN_VA_START, and
1184 BUILT_IN_VA_COPY, and of named functions "malloc", "calloc",
1185 "alloca", "realloc", "error", "error_at_line", "fgets",
1186 "fgets_unlocked", "fread", "getchar", "memset", "strchr", and
1187 "strlen". Replace all this special-casing with calls to
1188 get_known_function for internal fns and for fn decls.
1189 (region_model::on_call_post): Remove special-casing handling for
1190 "free" and "strchr", and for BUILT_IN_REALLOC, BUILT_IN_STRCHR,
1191 and BUILT_IN_VA_END. Replace by consolidating on usage of
1192 get_known_function.
1193 * region-model.h (call_details::arg_is_size_p): New.
1194 (region_model::on_stmt_pre): Drop "out_terminate_path" param.
1195 (region_model::on_call_pre): Likewise.
1196 (region_model::impl_call_alloca): Delete.
1197 (region_model::impl_call_builtin_expect): Delete.
1198 (region_model::impl_call_calloc): Delete.
1199 (region_model::impl_call_error): Delete.
1200 (region_model::impl_call_fgets): Delete.
1201 (region_model::impl_call_fread): Delete.
1202 (region_model::impl_call_free): Delete.
1203 (region_model::impl_call_malloc): Delete.
1204 (region_model::impl_call_memcpy): Delete.
1205 (region_model::impl_call_memset): Delete.
1206 (region_model::impl_call_realloc): Delete.
1207 (region_model::impl_call_strchr): Delete.
1208 (region_model::impl_call_strcpy): Delete.
1209 (region_model::impl_call_strlen): Delete.
1210 (region_model::impl_call_va_start): Delete.
1211 (region_model::impl_call_va_copy): Delete.
1212 (region_model::impl_call_va_arg): Delete.
1213 (region_model::impl_call_va_end): Delete.
1214 (region_model::check_region_for_write): Public.
1215 (region_model::get_known_function): Add "cd" param. Add
1216 overloaded decl taking enum internal_fn.
1217 * sm-malloc.cc: Update comments.
1218 * varargs.cc (class kf_va_start): New.
1219 (region_model::impl_call_va_start): Convert to...
1220 (kf_va_start::impl_call_pre): ...this.
1221 (class kf_va_copy): New.
1222 (region_model::impl_call_va_copy): Convert to...
1223 (kf_va_copy::impl_call_pre): ...this.
1224 (class kf_va_arg): New.
1225 (region_model::impl_call_va_arg): Convert to...
1226 (kf_va_arg::impl_call_pre): ...this.
1227 (class kf_va_end): New.
1228 (region_model::impl_call_va_end): Delete.
1229 (register_varargs_builtins): New.
1230
1231 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1232
1233 PR analyzer/107788
1234 * region-model.cc (region_model::update_for_int_cst_return):
1235 Require that the return type be an integer type.
1236 (region_model::update_for_nonzero_return): Likewise.
1237
1238 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1239
1240 PR analyzer/107783
1241 * region-model-impl-calls.cc (kf_accept::matches_call_types_p):
1242 Require that args 1 and 2 be pointers.
1243 (kf_bind::matches_call_types_p): Require that arg 1 be a pointer.
1244 * region-model.h (call_details::arg_is_pointer_p): New
1245
1246 2022-11-22 David Malcolm <dmalcolm@redhat.com>
1247
1248 PR analyzer/107777
1249 * call-summary.cc
1250 (call_summary_replay::convert_region_from_summary_1): Handle
1251 RK_THREAD_LOCAL and RK_ERRNO in switch.
1252 * region-model.cc (region_model::get_representative_path_var_1):
1253 Likewise.
1254
1255 2022-11-19 David Malcolm <dmalcolm@redhat.com>
1256
1257 PR analyzer/107582
1258 * engine.cc (dynamic_call_info_t::update_model): Update the model
1259 by pushing or pop a frame, rather than by clobbering it with the
1260 model from the exploded_node's state.
1261
1262 2022-11-18 David Malcolm <dmalcolm@redhat.com>
1263
1264 * analyzer.cc (is_pipe_call_p): Delete.
1265 * analyzer.h (is_pipe_call_p): Delete.
1266 * region-model-impl-calls.cc (call_details::get_location): New.
1267 (class kf_analyzer_break): New, adapted from
1268 region_model::on_stmt_pre.
1269 (region_model::impl_call_analyzer_describe): Convert to...
1270 (class kf_analyzer_describe): ...this.
1271 (region_model::impl_call_analyzer_dump_capacity): Convert to...
1272 (class kf_analyzer_dump_capacity): ...this.
1273 (region_model::impl_call_analyzer_dump_escaped): Convert to...
1274 (class kf_analyzer_dump_escaped): ...this.
1275 (class kf_analyzer_dump_exploded_nodes): New.
1276 (region_model::impl_call_analyzer_dump_named_constant): Convert
1277 to...
1278 (class kf_analyzer_dump_named_constant): ...this.
1279 (class dump_path_diagnostic): Move here from region-model.cc.
1280 (class kf_analyzer_dump_path) New, adapted from
1281 region_model::on_stmt_pre.
1282 (class kf_analyzer_dump_region_model): Likewise.
1283 (region_model::impl_call_analyzer_eval): Convert to...
1284 (class kf_analyzer_eval): ...this.
1285 (region_model::impl_call_analyzer_get_unknown_ptr): Convert to...
1286 (class kf_analyzer_get_unknown_ptr): ...this.
1287 (class known_function_accept): Rename to...
1288 (class kf_accept): ...this.
1289 (class known_function_bind): Rename to...
1290 (class kf_bind): ...this.
1291 (class known_function_connect): Rename to...
1292 (class kf_connect): ...this.
1293 (region_model::impl_call_errno_location): Convert to...
1294 (class kf_errno_location): ...this.
1295 (class known_function_listen): Rename to...
1296 (class kf_listen): ...this.
1297 (region_model::impl_call_pipe): Convert to...
1298 (class kf_pipe): ...this.
1299 (region_model::impl_call_putenv): Convert to...
1300 (class kf_putenv): ...this.
1301 (region_model::impl_call_operator_new): Convert to...
1302 (class kf_operator_new): ...this.
1303 (region_model::impl_call_operator_delete): Convert to...
1304 (class kf_operator_delete): ...this.
1305 (class known_function_socket): Rename to...
1306 (class kf_socket): ...this.
1307 (register_known_functions): Rename param to KFM. Break out
1308 existing known functions into a "POSIX" section, and add "pipe",
1309 "pipe2", and "putenv". Add debugging functions
1310 "__analyzer_break", "__analyzer_describe",
1311 "__analyzer_dump_capacity", "__analyzer_dump_escaped",
1312 "__analyzer_dump_exploded_nodes",
1313 "__analyzer_dump_named_constant", "__analyzer_dump_path",
1314 "__analyzer_dump_region_model", "__analyzer_eval",
1315 "__analyzer_get_unknown_ptr". Add C++ support functions
1316 "operator new", "operator new []", "operator delete", and
1317 "operator delete []".
1318 * region-model.cc (class dump_path_diagnostic): Move to
1319 region-model-impl-calls.cc.
1320 (region_model::on_stmt_pre): Eliminate special-casing of
1321 "__analyzer_describe", "__analyzer_dump_capacity",
1322 "__analyzer_dump_escaped", "__analyzer_dump_named_constant",
1323 "__analyzer_dump_path", "__analyzer_dump_region_model",
1324 "__analyzer_eval", "__analyzer_break",
1325 "__analyzer_dump_exploded_nodes", "__analyzer_get_unknown_ptr",
1326 "__errno_location", "pipe", "pipe2", "putenv", "operator new",
1327 "operator new []", "operator delete", "operator delete []"
1328 "pipe" and "pipe2", handling them instead via the known_functions
1329 mechanism.
1330 * region-model.h (call_details::get_location): New decl.
1331 (region_model::impl_call_analyzer_describe): Delete decl.
1332 (region_model::impl_call_analyzer_dump_capacity): Delete decl.
1333 (region_model::impl_call_analyzer_dump_escaped): Delete decl.
1334 (region_model::impl_call_analyzer_dump_named_constant): Delete decl.
1335 (region_model::impl_call_analyzer_eval): Delete decl.
1336 (region_model::impl_call_analyzer_get_unknown_ptr): Delete decl.
1337 (region_model::impl_call_errno_location): Delete decl.
1338 (region_model::impl_call_pipe): Delete decl.
1339 (region_model::impl_call_putenv): Delete decl.
1340 (region_model::impl_call_operator_new): Delete decl.
1341 (region_model::impl_call_operator_delete): Delete decl.
1342 * sm-fd.cc: Update comments.
1343
1344 2022-11-16 David Malcolm <dmalcolm@redhat.com>
1345
1346 PR analyzer/107711
1347 * analyzer-language.cc: Include "diagnostic.h".
1348 (maybe_stash_named_constant): Add logger param and use it to log
1349 the name being looked up, and the result.
1350 (stash_named_constants): New, splitting out from...
1351 (on_finish_translation_unit): ...this function. Call
1352 get_or_create_logfile and use the result to create a logger
1353 instance, passing it to stash_named_constants.
1354 * analyzer.h (get_or_create_any_logfile): New decl.
1355 * engine.cc (dump_fout, owns_dump_fout): New globals, split out
1356 from run_checkers.
1357 (get_or_create_any_logfile): New function, split out from...
1358 (run_checkers): ...here, so that the logfile can be opened by
1359 on_finish_translation_unit. Clear the globals when closing the
1360 dump file.
1361
1362 2022-11-16 David Malcolm <dmalcolm@redhat.com>
1363
1364 * analyzer.h (known_function::matches_call_types_p): New vfunc.
1365 (known_function::impl_call_pre): Provide base implementation.
1366 (known_function::impl_call_post): New vfunc.
1367 (register_known_functions): New.
1368 * engine.cc (impl_run_checkers): Call register_known_functions.
1369 * region-model-impl-calls.cc (region_model::impl_call_accept):
1370 Convert to...
1371 (class known_function_accept): ...this.
1372 (region_model::impl_call_bind): Convert to...
1373 (class known_function_bind): ...this.
1374 (region_model::impl_call_connect): Convert to...
1375 (class known_function_connect): ...this.
1376 (region_model::impl_call_listen): Convert to...
1377 (class known_function_listen): ...this.
1378 (region_model::impl_call_socket): Convert to...
1379 (class known_function_socket): ...this.
1380 (register_known_functions): New.
1381 * region-model.cc (region_model::on_call_pre): Remove special
1382 case for "bind" in favor of the known_function-handling dispatch.
1383 Add call to known_function::matches_call_types_p to latter.
1384 (region_model::on_call_post): Remove special cases for "accept",
1385 "bind", "connect", "listen", and "socket" in favor of dispatch
1386 to known_function::impl_call_post.
1387 * region-model.h (region_model::impl_call_accept): Delete decl.
1388 (region_model::impl_call_bind): Delete decl.
1389 (region_model::impl_call_connect): Delete decl.
1390 (region_model::impl_call_listen): Delete decl.
1391 (region_model::impl_call_socket): Delete decl.
1392 * sm-fd.cc: Update comments.
1393
1394 2022-11-16 David Malcolm <dmalcolm@redhat.com>
1395
1396 * checker-event.cc: New file, split out from...
1397 * checker-path.cc: ...this file.
1398
1399 2022-11-15 David Malcolm <dmalcolm@redhat.com>
1400
1401 PR analyzer/106140
1402 * analyzer-language.cc (on_finish_translation_unit): Stash named
1403 constants "SOCK_STREAM" and "SOCK_DGRAM".
1404 * analyzer.opt (Wanalyzer-fd-phase-mismatch): New.
1405 (Wanalyzer-fd-type-mismatch): New.
1406 * engine.cc (impl_region_model_context::get_state_map_by_name):
1407 Add "out_sm_context" param. Allow out_sm_idx to be NULL.
1408 * exploded-graph.h
1409 (impl_region_model_context::get_state_map_by_name):
1410 Add "out_sm_context" param.
1411 * region-model-impl-calls.cc (region_model::impl_call_accept): New.
1412 (region_model::impl_call_bind): New.
1413 (region_model::impl_call_connect): New.
1414 (region_model::impl_call_listen): New.
1415 (region_model::impl_call_socket): New.
1416 * region-model.cc (region_model::on_call_pre): Special-case
1417 "bind".
1418 (region_model::on_call_post): Special-case "accept", "bind",
1419 "connect", "listen", and "socket".
1420 * region-model.h (region_model::impl_call_accept): New decl.
1421 (region_model::impl_call_bind): New decl.
1422 (region_model::impl_call_connect): New decl.
1423 (region_model::impl_call_listen): New decl.
1424 (region_model::impl_call_socket): New decl.
1425 (region_model::on_socket): New decl.
1426 (region_model::on_bind): New decl.
1427 (region_model::on_listen): New decl.
1428 (region_model::on_accept): New decl.
1429 (region_model::on_connect): New decl.
1430 (region_model::add_constraint): Make public.
1431 (region_model::check_for_poison): Make public.
1432 (region_model_context::get_state_map_by_name): Add out_sm_context param.
1433 (region_model_context::get_fd_map): Likewise.
1434 (region_model_context::get_malloc_map): Likewise.
1435 (region_model_context::get_taint_map): Likewise.
1436 (noop_region_model_context::get_state_map_by_name): Likewise.
1437 (region_model_context_decorator::get_state_map_by_name): Likewise.
1438 * sm-fd.cc: Include "analyzer/supergraph.h" and
1439 "analyzer/analyzer-language.h".
1440 (enum expected_phase): New enum.
1441 (fd_state_machine::m_new_datagram_socket): New.
1442 (fd_state_machine::m_new_stream_socket): New.
1443 (fd_state_machine::m_new_unknown_socket): New.
1444 (fd_state_machine::m_bound_datagram_socket): New.
1445 (fd_state_machine::m_bound_stream_socket): New.
1446 (fd_state_machine::m_bound_unknown_socket): New.
1447 (fd_state_machine::m_listening_stream_socket): New.
1448 (fd_state_machine::m_m_connected_stream_socket): New.
1449 (fd_state_machine::m_SOCK_STREAM): New.
1450 (fd_state_machine::m_SOCK_DGRAM): New.
1451 (fd_diagnostic::describe_state_change): Handle socket states.
1452 (fd_diagnostic::get_meaning_for_state_change): Likewise.
1453 (class fd_phase_mismatch): New.
1454 (enum expected_type): New enum.
1455 (class fd_type_mismatch): New.
1456 (fd_state_machine::fd_state_machine): Initialize new states and
1457 stashed named constants.
1458 (fd_state_machine::is_socket_fd_p): New.
1459 (fd_state_machine::is_datagram_socket_fd_p): New.
1460 (fd_state_machine::is_stream_socket_fd_p): New.
1461 (fd_state_machine::on_close): Handle the socket states.
1462 (fd_state_machine::check_for_open_fd): Complain about fncalls on
1463 sockets in the wrong phase. Support socket FDs.
1464 (add_constraint_ge_zero): New.
1465 (fd_state_machine::get_state_for_socket_type): New.
1466 (fd_state_machine::on_socket): New.
1467 (fd_state_machine::check_for_socket_fd): New.
1468 (fd_state_machine::check_for_new_socket_fd): New.
1469 (fd_state_machine::on_bind): New.
1470 (fd_state_machine::on_listen): New.
1471 (fd_state_machine::on_accept): New.
1472 (fd_state_machine::on_connect): New.
1473 (fd_state_machine::can_purge_p): Don't purge socket values.
1474 (get_fd_state): New.
1475 (region_model::mark_as_valid_fd): Use get_fd_state.
1476 (region_model::on_socket): New.
1477 (region_model::on_bind): New.
1478 (region_model::on_listen): New.
1479 (region_model::on_accept): New.
1480 (region_model::on_connect): New.
1481 * sm-fd.dot: Update to reflect sm-fd.cc changes.
1482
1483 2022-11-15 David Malcolm <dmalcolm@redhat.com>
1484
1485 PR analyzer/106302
1486 * analyzer-language.cc: New file.
1487 * analyzer-language.h: New file.
1488 * analyzer.h (get_stashed_constant_by_name): New decl.
1489 (log_stashed_constants): New decl.
1490 * engine.cc (impl_run_checkers): Call log_stashed_constants.
1491 * region-model-impl-calls.cc
1492 (region_model::impl_call_analyzer_dump_named_constant): New.
1493 * region-model.cc (region_model::on_stmt_pre): Handle
1494 __analyzer_dump_named_constant.
1495 * region-model.h
1496 (region_model::impl_call_analyzer_dump_named_constant): New decl.
1497 * sm-fd.cc (fd_state_machine::m_O_ACCMODE): New.
1498 (fd_state_machine::m_O_RDONLY): New.
1499 (fd_state_machine::m_O_WRONLY): New.
1500 (fd_state_machine::fd_state_machine): Initialize the new fields.
1501 (fd_state_machine::get_access_mode_from_flag): Use the new fields,
1502 rather than using the host values.
1503
1504 2022-11-13 David Malcolm <dmalcolm@redhat.com>
1505
1506 PR analyzer/106235
1507 * analyzer.opt (Wanalyzer-tainted-assertion): New.
1508 * checker-path.cc (checker_path::fixup_locations): Pass false to
1509 pending_diagnostic::fixup_location.
1510 * diagnostic-manager.cc (get_emission_location): Pass true to
1511 pending_diagnostic::fixup_location.
1512 * pending-diagnostic.cc (pending_diagnostic::fixup_location): Add
1513 bool param.
1514 * pending-diagnostic.h (pending_diagnostic::fixup_location): Add
1515 bool param to decl.
1516 * sm-taint.cc (taint_state_machine::m_tainted_control_flow): New.
1517 (taint_diagnostic::describe_state_change): Drop "final".
1518 (class tainted_assertion): New.
1519 (taint_state_machine::taint_state_machine): Initialize
1520 m_tainted_control_flow.
1521 (taint_state_machine::alt_get_inherited_state): Support
1522 comparisons being tainted, based on their arguments.
1523 (is_assertion_failure_handler_p): New.
1524 (taint_state_machine::on_stmt): Complain about calls to assertion
1525 failure handlers guarded by an attacker-controller conditional.
1526 Detect attacker-controlled gcond conditionals and gswitch index
1527 values.
1528 (taint_state_machine::check_control_flow_arg_for_taint): New.
1529
1530 2022-11-11 David Malcolm <dmalcolm@redhat.com>
1531
1532 * sm-fd.dot: Fix typo in comment.
1533 * sm-file.dot: New file.
1534 * varargs.cc: Fix typo in comment.
1535 * varargs.dot: New file.
1536
1537 2022-11-11 David Malcolm <dmalcolm@redhat.com>
1538
1539 * checker-path.h: Split out checker_event and its subclasses to...
1540 * checker-event.h: ...this new header.
1541
1542 2022-11-11 David Malcolm <dmalcolm@redhat.com>
1543
1544 PR analyzer/106147
1545 * analyzer.opt (Wanalyzer-infinite-recursion): New.
1546 * call-string.cc (call_string::count_occurrences_of_function):
1547 New.
1548 * call-string.h (call_string::count_occurrences_of_function): New
1549 decl.
1550 * checker-path.cc (function_entry_event::function_entry_event):
1551 New ctor.
1552 (checker_path::add_final_event): Delete.
1553 * checker-path.h (function_entry_event::function_entry_event): New
1554 ctor.
1555 (function_entry_event::get_desc): Drop "final".
1556 (checker_path::add_final_event): Delete.
1557 * diagnostic-manager.cc
1558 (diagnostic_manager::emit_saved_diagnostic): Create the final
1559 event via a new pending_diagnostic::add_final_event vfunc, rather
1560 than checker_path::add_final_event.
1561 (diagnostic_manager::add_events_for_eedge): Create function entry
1562 events via a new pending_diagnostic::add_function_entry_event
1563 vfunc.
1564 * engine.cc (exploded_graph::process_node): When creating a new
1565 PK_BEFORE_SUPERNODE node, call
1566 exploded_graph::detect_infinite_recursion on it after adding the
1567 in-edge.
1568 * exploded-graph.h (exploded_graph::detect_infinite_recursion):
1569 New decl.
1570 (exploded_graph::find_previous_entry_to): New decl.
1571 * infinite-recursion.cc: New file.
1572 * pending-diagnostic.cc
1573 (pending_diagnostic::add_function_entry_event): New.
1574 (pending_diagnostic::add_final_event): New.
1575 * pending-diagnostic.h
1576 (pending_diagnostic::add_function_entry_event): New vfunc.
1577 (pending_diagnostic::add_final_event): New vfunc.
1578
1579 2022-11-10 David Malcolm <dmalcolm@redhat.com>
1580
1581 PR analyzer/99671
1582 * analyzer.opt (Wanalyzer-deref-before-check): New warning.
1583 * diagnostic-manager.cc
1584 (null_assignment_sm_context::set_next_state): Only add state
1585 change events for transition to "null" state.
1586 (null_assignment_sm_context::is_transition_to_null): New.
1587 * engine.cc (impl_region_model_context::on_pop_frame): New.
1588 * exploded-graph.h (impl_region_model_context::on_pop_frame): New
1589 decl.
1590 * program-state.cc (sm_state_map::clear_any_state): New.
1591 (sm_state_map::can_merge_with_p): New.
1592 (program_state::can_merge_with_p): Replace requirement that
1593 sm-states be equal in favor of an attempt to merge them.
1594 * program-state.h (sm_state_map::clear_any_state): New decl.
1595 (sm_state_map::can_merge_with_p): New decl.
1596 * region-model.cc (region_model::eval_condition): Make const.
1597 (region_model::pop_frame): Call ctxt->on_pop_frame.
1598 * region-model.h (region_model::eval_condition): Make const.
1599 (region_model_context::on_pop_frame): New vfunc.
1600 (noop_region_model_context::on_pop_frame): New.
1601 (region_model_context_decorator::on_pop_frame): New.
1602 * sm-malloc.cc (enum resource_state): Add RS_ASSUMED_NON_NULL.
1603 (allocation_state::dump_to_pp): Drop "final".
1604 (struct assumed_non_null_state): New subclass.
1605 (malloc_state_machine::m_assumed_non_null): New.
1606 (assumed_non_null_p): New.
1607 (class deref_before_check): New.
1608 (assumed_non_null_state::dump_to_pp): New.
1609 (malloc_state_machine::get_or_create_assumed_non_null_state_for_frame):
1610 New.
1611 (malloc_state_machine::maybe_assume_non_null): New.
1612 (malloc_state_machine::on_stmt): Transition from start state to
1613 "assumed-non-null" state for pointers passed to
1614 __attribute__((nonnull)) arguments, and for pointers explicitly
1615 dereferenced. Call maybe_complain_about_deref_before_check for
1616 pointers explicitly compared against NULL.
1617 (malloc_state_machine::maybe_complain_about_deref_before_check):
1618 New.
1619 (malloc_state_machine::on_deallocator_call): Also transition
1620 "assumed-non-null" states to "freed".
1621 (malloc_state_machine::on_pop_frame): New.
1622 (malloc_state_machine::maybe_get_merged_states_nonequal): New.
1623 * sm-malloc.dot: Update for changes to sm-malloc.cc.
1624 * sm.h (state_machine::on_pop_frame): New.
1625 (state_machine::maybe_get_merged_state): New.
1626 (state_machine::maybe_get_merged_states_nonequal): New.
1627
1628 2022-11-09 David Malcolm <dmalcolm@redhat.com>
1629
1630 * checker-path.cc (checker_event::debug): New.
1631 (checker_path::add_event): Move here from checker-path.h. Add
1632 logging.
1633 * checker-path.h (checker_event::debug): New decl.
1634 (checker_path::checker_path): Add logger param.
1635 (checker_path::add_event): Move definition from here to
1636 checker-path.cc.
1637 (checker_path::m_logger): New field.
1638 * diagnostic-manager.cc
1639 (diagnostic_manager::emit_saved_diagnostic): Pass logger to
1640 checker_path ctor.
1641 (diagnostic_manager::add_events_for_eedge): Log scope when
1642 processing a run of stmts.
1643
1644 2022-11-08 David Malcolm <dmalcolm@redhat.com>
1645
1646 PR analyzer/101962
1647 * region-model-impl-calls.cc: Update comment.
1648 * region-model.cc (region_model::check_symbolic_bounds): Fix
1649 layout of "void" return. Replace usage of
1650 eval_condition_without_cm with eval_condition.
1651 (region_model::eval_condition): Take over body of...
1652 (region_model::eval_condition_without_cm): ...this subroutine,
1653 dropping the latter. Eliminating this distinction avoids issues
1654 where constraints were not considered when recursing.
1655 (region_model::compare_initial_and_pointer): Update comment.
1656 (region_model::symbolic_greater_than): Replace usage of
1657 eval_condition_without_cm with eval_condition.
1658 * region-model.h
1659 (region_model::eval_condition_without_cm): Delete decl.
1660
1661 2022-11-08 David Malcolm <dmalcolm@redhat.com>
1662
1663 * region-model-impl-calls.cc
1664 (region_model::impl_call_errno_location): New.
1665 * region-model-manager.cc
1666 (region_model_manager::region_model_manager): Initialize
1667 m_thread_local_region and m_errno_region.
1668 * region-model-manager.h (region_model_manager::get_errno_region):
1669 New accessor.
1670 (region_model_manager::m_thread_local_region): New.
1671 (region_model_manager::m_errno_region): New.
1672 * region-model.cc (region_model::on_call_pre): Special-case
1673 "__errno_location".
1674 (region_model::set_errno): New.
1675 * region-model.h (impl_call_errno_location): New decl.
1676 (region_model::set_errno): New decl.
1677 * region.cc (thread_local_region::dump_to_pp): New.
1678 (errno_region::dump_to_pp): New.
1679 * region.h (enum memory_space): Add MEMSPACE_THREAD_LOCAL.
1680 (enum region_kind): Add RK_THREAD_LOCAL and RK_ERRNO.
1681 (class thread_local_region): New.
1682 (is_a_helper <const thread_local_region *>::test): New.
1683 (class errno_region): New.
1684 (is_a_helper <const errno_region *>::test): New.
1685 * store.cc (binding_cluster::escaped_p): New.
1686 (store::escaped_p): Treat errno as always having escaped.
1687 (store::replay_call_summary_cluster): Handle RK_THREAD_LOCAL and
1688 RK_ERRNO.
1689 * store.h (binding_cluster::escaped_p): Remove definition.
1690
1691 2022-11-08 David Malcolm <dmalcolm@redhat.com>
1692
1693 * call-info.cc (success_call_info::get_desc): Delete.
1694 (failed_call_info::get_desc): Likewise.
1695 (succeed_or_fail_call_info::get_desc): New.
1696 * call-info.h (class succeed_or_fail_call_info): New.
1697 (class success_call_info): Convert to a subclass of
1698 succeed_or_fail_call_info.
1699 (class failed_call_info): Likewise.
1700
1701 2022-11-08 David Malcolm <dmalcolm@redhat.com>
1702
1703 * region-model-impl-calls.cc (region_model::impl_call_strchr):
1704 Move to on_call_post. Handle both outcomes using bifurcation,
1705 rather than just the "not found" case.
1706 * region-model.cc (region_model::on_call_pre): Move
1707 BUILT_IN_STRCHR and "strchr" to...
1708 (region_model::on_call_post): ...here.
1709
1710 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1711
1712 * analyzer.h: Use std::unique_ptr for state machines from plugins.
1713 * engine.cc: Likewise.
1714
1715 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1716
1717 * analyzer.h: Use std::unique_ptr for known functions.
1718 * engine.cc: Likewise.
1719 * known-function-manager.cc: Likewise.
1720 * known-function-manager.h: Likewise.
1721
1722 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1723
1724 * analysis-plan.cc: Define INCLUDE_MEMORY before including
1725 system.h.
1726 * analyzer-pass.cc: Likewise.
1727 * analyzer-selftests.cc: Likewise.
1728 * analyzer.cc: Likewise.
1729 * analyzer.h: Use std::unique_ptr in bifurcation code.
1730 * call-string.cc: Define INCLUDE_MEMORY before including system.h.
1731 * complexity.cc: Likewise.
1732 * engine.cc: Use std::unique_ptr in bifurcation code.
1733 * exploded-graph.h: Likewise.
1734 * known-function-manager.cc: Define INCLUDE_MEMORY before
1735 including system.h.
1736 * region-model-impl-calls.cc: Use std::unique_ptr in bifurcation
1737 code.
1738 * region-model.cc: Likewise.
1739 * region-model.h: Likewise.
1740 * supergraph.cc: Define INCLUDE_MEMORY before including system.h.
1741
1742 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1743
1744 * call-info.cc: Use std::unique_ptr for checker_event.
1745 * checker-path.cc: Likewise.
1746 * checker-path.h: Likewise.
1747 * diagnostic-manager.cc: Likewise.
1748 * engine.cc: Likewise.
1749 * pending-diagnostic.cc: Likewise.
1750 * sm-signal.cc: Likewise.
1751 * varargs.cc: Likewise.
1752
1753 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1754
1755 * diagnostic-manager.cc: Include "make-unique.h".
1756 Use std::unique_ptr for feasibility_problems and exploded_path.
1757 Delete explicit saved_diagnostic dtor.
1758 * diagnostic-manager.h: Likewise.
1759 * engine.cc: Likewise.
1760 * exploded-graph.h: Likewise.
1761 * feasible-graph.cc: Likewise.
1762 * feasible-graph.h: Likewise.
1763
1764 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1765
1766 * checker-path.cc (rewind_event::rewind_event): Update for usage of
1767 std::unique_ptr on custom_edge_info.
1768 * engine.cc (exploded_node::on_longjmp): Likewise.
1769 (exploded_edge::exploded_edge): Likewise.
1770 (exploded_edge::~exploded_edge): Delete.
1771 (exploded_graph::add_function_entry): Update for usage of
1772 std::unique_ptr on custom_edge_info.
1773 (exploded_graph::add_edge): Likewise.
1774 (add_tainted_args_callback): Likewise.
1775 (exploded_graph::maybe_create_dynamic_call): Likewise.
1776 (exploded_graph::process_node): Likewise.
1777 * exploded-graph.h (exploded_edge::~exploded_edge): Delete.
1778 (exploded_edge::m_custom_info): Use std::unique_ptr.
1779 (exploded_edge::add_edge): Likewise.
1780 * sm-signal.cc (register_signal_handler::impl_transition): Use
1781 make_unique.
1782
1783 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1784
1785 * diagnostic-manager.cc (saved_diagnostic::saved_diagnostic): Make
1786 stmt_finder const.
1787 (saved_diagnostic::~saved_diagnostic): Remove explicit delete of
1788 m_stmt_finder.
1789 (diagnostic_manager::add_diagnostic): Make stmt_finder const.
1790 * diagnostic-manager.h (saved_diagnostic::saved_diagnostic):
1791 Likewise.
1792 (saved_diagnostic::m_stmt_finder): Convert to std::unique_ptr.
1793 (diagnostic_manager::add_diagnostic): Make stmt_finder const.
1794 * engine.cc (impl_sm_context::impl_sm_context): Likewise.
1795 (impl_sm_context::m_stmt_finder): Likewise.
1796 (leak_stmt_finder::clone): Convert return type to std::unique_ptr.
1797 * exploded-graph.h (stmt_finder::clone): Likewise.
1798
1799 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1800
1801 * call-info.cc: Add define of INCLUDE_MEMORY.
1802 * call-summary.cc: Likewise.
1803 * checker-path.cc: Likewise.
1804 * constraint-manager.cc: Likewise.
1805 * diagnostic-manager.cc: Likewise.
1806 (saved_diagnostic::saved_diagnostic): Use std::unique_ptr for
1807 param d and field m_d.
1808 (saved_diagnostic::~saved_diagnostic): Remove explicit delete of m_d.
1809 (saved_diagnostic::add_note): Use std::unique_ptr for
1810 param pn.
1811 (saved_diagnostic::get_pending_diagnostic): Update for conversion
1812 of m_sd.m_d to unique_ptr.
1813 (diagnostic_manager::add_diagnostic): Use std::unique_ptr for
1814 param d. Remove explicit deletion.
1815 (diagnostic_manager::add_note): Use std::unique_ptr for param pn.
1816 (diagnostic_manager::emit_saved_diagnostic): Update for conversion
1817 of m_sd.m_d to unique_ptr.
1818 (null_assignment_sm_context::warn): Use std::unique_ptr for
1819 param d. Remove explicit deletion.
1820 * diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Use
1821 std::unique_ptr for param d.
1822 (saved_diagnostic::add_note): Likewise for param pn.
1823 (saved_diagnostic::m_d): Likewise.
1824 (diagnostic_manager::add_diagnostic): Use std::unique_ptr for
1825 param d.
1826 (diagnostic_manager::add_note): Use std::unique_ptr for param pn.
1827 * engine.cc: Include "make-unique.h".
1828 (impl_region_model_context::warn): Update to use std::unique_ptr
1829 for param, removing explicit deletion.
1830 (impl_region_model_context::add_note): Likewise.
1831 (impl_sm_context::warn): Update to use std::unique_ptr
1832 for param.
1833 (impl_region_model_context::on_state_leak): Likewise for result of
1834 on_leak.
1835 (exploded_node::on_longjmp): Use make_unique when creating
1836 pending_diagnostic.
1837 (exploded_graph::process_node): Likewise.
1838 * exploded-graph.h (impl_region_model_context::warn): Update to
1839 use std::unique_ptr for param.
1840 (impl_region_model_context::add_note): Likewise.
1841 * feasible-graph.cc: Add define of INCLUDE_MEMORY.
1842 * pending-diagnostic.cc: Likewise.
1843 * pending-diagnostic.h: Include analyzer.sm.h"
1844 * program-point.cc: Add define of INCLUDE_MEMORY.
1845 * program-state.cc: Likewise.
1846 * region-model-asm.cc: Likewise.
1847 * region-model-impl-calls.cc: Likewise. Include "make-unique.h".
1848 (region_model::impl_call_putenv): Use make_unique when creating
1849 pending_diagnostic.
1850 * region-model-manager.cc: Add define of INCLUDE_MEMORY.
1851 * region-model-reachability.cc: Likewise.
1852 * region-model.cc: Likewise. Include "make-unique.h".
1853 (region_model::get_gassign_result): Use make_unique when creating
1854 pending_diagnostic.
1855 (region_model::check_for_poison): Likewise.
1856 (region_model::on_stmt_pre): Likewise.
1857 (region_model::check_symbolic_bounds): Likewise.
1858 (region_model::check_region_bounds): Likewise.
1859 (annotating_ctxt: make_note): Use std::unique_ptr for result.
1860 (region_model::deref_rvalue): Use make_unique when creating
1861 pending_diagnostic.
1862 (region_model::check_for_writable_region): Likewise.
1863 (region_model::check_region_size): Likewise.
1864 (region_model::check_dynamic_size_for_floats): Likewise.
1865 (region_model::maybe_complain_about_infoleak): Likewise.
1866 (noop_region_model_context::add_note): Use std::unique_ptr for
1867 param. Remove explicit deletion.
1868 * region-model.h: Include "analyzer/pending-diagnostic.h".
1869 (region_model_context::warn): Convert param to std::unique_ptr.
1870 (region_model_context::add_note): Likewise.
1871 (noop_region_model_context::warn): Likewise.
1872 (noop_region_model_context::add_note): Likewise.
1873 (region_model_context_decorator::warn): Likewise.
1874 (region_model_context_decorator::add_note): Likewise.
1875 (note_adding_context::warn): Likewise.
1876 (note_adding_context::make_note): Likewise for return type.
1877 (test_region_model_context::warn): Convert param to
1878 std::unique_ptr.
1879 * region.cc: Add define of INCLUDE_MEMORY.
1880 * sm-fd.cc: Likewise. Include "make-unique.h".
1881 (fd_state_machine::check_for_fd_attrs): Use make_unique when
1882 creating pending_diagnostics.
1883 (fd_state_machine::on_open): Likewise.
1884 (fd_state_machine::on_creat): Likewise.
1885 (fd_state_machine::check_for_dup): Likewise.
1886 (fd_state_machine::on_close): Likewise.
1887 (fd_state_machine::check_for_open_fd): Likewise.
1888 (fd_state_machine::on_leak): Likewise, converting return type to
1889 std::unique_ptr.
1890 * sm-file.cc: Add define of INCLUDE_MEMORY. Include
1891 "make-unique.h".
1892 (fileptr_state_machine::on_stmt): Use make_unique when creating
1893 pending_diagnostic.
1894 (fileptr_state_machine::on_leak): Likewise, converting return type
1895 to std::unique_ptr.
1896 * sm-malloc.cc: Add define of INCLUDE_MEMORY. Include
1897 "make-unique.h".
1898 (malloc_state_machine::on_stmt): Use make_unique when creating
1899 pending_diagnostic.
1900 (malloc_state_machine::handle_free_of_non_heap): Likewise.
1901 (malloc_state_machine::on_deallocator_call): Likewise.
1902 (malloc_state_machine::on_realloc_call): Likewise.
1903 (malloc_state_machine::on_leak): Likewise, converting return type
1904 to std::unique_ptr.
1905 * sm-pattern-test.cc: Add define of INCLUDE_MEMORY. Include
1906 "make-unique.h".
1907 (pattern_test_state_machine::on_condition): Use make_unique when
1908 creating pending_diagnostic.
1909 * sm-sensitive.cc: Add define of INCLUDE_MEMORY. Include
1910 "make-unique.h".
1911 (sensitive_state_machine::warn_for_any_exposure): Use make_unique
1912 when creating pending_diagnostic.
1913 * sm-signal.cc: Add define of INCLUDE_MEMORY. Include
1914 "make-unique.h".
1915 (signal_state_machine::on_stmt): Use make_unique when creating
1916 pending_diagnostic.
1917 * sm-taint.cc: Add define of INCLUDE_MEMORY. Include
1918 "make-unique.h".
1919 (taint_state_machine::check_for_tainted_size_arg): Use make_unique
1920 when creating pending_diagnostic.
1921 (taint_state_machine::check_for_tainted_divisor): Likewise.
1922 (region_model::check_region_for_taint): Likewise.
1923 (region_model::check_dynamic_size_for_taint): Likewise.
1924 * sm.cc: Add define of INCLUDE_MEMORY. Include
1925 "analyzer/pending-diagnostic.h".
1926 (state_machine::on_leak): Move here from sm.h, changing return
1927 type to std::unique_ptr.
1928 * sm.h (state_machine::on_leak): Change return type to
1929 std::unique_ptr. Move defn of base impl to sm.cc
1930 (sm_context::warn): Convert param d to std_unique_ptr.
1931 * state-purge.cc: Add define of INCLUDE_MEMORY.
1932 * store.cc: Likewise.
1933 * svalue.cc: Likewise.
1934 * trimmed-graph.cc: Likewise.
1935 * varargs.cc: Likewise. Include "make-unique.h".
1936 (va_list_state_machine::check_for_ended_va_list): Use make_unique
1937 when creating pending_diagnostic.
1938 (va_list_state_machine::on_leak): Likewise, converting return type
1939 to std::unique_ptr.
1940 (region_model::impl_call_va_arg): Use make_unique when creating
1941 pending_diagnostic.
1942
1943 2022-11-03 David Malcolm <dmalcolm@redhat.com>
1944
1945 PR analyzer/107486
1946 * analyzer.cc (is_pipe_call_p): New.
1947 * analyzer.h (is_pipe_call_p): New decl.
1948 * region-model.cc (region_model::on_call_pre): Use it.
1949 (region_model::on_call_post): Likewise.
1950
1951 2022-10-26 David Malcolm <dmalcolm@redhat.com>
1952
1953 * sm-fd.cc (fd_state_machine::on_open): Transition to "unchecked"
1954 when the mode is symbolic, rather than just on integer constants.
1955 (fd_state_machine::check_for_open_fd): Don't complain about
1956 unchecked values in the start state.
1957
1958 2022-10-26 David Malcolm <dmalcolm@redhat.com>
1959
1960 * sm-fd.dot: New file.
1961
1962 2022-10-24 David Malcolm <dmalcolm@redhat.com>
1963
1964 PR analyzer/107349
1965 * varargs.cc (get_va_copy_arg): Fix the non-pointer case.
1966
1967 2022-10-24 David Malcolm <dmalcolm@redhat.com>
1968
1969 PR analyzer/107345
1970 * region-model.cc (region_model::eval_condition_without_cm):
1971 Ensure that constants are on the right-hand side before checking
1972 for them.
1973
1974 2022-10-24 David Malcolm <dmalcolm@redhat.com>
1975
1976 * engine.cc (impl_region_model_context::get_malloc_map): Replace
1977 with...
1978 (impl_region_model_context::get_state_map_by_name): ...this.
1979 (impl_region_model_context::get_fd_map): Delete.
1980 (impl_region_model_context::get_taint_map): Delete.
1981 * exploded-graph.h (impl_region_model_context::get_fd_map):
1982 Delete.
1983 (impl_region_model_context::get_malloc_map): Delete.
1984 (impl_region_model_context::get_taint_map): Delete.
1985 (impl_region_model_context::get_state_map_by_name): New.
1986 * region-model.h (region_model_context::get_state_map_by_name):
1987 New vfunc.
1988 (region_model_context::get_fd_map): Convert from vfunc to
1989 function.
1990 (region_model_context::get_malloc_map): Likewise.
1991 (region_model_context::get_taint_map): Likewise.
1992 (noop_region_model_context::get_state_map_by_name): New.
1993 (noop_region_model_context::get_fd_map): Delete.
1994 (noop_region_model_context::get_malloc_map): Delete.
1995 (noop_region_model_context::get_taint_map): Delete.
1996 (region_model_context_decorator::get_state_map_by_name): New.
1997 (region_model_context_decorator::get_fd_map): Delete.
1998 (region_model_context_decorator::get_malloc_map): Delete.
1999 (region_model_context_decorator::get_taint_map): Delete.
2000
2001 2022-10-24 David Malcolm <dmalcolm@redhat.com>
2002
2003 PR analyzer/106300
2004 * engine.cc (impl_region_model_context::get_fd_map): New.
2005 * exploded-graph.h (impl_region_model_context::get_fd_map): New
2006 decl.
2007 * region-model-impl-calls.cc (region_model::impl_call_pipe): New.
2008 * region-model.cc (region_model::update_for_int_cst_return): New,
2009 based on...
2010 (region_model::update_for_zero_return): ...this. Reimplement in
2011 terms of the former.
2012 (region_model::on_call_pre): Handle "pipe" and "pipe2".
2013 (region_model::on_call_post): Likewise.
2014 * region-model.h (region_model::impl_call_pipe): New decl.
2015 (region_model::update_for_int_cst_return): New decl.
2016 (region_model::mark_as_valid_fd): New decl.
2017 (region_model_context::get_fd_map): New pure virtual fn.
2018 (noop_region_model_context::get_fd_map): New.
2019 (region_model_context_decorator::get_fd_map): New.
2020 * sm-fd.cc: Include "analyzer/program-state.h".
2021 (fd_state_machine::describe_state_change): Handle transitions from
2022 start state to valid states.
2023 (fd_state_machine::mark_as_valid_fd): New.
2024 (fd_state_machine::on_stmt): Add missing return for "creat".
2025 (region_model::mark_as_valid_fd): New.
2026
2027 2022-10-19 David Malcolm <dmalcolm@redhat.com>
2028
2029 PR analyzer/105765
2030 * varargs.cc (get_BT_VALIST_ARG): Rename to...
2031 (get_va_copy_arg): ...this, and update logic for determining level
2032 of indirection of va_copy's argument to use type of argument,
2033 rather than looking at va_list_type_node, to correctly handle
2034 __builtin_ms_va_copy.
2035 (get_stateful_BT_VALIST_ARG): Rename to...
2036 (get_stateful_va_copy_arg): ...this.
2037 (va_list_state_machine::on_va_copy): Update for renaming.
2038 (region_model::impl_call_va_copy): Likewise.
2039
2040 2022-10-13 David Malcolm <dmalcolm@redhat.com>
2041
2042 PR analyzer/107210
2043 * svalue.cc (constant_svalue::maybe_fold_bits_within): Only
2044 attempt to extract individual bits when tree_fits_uhwi_p.
2045
2046 2022-10-07 David Malcolm <dmalcolm@redhat.com>
2047
2048 PR analyzer/105783
2049 * region-model.cc (selftest::get_bit): New function.
2050 (selftest::test_bits_within_svalue_folding): New.
2051 (selfftest::analyzer_region_model_cc_tests): Call it.
2052 * svalue.cc (constant_svalue::maybe_fold_bits_within): Handle the
2053 case of extracting a single bit.
2054
2055 2022-10-06 David Malcolm <dmalcolm@redhat.com>
2056
2057 PR analyzer/107158
2058 * store.cc (store::replay_call_summary_cluster): Eliminate
2059 special-casing of RK_HEAP_ALLOCATED in favor of sharing code with
2060 RK_DECL, avoiding an ICE due to attempting to bind a
2061 compound_svalue into a binding_cluster when an svalue in the
2062 summary cluster converts to a compound_svalue in the caller.
2063
2064 2022-10-06 David Malcolm <dmalcolm@redhat.com>
2065
2066 * call-summary.cc (call_summary_replay::dump_to_pp): Bulletproof
2067 against NULL caller regions/svalues.
2068
2069 2022-10-05 David Malcolm <dmalcolm@redhat.com>
2070
2071 * analysis-plan.cc: Simplify includes.
2072 * analyzer-pass.cc: Likewise.
2073 * analyzer-selftests.cc: Likewise.
2074 * analyzer.cc: Likewise.
2075 * analyzer.h: Add includes of "json.h" and "tristate.h".
2076 * call-info.cc: Simplify includes.
2077 * call-string.cc: Likewise.
2078 * call-summary.cc: Likewise.
2079 * checker-path.cc: Likewise.
2080 * complexity.cc: Likewise.
2081 * constraint-manager.cc: Likewise.
2082 * diagnostic-manager.cc: Likewise.
2083 * engine.cc: Likewise.
2084 * feasible-graph.cc: Likewise.
2085 * known-function-manager.cc: Likewise.
2086 * pending-diagnostic.cc: Likewise.
2087 * program-point.cc: Likewise.
2088 * program-state.cc: Likewise.
2089 * region-model-asm.cc: Likewise.
2090 * region-model-impl-calls.cc: Likewise.
2091 * region-model-manager.cc: Likewise.
2092 * region-model-reachability.cc: Likewise.
2093 * region-model.cc: Likewise.
2094 * region-model.h: Include "selftest.h".
2095 * region.cc: Simplify includes.
2096 * sm-fd.cc: Likewise.
2097 * sm-file.cc: Likewise.
2098 * sm-malloc.cc: Likewise.
2099 * sm-pattern-test.cc: Likewise.
2100 * sm-sensitive.cc: Likewise.
2101 * sm-signal.cc: Likewise.
2102 * sm-taint.cc: Likewise.
2103 * sm.cc: Likewise.
2104 * state-purge.cc: Likewise.
2105 * store.cc: Likewise.
2106 * store.h: Likewise.
2107 * supergraph.cc: Likewise.
2108 * svalue.cc: Likewise.
2109 * svalue.h: Likewise.
2110 * trimmed-graph.cc: Likewise.
2111 * varargs.cc: Likewise.
2112
2113 2022-10-05 David Malcolm <dmalcolm@redhat.com>
2114
2115 PR analyzer/107060
2116 * call-summary.cc
2117 (call_summary_replay::convert_svalue_from_summary_1): Handle NULL
2118 results from convert_svalue_from_summary in SK_UNARY_OP and
2119 SK_BIN_OP.
2120 * engine.cc (impl_region_model_context::on_unknown_change): Bail
2121 out on svalues that can't have associated state.
2122 * region-model-impl-calls.cc
2123 (region_model::impl_call_analyzer_get_unknown_ptr): New.
2124 * region-model.cc (region_model::on_stmt_pre): Handle
2125 "__analyzer_get_unknown_ptr".
2126 * region-model.h
2127 (region_model::impl_call_analyzer_get_unknown_ptr): New decl.
2128 * store.cc (store::replay_call_summary_cluster): Avoid trying to
2129 create binding clusters for base regions that shouldn't have them.
2130
2131 2022-10-05 Martin Liska <mliska@suse.cz>
2132
2133 * call-summary.cc (call_summary_replay::call_summary_replay):
2134 Remove unused variable and arguments.
2135 * call-summary.h: Likewise.
2136 * engine.cc (exploded_node::on_stmt): Likewise.
2137 (exploded_node::replay_call_summaries): Likewise.
2138 (exploded_node::replay_call_summary): Likewise.
2139 * exploded-graph.h (class exploded_node): Likewise.
2140
2141 2022-10-05 David Malcolm <dmalcolm@redhat.com>
2142
2143 PR analyzer/107072
2144 * analyzer-logging.h: Include "diagnostic-core.h".
2145 * analyzer.h: Include "function.h".
2146 (class call_summary): New forward decl.
2147 (class call_summary_replay): New forward decl.
2148 (struct per_function_data): New forward decl.
2149 (struct interesting_t): New forward decl.
2150 (custom_edge_info::update_state): New vfunc.
2151 * call-info.cc (custom_edge_info::update_state): New.
2152 * call-summary.cc: New file.
2153 * call-summary.h: New file.
2154 * constraint-manager.cc: Include "analyzer/call-summary.h".
2155 (class replay_fact_visitor): New.
2156 (constraint_manager::replay_call_summary): New.
2157 * constraint-manager.h (constraint_manager::replay_call_summary):
2158 New.
2159 * engine.cc: Include "analyzer/call-summary.h".
2160 (exploded_node::on_stmt): Handle call summaries.
2161 (class call_summary_edge_info): New.
2162 (exploded_node::replay_call_summaries): New.
2163 (exploded_node::replay_call_summary): New.
2164 (per_function_data::~per_function_data): New.
2165 (per_function_data::add_call_summary): Move here from header and
2166 reimplement.
2167 (exploded_graph::process_node): Call update_state rather than
2168 update_model when handling bifurcation
2169 (viz_callgraph_node::dump_dot): Use a regular label rather
2170 than an HTML table; add summaries to dump.
2171 * exploded-graph.h: Include "alloc-pool.h", "fibonacci_heap.h",
2172 "supergraph.h", "sbitmap.h", "shortest-paths.h", "analyzer/sm.h",
2173 "analyzer/program-state.h", and "analyzer/diagnostic-manager.h".
2174 (exploded_node::replay_call_summaries): New decl.
2175 (exploded_node::replay_call_summary): New decl.
2176 (per_function_data::~per_function_data): New decl.
2177 (per_function_data::add_call_summary): Move implemention from
2178 header.
2179 (per_function_data::m_summaries): Update type of element.
2180 * known-function-manager.h: Include "analyzer/analyzer-logging.h".
2181 * program-point.h: Include "pretty-print.h" and
2182 "analyzer/call-string.h".
2183 * program-state.cc: Include "analyzer/call-summary.h".
2184 (sm_state_map::replay_call_summary): New.
2185 (program_state::replay_call_summary): New.
2186 * program-state.h (sm_state_map::replay_call_summary): New decl.
2187 (program_state::replay_call_summary): New decl.
2188 * region-model-manager.cc
2189 (region_model_manager::get_or_create_asm_output_svalue): New
2190 overload.
2191 * region-model-manager.h
2192 (region_model_manager::get_or_create_asm_output_svalue): New
2193 overload decl.
2194 * region-model.cc: Include "analyzer/call-summary.h".
2195 (region_model::maybe_update_for_edge): Remove call to
2196 region_model::update_for_call_summary on
2197 SUPEREDGE_INTRAPROCEDURAL_CALL.
2198 (region_model::update_for_call_summary): Delete.
2199 (region_model::replay_call_summary): New.
2200 * region-model.h (region_model::replay_call_summary): New decl.
2201 (region_model::update_for_call_summary): Delete decl.
2202 * store.cc: Include "analyzer/call-summary.h".
2203 (store::replay_call_summary): New.
2204 (store::replay_call_summary_cluster): New.
2205 * store.h: Include "tristate.h".
2206 (is_a_helper <const ana::concrete_binding *>::test): New.
2207 (store::replay_call_summary): New decl.
2208 (store::replay_call_summary_cluster): New decl.
2209 * supergraph.cc (get_ultimate_function_for_cgraph_edge): Remove
2210 "static" from decl.
2211 (supergraph_call_edge): Make stmt param const.
2212 * supergraph.h: Include "ordered-hash-map.h", "cfg.h",
2213 "basic-block.h", "gimple.h", "gimple-iterator.h", and "digraph.h".
2214 (supergraph_call_edge): Make stmt param const.
2215 (get_ultimate_function_for_cgraph_edge): New decl.
2216 * svalue.cc (compound_svalue::compound_svalue): Assert that we're
2217 not nesting compound_svalues.
2218 * svalue.h: Include "json.h", "analyzer/store.h", and
2219 "analyzer/program-point.h".
2220 (asm_output_svalue::get_num_outputs): New accessor.
2221
2222 2022-10-05 David Malcolm <dmalcolm@redhat.com>
2223
2224 * region-model.h: Include "analyzer/region-model-manager.h"
2225 (class region_model_manager): Move decl to...
2226 * region-model-manager.h: ...this new file.
2227
2228 2022-10-05 David Malcolm <dmalcolm@redhat.com>
2229
2230 * region-model-manager.cc
2231 (region_model_manager::maybe_fold_unaryop): Fold -(-(VAL)) to VAL.
2232
2233 2022-10-05 David Malcolm <dmalcolm@redhat.com>
2234
2235 * region-model-manager.cc
2236 (region_model_manager::get_or_create_widening_svalue): Use a
2237 function_point rather than a program_point.
2238 * region-model.cc (selftest::test_widening_constraints): Likewise.
2239 * region-model.h
2240 (region_model_manager::get_or_create_widening_svalue): Likewise.
2241 (model_merger::get_function_point): New.
2242 * svalue.cc (svalue::can_merge_p): Use a function_point rather
2243 than a program_point.
2244 (svalue::can_merge_p): Likewise.
2245 * svalue.h (widening_svalue::key_t): Likewise.
2246 (widening_svalue::widening_svalue): Likewise.
2247
2248 2022-09-12 Martin Liska <mliska@suse.cz>
2249
2250 * region-model.cc (region_model::maybe_complain_about_infoleak):
2251 Remove unused fields.
2252
2253 2022-09-11 Tim Lange <mail@tim-lange.me>
2254
2255 PR analyzer/106845
2256 * region-model.cc (region_model::check_region_bounds):
2257 Bail out if 0 bytes were accessed.
2258 * store.cc (byte_range::dump_to_pp):
2259 Add special case for empty ranges.
2260 (byte_range::exceeds_p): Restrict to non-empty ranges.
2261 (byte_range::falls_short_of_p): Restrict to non-empty ranges.
2262 * store.h (bit_range::empty_p): New function.
2263 (bit_range::get_last_byte_offset): Restrict to non-empty ranges.
2264 (byte_range::empty_p): New function.
2265 (byte_range::get_last_byte_offset): Restrict to non-empty ranges.
2266
2267 2022-09-09 David Malcolm <dmalcolm@redhat.com>
2268
2269 * analyzer.opt (Wanalyzer-exposure-through-uninit-copy): New.
2270 * checker-path.cc (region_creation_event::region_creation_event):
2271 Add "capacity" and "kind" params.
2272 (region_creation_event::get_desc): Generalize to different kinds
2273 of event.
2274 (checker_path::add_region_creation_event): Convert to...
2275 (checker_path::add_region_creation_events): ...this.
2276 * checker-path.h (enum rce_kind): New.
2277 (region_creation_event::region_creation_event): Add "capacity" and
2278 "kind" params.
2279 (region_creation_event::m_capacity): New field.
2280 (region_creation_event::m_rce_kind): New field.
2281 (checker_path::add_region_creation_event): Convert to...
2282 (checker_path::add_region_creation_events): ...this.
2283 * diagnostic-manager.cc (diagnostic_manager::build_emission_path):
2284 Update for multiple region creation events.
2285 (diagnostic_manager::add_event_on_final_node): Likewise.
2286 (diagnostic_manager::add_events_for_eedge): Likewise.
2287 * region-model-impl-calls.cc (call_details::get_logger): New.
2288 * region-model.cc: Define INCLUDE_MEMORY before including
2289 "system.h". Include "gcc-rich-location.h".
2290 (class record_layout): New.
2291 (class exposure_through_uninit_copy): New.
2292 (contains_uninit_p): New.
2293 (region_model::maybe_complain_about_infoleak): New.
2294 * region-model.h (call_details::get_logger): New decl.
2295 (region_model::maybe_complain_about_infoleak): New decl.
2296 (region_model::mark_as_tainted): New decl.
2297 * sm-taint.cc (region_model::mark_as_tainted): New.
2298
2299 2022-09-09 David Malcolm <dmalcolm@redhat.com>
2300
2301 * analyzer.h (class known_function_manager): New forward decl.
2302 (class known_function): New.
2303 (plugin_analyzer_init_iface::register_known_function): New.
2304 * engine.cc: Include "analyzer/known-function-manager.h".
2305 (plugin_analyzer_init_impl::plugin_analyzer_init_impl): Add
2306 known_fn_mgr param.
2307 (plugin_analyzer_init_impl::register_state_machine): Add
2308 LOC_SCOPE.
2309 (plugin_analyzer_init_impl::register_known_function): New.
2310 (plugin_analyzer_init_impl::m_known_fn_mgr): New.
2311 (impl_run_checkers): Update plugin callback invocation to use
2312 eng's known_function_manager.
2313 * known-function-manager.cc: New file.
2314 * known-function-manager.h: New file.
2315 * region-model-manager.cc
2316 (region_model_manager::region_model_manager): Pass logger to
2317 m_known_fn_mgr's ctor.
2318 * region-model.cc (region_model::update_for_zero_return): New.
2319 (region_model::update_for_nonzero_return): New.
2320 (maybe_simplify_upper_bound): New.
2321 (region_model::maybe_get_copy_bounds): New.
2322 (region_model::get_known_function): New.
2323 (region_model::on_call_pre): Handle plugin-supplied known
2324 functions.
2325 * region-model.h: Include "analyzer/known-function-manager.h".
2326 (region_model_manager::get_known_function_manager): New.
2327 (region_model_manager::m_known_fn_mgr): New.
2328 (call_details::get_model): New accessor.
2329 (region_model::maybe_get_copy_bounds): New decl.
2330 (region_model::update_for_zero_return): New decl.
2331 (region_model::update_for_nonzero_return): New decl.
2332 (region_model::get_known_function): New decl.
2333 (region_model::get_known_function_manager): New.
2334
2335 2022-09-08 Tim Lange <mail@tim-lange.me>
2336
2337 PR analyzer/106625
2338 * analyzer.h (region_offset): Eliminate m_is_symbolic member.
2339 * region-model-impl-calls.cc (region_model::impl_call_realloc):
2340 Refine implementation to be more precise.
2341 * region-model.cc (class symbolic_past_the_end):
2342 Abstract diagnostic class to complain about accesses past the end
2343 with symbolic values.
2344 (class symbolic_buffer_overflow):
2345 Concrete diagnostic class to complain about buffer overflows with
2346 symbolic values.
2347 (class symbolic_buffer_overread):
2348 Concrete diagnostic class to complain about buffer overreads with
2349 symbolic values.
2350 (region_model::check_symbolic_bounds): New function.
2351 (maybe_get_integer_cst_tree): New helper function.
2352 (region_model::check_region_bounds):
2353 Add call to check_symbolic_bounds if offset is not concrete.
2354 (region_model::eval_condition_without_cm):
2355 Add support for EQ_EXPR and GT_EXPR with binaryop_svalues.
2356 (is_positive_svalue): New hleper function.
2357 (region_model::symbolic_greater_than):
2358 New function to handle GT_EXPR comparisons with symbolic values.
2359 (region_model::structural_equality): New function to compare
2360 whether two svalues are structured the same, i.e. evaluate to
2361 the same value.
2362 (test_struct): Reflect changes to region::calc_offset.
2363 (test_var): Likewise.
2364 (test_array_2): Likewise and add selftest with symbolic i.
2365 * region-model.h (class region_model): Add check_symbolic_bounds,
2366 symbolic_greater_than and structural_equality.
2367 * region.cc (region::get_offset):
2368 Reflect changes to region::calc_offset.
2369 (region::calc_offset):
2370 Compute the symbolic offset if the offset is not concrete.
2371 (region::get_relative_symbolic_offset): New function to return the
2372 symbolic offset in bytes relative to its parent.
2373 (field_region::get_relative_symbolic_offset): Likewise.
2374 (element_region::get_relative_symbolic_offset): Likewise.
2375 (offset_region::get_relative_symbolic_offset): Likewise.
2376 (bit_range_region::get_relative_symbolic_offset): Likewise.
2377 * region.h: Add get_relative_symbolic_offset.
2378 * store.cc (binding_key::make):
2379 Reflect changes to region::calc_offset.
2380 (binding_map::apply_ctor_val_to_range): Likewise.
2381 (binding_map::apply_ctor_pair_to_child_region): Likewise.
2382 (binding_cluster::bind_compound_sval): Likewise.
2383 (binding_cluster::get_any_binding): Likewise.
2384 (binding_cluster::maybe_get_compound_binding): Likewise.
2385
2386 2022-09-05 Tim Lange <mail@tim-lange.me>
2387
2388 * region-model-impl-calls.cc (region_model::impl_call_strcpy):
2389 Handle the constant string case.
2390 * region-model.cc (region_model::get_string_size):
2391 New function to get the string size from a region or svalue.
2392 * region-model.h (class region_model): Add get_string_size.
2393
2394 2022-09-05 Tim Lange <mail@tim-lange.me>
2395
2396 * region.cc (cast_region::get_relative_concrete_offset):
2397 New overloaded method.
2398 * region.h: Add cast_region::get_relative_concrete_offset.
2399
2400 2022-08-22 Martin Liska <mliska@suse.cz>
2401
2402 * region-model.cc: Add missing final keyword.
2403
2404 2022-08-18 Tim Lange <mail@tim-lange.me>
2405
2406 PR analyzer/106181
2407 * analyzer.opt: Add Wanalyzer-imprecise-floating-point-arithmetic.
2408 * region-model.cc (is_any_cast_p): Formatting.
2409 (region_model::check_region_size): Ensure precondition.
2410 (class imprecise_floating_point_arithmetic): New abstract
2411 diagnostic class for all floating-point related warnings.
2412 (class float_as_size_arg): Concrete diagnostic class to complain
2413 about floating-point operands inside the size argument.
2414 (class contains_floating_point_visitor):
2415 New visitor to find floating-point operands inside svalues.
2416 (region_model::check_dynamic_size_for_floats): New function.
2417 (region_model::set_dynamic_extents):
2418 Call to check_dynamic_size_for_floats.
2419 * region-model.h (class region_model):
2420 Add region_model::check_dynamic_size_for_floats.
2421
2422 2022-08-16 Martin Liska <mliska@suse.cz>
2423
2424 * region-model.cc: Fix -Winconsistent-missing-override clang
2425 warning.
2426 * region.h: Likewise.
2427
2428 2022-08-15 David Malcolm <dmalcolm@redhat.com>
2429
2430 PR analyzer/106626
2431 * region-model.cc (buffer_overread::emit): Fix copy&paste error in
2432 direction of the access in the note.
2433
2434 2022-08-15 David Malcolm <dmalcolm@redhat.com>
2435
2436 PR analyzer/106573
2437 * region-model.cc (region_model::on_call_pre): Use check_call_args
2438 when ensuring that we call get_arg_svalue on all args. Remove
2439 redundant call from handling for stdio builtins.
2440
2441 2022-08-15 Immad Mir <mirimmad@outlook.com>
2442
2443 PR analyzer/106551
2444 * sm-fd.cc (check_for_dup): exit early if first
2445 argument is invalid for all dup functions.
2446
2447 2022-08-12 Tim Lange <mail@tim-lange.me>
2448
2449 PR analyzer/106000
2450 * analyzer.opt: Add Wanalyzer-out-of-bounds.
2451 * region-model.cc (class out_of_bounds): Diagnostics base class
2452 for all out-of-bounds diagnostics.
2453 (class past_the_end): Base class derived from out_of_bounds for
2454 the buffer_overflow and buffer_overread diagnostics.
2455 (class buffer_overflow): Buffer overflow diagnostics.
2456 (class buffer_overread): Buffer overread diagnostics.
2457 (class buffer_underflow): Buffer underflow diagnostics.
2458 (class buffer_underread): Buffer overread diagnostics.
2459 (region_model::check_region_bounds): New function to check region
2460 bounds for out-of-bounds accesses.
2461 (region_model::check_region_access):
2462 Add call to check_region_bounds.
2463 (region_model::get_representative_tree): New function that accepts
2464 a region instead of an svalue.
2465 * region-model.h (class region_model):
2466 Add region_model::check_region_bounds.
2467 * region.cc (region::symbolic_p): New predicate.
2468 (offset_region::get_byte_size_sval): Only return the remaining
2469 byte size on offset_regions.
2470 * region.h: Add region::symbolic_p.
2471 * store.cc (byte_range::intersects_p):
2472 Add new function equivalent to bit_range::intersects_p.
2473 (byte_range::exceeds_p): New function.
2474 (byte_range::falls_short_of_p): New function.
2475 * store.h (struct byte_range): Add byte_range::intersects_p,
2476 byte_range::exceeds_p and byte_range::falls_short_of_p.
2477
2478 2022-08-12 Tim Lange <mail@tim-lange.me>
2479
2480 PR analyzer/106539
2481 * region-model-impl-calls.cc (region_model::impl_call_realloc):
2482 Use the result of get_copied_size as the size for the
2483 sized_regions in realloc.
2484 (success_with_move::get_copied_size): New function.
2485
2486 2022-08-11 Immad Mir <mirimmad@outlook.com>
2487
2488 PR analyzer/106551
2489 * sm-fd.cc (check_for_dup): handle the m_start
2490 state when transitioning the state of LHS
2491 of dup, dup2 and dup3 call.
2492
2493 2022-08-09 David Malcolm <dmalcolm@redhat.com>
2494
2495 PR analyzer/106573
2496 * region-model.cc (region_model::on_call_pre): Ensure that we call
2497 get_arg_svalue on all arguments.
2498
2499 2022-08-05 David Malcolm <dmalcolm@redhat.com>
2500
2501 PR analyzer/105947
2502 * analyzer.opt (Wanalyzer-jump-through-null): New option.
2503 * engine.cc (class jump_through_null): New.
2504 (exploded_graph::process_node): Complain about jumps through NULL
2505 function pointers.
2506
2507 2022-08-02 Immad Mir <mirimmad@outlook.com>
2508
2509 PR analyzer/106298
2510 * sm-fd.cc (fd_state_machine::on_open): Add
2511 creat, dup, dup2 and dup3 functions.
2512 (enum dup): New.
2513 (fd_state_machine::valid_to_unchecked_state): New.
2514 (fd_state_machine::on_creat): New.
2515 (fd_state_machine::on_dup): New.
2516
2517 2022-07-28 David Malcolm <dmalcolm@redhat.com>
2518
2519 PR analyzer/105893
2520 * analyzer.opt (Wanalyzer-putenv-of-auto-var): New.
2521 * region-model-impl-calls.cc (class putenv_of_auto_var): New.
2522 (region_model::impl_call_putenv): New.
2523 * region-model.cc (region_model::on_call_pre): Handle putenv.
2524 * region-model.h (region_model::impl_call_putenv): New decl.
2525
2526 2022-07-28 David Malcolm <dmalcolm@redhat.com>
2527
2528 * sm-malloc.cc (free_of_non_heap::emit): Add comment about CWE.
2529 * sm-taint.cc (tainted_size::emit): Likewise.
2530
2531 2022-07-28 David Malcolm <dmalcolm@redhat.com>
2532
2533 * region.h: Add notes to the comment describing the region
2534 class hierarchy.
2535
2536 2022-07-27 Immad Mir <mirimmad@outlook.com>
2537
2538 PR analyzer/106286
2539 * sm-fd.cc:
2540 (fd_diagnostic::get_meaning_for_state_change): New.
2541
2542 2022-07-26 David Malcolm <dmalcolm@redhat.com>
2543
2544 PR analyzer/106319
2545 * store.cc (store::set_value): Don't strip away casts if the
2546 region has NULL type.
2547
2548 2022-07-26 David Malcolm <dmalcolm@redhat.com>
2549
2550 * region.h (code_region::get_element): Remove stray decl.
2551 (function_region::get_element): Likewise.
2552
2553 2022-07-25 Martin Liska <mliska@suse.cz>
2554
2555 * sm-fd.cc: Run dos2unix and fix coding style issues.
2556
2557 2022-07-23 Immad Mir <mirimmad@outlook.com>
2558
2559 * sm-fd.cc (fd_param_diagnostic): New diagnostic class.
2560 (fd_access_mode_mismatch): Change inheritance from fd_diagnostic
2561 to fd_param_diagnostic. Add new overloaded constructor.
2562 (fd_use_after_close): Likewise.
2563 (unchecked_use_of_fd): Likewise and also change name to fd_use_without_check.
2564 (double_close): Change name to fd_double_close.
2565 (enum access_directions): New.
2566 (fd_state_machine::on_stmt): Handle calls to function with the
2567 new three function attributes.
2568 (fd_state_machine::check_for_fd_attrs): New.
2569 (fd_state_machine::on_open): Use the new overloaded constructors
2570 of diagnostic classes.
2571
2572 2022-07-22 David Malcolm <dmalcolm@redhat.com>
2573
2574 PR analyzer/106413
2575 * varargs.cc (region_model::impl_call_va_start): Avoid iterating
2576 through non-existant variadic arguments by initializing the
2577 impl_region to "UNKNOWN" if the va_start occurs in the top-level
2578 function to the analysis.
2579
2580 2022-07-22 David Malcolm <dmalcolm@redhat.com>
2581
2582 PR analyzer/106401
2583 * store.cc (binding_cluster::binding_cluster): Remove overzealous
2584 assertion; we're checking for tracked_p in
2585 store::get_or_create_cluster.
2586
2587 2022-07-22 Tim Lange <mail@tim-lange.me>
2588
2589 PR analyzer/106394
2590 * region-model.cc (capacity_compatible_with_type): Always return true
2591 if alloc_size is zero.
2592
2593 2022-07-21 David Malcolm <dmalcolm@redhat.com>
2594
2595 PR analyzer/106383
2596 * varargs.cc (region_model::impl_call_va_arg): When determining if
2597 we're doing interprocedural analysis, use the stack depth of the
2598 frame in which va_start was called, rather than the current stack
2599 depth.
2600
2601 2022-07-21 David Malcolm <dmalcolm@redhat.com>
2602
2603 * sm-taint.cc (tainted_array_index::emit): Bulletproof against
2604 NULL m_arg.
2605 (tainted_array_index::describe_final_event): Likewise.
2606 (tainted_size::emit): Likewise.
2607 (tainted_size::describe_final_event): Likewise.
2608
2609 2022-07-21 David Malcolm <dmalcolm@redhat.com>
2610
2611 PR analyzer/106374
2612 * region.cc (decl_region::get_svalue_for_initializer): Bail out on
2613 untracked regions.
2614
2615 2022-07-20 David Malcolm <dmalcolm@redhat.com>
2616
2617 PR analyzer/106373
2618 * sm-taint.cc (taint_state_machine::on_condition): Potentially
2619 update the state of the RHS as well as the LHS.
2620
2621 2022-07-20 David Malcolm <dmalcolm@redhat.com>
2622
2623 PR analyzer/106359
2624 * region.h (string_region::tracked_p): New.
2625 * store.cc (binding_cluster::binding_cluster): Move here from
2626 store.h. Add assertion that base_region is tracked_p.
2627 * store.h (binding_cluster::binding_cluster): Move to store.cc.
2628
2629 2022-07-19 David Malcolm <dmalcolm@redhat.com>
2630
2631 PR analyzer/106321
2632 * constraint-manager.h (bounded_ranges::get_count): New.
2633 (bounded_ranges::get_range): New.
2634 * engine.cc (impl_region_model_context::on_bounded_ranges): New.
2635 * exploded-graph.h (impl_region_model_context::on_bounded_ranges):
2636 New decl.
2637 * region-model.cc (region_model::apply_constraints_for_gswitch):
2638 Potentially call ctxt->on_bounded_ranges.
2639 * region-model.h (region_model_context::on_bounded_ranges): New
2640 vfunc.
2641 (noop_region_model_context::on_bounded_ranges): New.
2642 (region_model_context_decorator::on_bounded_ranges): New.
2643 * sm-taint.cc: Include "analyzer/constraint-manager.h".
2644 (taint_state_machine::on_bounded_ranges): New.
2645 * sm.h (state_machine::on_bounded_ranges): New.
2646
2647 2022-07-19 David Malcolm <dmalcolm@redhat.com>
2648
2649 * engine.cc (exploded_graph::process_node): Show any description
2650 of the out-edge when logging it for consideration.
2651
2652 2022-07-15 David Malcolm <dmalcolm@redhat.com>
2653
2654 PR analyzer/106284
2655 * sm-taint.cc (taint_state_machine::on_condition): Handle range
2656 checks optimized by build_range_check.
2657
2658 2022-07-15 Jonathan Wakely <jwakely@redhat.com>
2659
2660 * call-info.cc (call_info::print): Adjust to new label_text API.
2661 * checker-path.cc (checker_event::dump): Likewise.
2662 (region_creation_event::get_desc): Likewise.
2663 (state_change_event::get_desc): Likewise.
2664 (superedge_event::should_filter_p): Likewise.
2665 (start_cfg_edge_event::get_desc): Likewise.
2666 (call_event::get_desc): Likewise.
2667 (return_event::get_desc): Likewise.
2668 (warning_event::get_desc): Likewise.
2669 (checker_path::dump): Likewise.
2670 (checker_path::debug): Likewise.
2671 * diagnostic-manager.cc (diagnostic_manager::prune_for_sm_diagnostic):
2672 Likewise.
2673 (diagnostic_manager::prune_interproc_events): Likewise.
2674 * engine.cc (feasibility_state::maybe_update_for_edge):
2675 Likewise.
2676 * program-state.cc (sm_state_map::to_json): Likewise.
2677 * region-model-impl-calls.cc (region_model::impl_call_analyzer_describe): Likewise.
2678 (region_model::impl_call_analyzer_dump_capacity): Likewise.
2679 * region.cc (region::to_json): Likewise.
2680 * sm-malloc.cc (inform_nonnull_attribute): Likewise.
2681 * store.cc (binding_map::to_json): Likewise.
2682 (store::to_json): Likewise.
2683 * supergraph.cc (superedge::dump): Likewise.
2684 * svalue.cc (svalue::to_json): Likewise.
2685
2686 2022-07-07 David Malcolm <dmalcolm@redhat.com>
2687
2688 * checker-path.cc (start_cfg_edge_event::get_desc): Update for
2689 superedge::get_description returning a label_text.
2690 * engine.cc (feasibility_state::maybe_update_for_edge): Likewise.
2691 * supergraph.cc (superedge::dump): Likewise.
2692 (superedge::get_description): Convert return type from char * to
2693 label_text.
2694 * supergraph.h (superedge::get_description): Likewise.
2695
2696 2022-07-07 David Malcolm <dmalcolm@redhat.com>
2697
2698 * call-info.cc (call_info::print): Update for removal of
2699 label_text::maybe_free in favor of automatic memory management.
2700 * checker-path.cc (checker_event::dump): Likewise.
2701 (checker_event::prepare_for_emission): Likewise.
2702 (state_change_event::get_desc): Likewise.
2703 (superedge_event::should_filter_p): Likewise.
2704 (start_cfg_edge_event::get_desc): Likewise.
2705 (warning_event::get_desc): Likewise.
2706 (checker_path::dump): Likewise.
2707 (checker_path::debug): Likewise.
2708 * diagnostic-manager.cc
2709 (diagnostic_manager::prune_for_sm_diagnostic): Likewise.
2710 (diagnostic_manager::prune_interproc_events): Likewise.
2711 * program-state.cc (sm_state_map::to_json): Likewise.
2712 * region.cc (region::to_json): Likewise.
2713 * sm-malloc.cc (inform_nonnull_attribute): Likewise.
2714 * store.cc (binding_map::to_json): Likewise.
2715 (store::to_json): Likewise.
2716 * svalue.cc (svalue::to_json): Likewise.
2717
2718 2022-07-07 David Malcolm <dmalcolm@redhat.com>
2719
2720 PR analyzer/106225
2721 * sm-taint.cc (taint_state_machine::on_stmt): Move handling of
2722 assignments from division to...
2723 (taint_state_machine::check_for_tainted_divisor): ...this new
2724 function. Reject warning when the divisor is known to be non-zero.
2725 * sm.cc: Include "analyzer/program-state.h".
2726 (sm_context::get_old_region_model): New.
2727 * sm.h (sm_context::get_old_region_model): New decl.
2728
2729 2022-07-06 Immad Mir <mirimmad@outlook.com>
2730
2731 PR analyzer/106184
2732 * sm-fd.cc (fd_state_machine): Change ordering of initialization
2733 of state m_invalid so that the order of initializers is same as
2734 the ordering of the fields in the class decl.
2735
2736 2022-07-06 Immad Mir <mirimmad@outlook.com>
2737
2738 * sm-fd.cc (use_after_close): save the "close" event and
2739 show it where possible.
2740
2741 2022-07-06 David Malcolm <dmalcolm@redhat.com>
2742
2743 PR analyzer/106204
2744 * region-model.cc (within_short_circuited_stmt_p): Move extraction
2745 of assign_stmt to caller.
2746 (due_to_ifn_deferred_init_p): New.
2747 (region_model::check_for_poison): Move extraction of assign_stmt
2748 from within_short_circuited_stmt_p to here. Share logic with
2749 call to due_to_ifn_deferred_init_p.
2750
2751 2022-07-02 Tim Lange <mail@tim-lange.me>
2752
2753 PR analyzer/105900
2754 * analyzer.opt: Added Wanalyzer-allocation-size.
2755 * checker-path.cc (region_creation_event::get_desc): Added call to new
2756 virtual function pending_diagnostic::describe_region_creation_event.
2757 * checker-path.h: Added region_creation_event::get_desc.
2758 * diagnostic-manager.cc (diagnostic_manager::add_event_on_final_node):
2759 New function.
2760 * diagnostic-manager.h:
2761 Added diagnostic_manager::add_event_on_final_node.
2762 * pending-diagnostic.h (struct region_creation): New event_desc struct.
2763 (pending_diagnostic::describe_region_creation_event): Added virtual
2764 function to overwrite description of a region creation.
2765 * region-model.cc (class dubious_allocation_size): New class.
2766 (capacity_compatible_with_type): New helper function.
2767 (class size_visitor): New class.
2768 (struct_or_union_with_inheritance_p): New helper function.
2769 (is_any_cast_p): New helper function.
2770 (region_model::check_region_size): New function.
2771 (region_model::set_value): Added call to
2772 region_model::check_region_size.
2773 * region-model.h (class region_model): New function check_region_size.
2774 * svalue.cc (region_svalue::accept): Changed to post-order traversal.
2775 (initial_svalue::accept): Likewise.
2776 (unaryop_svalue::accept): Likewise.
2777 (binop_svalue::accept): Likewise.
2778 (sub_svalue::accept): Likewise.
2779 (repeated_svalue::accept): Likewise.
2780 (bits_within_svalue::accept): Likewise.
2781 (widening_svalue::accept): Likewise.
2782 (unmergeable_svalue::accept): Likewise.
2783 (compound_svalue::accept): Likewise.
2784 (conjured_svalue::accept): Likewise.
2785 (asm_output_svalue::accept): Likewise.
2786 (const_fn_result_svalue::accept): Likewise.
2787
2788 2022-07-02 Immad Mir <mirimmad17@gmail.com>
2789
2790 PR analyzer/106003
2791 * analyzer.opt (Wanalyzer-fd-leak): New option.
2792 (Wanalyzer-fd-access-mode-mismatch): New option.
2793 (Wanalyzer-fd-use-without-check): New option.
2794 (Wanalyzer-fd-double-close): New option.
2795 (Wanalyzer-fd-use-after-close): New option.
2796 * sm.h (make_fd_state_machine): New decl.
2797 * sm.cc (make_checkers): Call make_fd_state_machine.
2798 * sm-fd.cc: New file.
2799
2800 2022-06-24 David Malcolm <dmalcolm@redhat.com>
2801
2802 * call-string.cc: Add includes of "analyzer/analyzer.h"
2803 and "analyzer/analyzer-logging.h".
2804 (call_string::call_string): Delete copy ctor.
2805 (call_string::operator=): Delete.
2806 (call_string::operator==): Delete.
2807 (call_string::hash): Delete.
2808 (call_string::push_call): Make const, returning the resulting
2809 call_string.
2810 (call_string::pop): Delete.
2811 (call_string::cmp_ptr_ptr): New.
2812 (call_string::validate): Assert that m_parent is non-NULL, or
2813 m_elements is empty.
2814 (call_string::call_string): Move default ctor here from
2815 call-string.h and reimplement. Add ctor taking a parent
2816 and an element.
2817 (call_string::~call_string): New.
2818 (call_string::recursive_log): New.
2819 * call-string.h (call_string::call_string): Move default ctor's
2820 defn to call-string.cc. Delete copy ctor. Add ctor taking a
2821 parent and an element.
2822 (call_string::operator=): Delete.
2823 (call_string::operator==): Delete.
2824 (call_string::hash): Delete.
2825 (call_string::push_call): Make const, returning the resulting
2826 call_string.
2827 (call_string::pop): Delete decl.
2828 (call_string::get_parent): New.
2829 (call_string::cmp_ptr_ptr): New decl.
2830 (call_string::get_top_of_stack): New.
2831 (struct call_string::hashmap_traits_t): New.
2832 (class call_string): Add friend class region_model_manager. Add
2833 DISABLE_COPY_AND_ASSIGN.
2834 (call_string::~call_string): New decl.
2835 (call_string::recursive_log): New decl.
2836 (call_string::m_parent): New field.
2837 (call_string::m_children): New field.
2838 * constraint-manager.cc (selftest::test_many_constants): Pass
2839 model manager to program_point::origin.
2840 * engine.cc (exploded_graph::exploded_graph): Likewise.
2841 (exploded_graph::add_function_entry): Likewise for
2842 program_point::from_function_entry.
2843 (add_tainted_args_callback): Likewise.
2844 (exploded_graph::maybe_process_run_of_before_supernode_enodes):
2845 Update for change to program_point.get_call_string.
2846 (exploded_graph::process_node): Likewise.
2847 (class function_call_string_cluster): Convert m_cs from a
2848 call_string to a const call_string &.
2849 (struct function_call_string): Likewise.
2850 (pod_hash_traits<function_call_string>::hash): Use pointer_hash
2851 for m_cs.
2852 (pod_hash_traits<function_call_string>::equal): Update for change
2853 to m_cs.
2854 (root_cluster::add_node): Update for change to
2855 function_call_string.
2856 (viz_callgraph_node::dump_dot): Update for change to call_string.
2857 * exploded-graph.h (per_call_string_data::m_key): Convert to a
2858 reference.
2859 (struct eg_call_string_hash_map_traits): Delete.
2860 (exploded_graph::call_string_data_map_t): Remove traits class.
2861 * program-point.cc: Move include of "analyzer/call-string.h" to
2862 after "analyzer/analyzer-logging.h".
2863 (program_point::print): Update for conversion of m_call_string to
2864 a pointer.
2865 (program_point::to_json): Likewise.
2866 (program_point::push_to_call_stack): Update for immutability of
2867 call strings.
2868 (program_point::pop_from_call_stack): Likewise.
2869 (program_point::hash): Use pointer hashing for m_call_string.
2870 (program_point::get_function_at_depth): Update for change to
2871 m_call_string.
2872 (program_point::validate): Update for changes to call_string.
2873 (program_point::on_edge): Likewise.
2874 (program_point::origin): Move here from call-string.h. Add
2875 region_model_manager param and use it to get empty call string.
2876 (program_point::from_function_entry): Likewise.
2877 (selftest::test_function_point_ordering): Likewise.
2878 (selftest::test_function_point_ordering): Likewise.
2879 * program-point.h (program_point::program_point): Update for
2880 change to m_call_string.
2881 (program_point::get_call_string): Likewise.
2882 (program_point::get_stack_depth): Likewise.
2883 (program_point::origin): Add region_model_manager param, and move
2884 defn to call-string.cc.
2885 (program_point::from_function_entry): Likewise.
2886 (program_point::empty): Drop call_string.
2887 (program_point::deleted): Likewise.
2888 (program_point::program_point): New private ctor.
2889 (program_point::m_call_string): Convert from call_string to const
2890 call_string *.
2891 * program-state.cc (selftest::test_program_state_merging): Update
2892 for call_string changes.
2893 (selftest::test_program_state_merging_2): Likewise.
2894 * region-model-manager.cc
2895 (region_model_manager::region_model_manager): Construct
2896 m_empty_call_string.
2897 (region_model_manager::log_stats): Log the call strings.
2898 * region-model.cc (assert_region_models_merge): Pass the
2899 region_model_manager when creating program_point instances.
2900 (selftest::test_state_merging): Likewise.
2901 (selftest::test_constraint_merging): Likewise.
2902 (selftest::test_widening_constraints): Likewise.
2903 (selftest::test_iteration_1): Likewise.
2904 * region-model.h (region_model_manager::get_empty_call_string):
2905 New.
2906 (region_model_manager::m_empty_call_string): New.
2907 * sm-signal.cc (register_signal_handler::impl_transition): Update
2908 for changes to call_string.
2909
2910 2022-06-24 David Malcolm <dmalcolm@redhat.com>
2911
2912 * call-string.cc (call_string::calc_recursion_depth): Whitespace
2913 cleanups.
2914 (call_string::cmp): Likewise.
2915 (call_string::get_caller_node): Likewise.
2916 (call_string::validate): Likewise.
2917 * engine.cc (dynamic_call_info_t::add_events_to_path): Likewise.
2918 (exploded_graph::get_per_function_data): Likewise.
2919 (exploded_graph::maybe_create_dynamic_call): Likewise.
2920 (exploded_graph::maybe_create_dynamic_call): Likewise.
2921 (exploded_graph::process_node): Likewise.
2922
2923 2022-06-16 David Malcolm <dmalcolm@redhat.com>
2924
2925 * varargs.cc (va_arg_type_mismatch::emit): Associate the warning
2926 with CWE-686 ("Function Call With Incorrect Argument Type").
2927
2928 2022-06-16 David Malcolm <dmalcolm@redhat.com>
2929
2930 * varargs.cc: Include "diagnostic-metadata.h".
2931 (va_list_exhausted::emit): Associate the warning with
2932 CWE-685 ("Function Call With Incorrect Number of Arguments").
2933
2934 2022-06-16 David Malcolm <dmalcolm@redhat.com>
2935
2936 * sm-file.cc (double_fclose::emit): Associate the warning with
2937 CWE-1341 ("Multiple Releases of Same Resource or Handle").
2938
2939 2022-06-15 David Malcolm <dmalcolm@redhat.com>
2940
2941 PR analyzer/105962
2942 * analyzer.opt (fanalyzer-undo-inlining): New option.
2943 * checker-path.cc: Include "diagnostic-core.h" and
2944 "inlining-iterator.h".
2945 (event_kind_to_string): Handle EK_INLINED_CALL.
2946 (class inlining_info): New class.
2947 (checker_event::checker_event): Move here from checker-path.h.
2948 Store original fndecl and depth, and calculate effective fndecl
2949 and depth based on inlining information.
2950 (checker_event::dump): Emit original depth as well as effective
2951 depth when they differ; likewise for fndecl.
2952 (region_creation_event::get_desc): Use m_effective_fndecl.
2953 (inlined_call_event::get_desc): New.
2954 (inlined_call_event::get_meaning): New.
2955 (checker_path::inject_any_inlined_call_events): New.
2956 * checker-path.h (enum event_kind): Add EK_INLINED_CALL.
2957 (checker_event::checker_event): Make protected, and move
2958 definition to checker-path.cc.
2959 (checker_event::get_fndecl): Use effective fndecl.
2960 (checker_event::get_stack_depth): Use effective stack depth.
2961 (checker_event::get_logical_location): Use effective stack depth.
2962 (checker_event::get_original_stack_depth): New.
2963 (checker_event::m_fndecl): Rename to...
2964 (checker_event::m_original_fndecl): ...this.
2965 (checker_event::m_depth): Rename to...
2966 (checker_event::m_original_depth): ...this.
2967 (checker_event::m_effective_fndecl): New field.
2968 (checker_event::m_effective_depth): New field.
2969 (class inlined_call_event): New checker_event subclass.
2970 (checker_path::inject_any_inlined_call_events): New decl.
2971 * diagnostic-manager.cc: Include "inlining-iterator.h".
2972 (diagnostic_manager::emit_saved_diagnostic): Call
2973 checker_path::inject_any_inlined_call_events.
2974 (diagnostic_manager::prune_for_sm_diagnostic): Handle
2975 EK_INLINED_CALL.
2976 * engine.cc (tainted_args_function_custom_event::get_desc): Use
2977 effective fndecl.
2978 * inlining-iterator.h: New file.
2979
2980 2022-06-15 David Malcolm <dmalcolm@redhat.com>
2981
2982 * diagnostic-manager.cc (saved_diagnostic::dump_dot_id): New.
2983 (saved_diagnostic::dump_as_dot_node): New.
2984 * diagnostic-manager.h (saved_diagnostic::dump_dot_id): New decl.
2985 (saved_diagnostic::dump_as_dot_node): New decl.
2986 * engine.cc (exploded_node::dump_dot): Add nodes for saved
2987 diagnostics.
2988
2989 2022-06-02 David Malcolm <dmalcolm@redhat.com>
2990
2991 * checker-path.cc (checker_event::get_meaning): New.
2992 (function_entry_event::get_meaning): New.
2993 (state_change_event::get_desc): Add dump of meaning of the event
2994 to the -fanalyzer-verbose-state-changes output.
2995 (state_change_event::get_meaning): New.
2996 (cfg_edge_event::get_meaning): New.
2997 (call_event::get_meaning): New.
2998 (return_event::get_meaning): New.
2999 (start_consolidated_cfg_edges_event::get_meaning): New.
3000 (warning_event::get_meaning): New.
3001 * checker-path.h: Include "tree-logical-location.h".
3002 (checker_event::checker_event): Construct m_logical_loc.
3003 (checker_event::get_logical_location): New.
3004 (checker_event::get_meaning): New decl.
3005 (checker_event::m_logical_loc): New.
3006 (function_entry_event::get_meaning): New decl.
3007 (state_change_event::get_meaning): New decl.
3008 (cfg_edge_event::get_meaning): New decl.
3009 (call_event::get_meaning): New decl.
3010 (return_event::get_meaning): New decl.
3011 (start_consolidated_cfg_edges_event::get_meaning): New.
3012 (warning_event::get_meaning): New decl.
3013 * pending-diagnostic.h: Include "diagnostic-path.h".
3014 (pending_diagnostic::get_meaning_for_state_change): New vfunc.
3015 * sm-file.cc (file_diagnostic::get_meaning_for_state_change): New
3016 vfunc impl.
3017 * sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change):
3018 Likewise.
3019 * sm-sensitive.cc
3020 (exposure_through_output_file::get_meaning_for_state_change):
3021 Likewise.
3022 * sm-taint.cc (taint_diagnostic::get_meaning_for_state_change):
3023 Likewise.
3024 * varargs.cc
3025 (va_list_sm_diagnostic::get_meaning_for_state_change): Likewise.
3026
3027 2022-05-23 David Malcolm <dmalcolm@redhat.com>
3028
3029 * call-info.cc: Add "final" and "override" to all vfunc
3030 implementations that were missing them, as appropriate.
3031 * engine.cc: Likewise.
3032 * region-model.cc: Likewise.
3033 * sm-malloc.cc: Likewise.
3034 * supergraph.h: Likewise.
3035 * svalue.cc: Likewise.
3036 * varargs.cc: Likewise.
3037
3038 2022-05-20 David Malcolm <dmalcolm@redhat.com>
3039
3040 * analyzer-pass.cc: Replace uses of "FINAL" and "OVERRIDE" with
3041 "final" and "override".
3042 * call-info.h: Likewise.
3043 * checker-path.h: Likewise.
3044 * constraint-manager.cc: Likewise.
3045 * diagnostic-manager.cc: Likewise.
3046 * engine.cc: Likewise.
3047 * exploded-graph.h: Likewise.
3048 * feasible-graph.h: Likewise.
3049 * pending-diagnostic.h: Likewise.
3050 * region-model-impl-calls.cc: Likewise.
3051 * region-model.cc: Likewise.
3052 * region-model.h: Likewise.
3053 * region.h: Likewise.
3054 * sm-file.cc: Likewise.
3055 * sm-malloc.cc: Likewise.
3056 * sm-pattern-test.cc: Likewise.
3057 * sm-sensitive.cc: Likewise.
3058 * sm-signal.cc: Likewise.
3059 * sm-taint.cc: Likewise.
3060 * state-purge.h: Likewise.
3061 * store.cc: Likewise.
3062 * store.h: Likewise.
3063 * supergraph.h: Likewise.
3064 * svalue.h: Likewise.
3065 * trimmed-graph.h: Likewise.
3066 * varargs.cc: Likewise.
3067
3068 2022-05-16 David Malcolm <dmalcolm@redhat.com>
3069
3070 PR analyzer/105103
3071 * analyzer.cc (make_label_text_n): New.
3072 * analyzer.h (class var_arg_region): New forward decl.
3073 (make_label_text_n): New decl.
3074 * analyzer.opt (Wanalyzer-va-arg-type-mismatch): New option.
3075 (Wanalyzer-va-list-exhausted): New option.
3076 (Wanalyzer-va-list-leak): New option.
3077 (Wanalyzer-va-list-use-after-va-end): New option.
3078 * checker-path.cc (call_event::get_desc): Split out decl access
3079 into..
3080 (call_event::get_caller_fndecl): ...this new function and...
3081 (call_event::get_callee_fndecl): ...this new function.
3082 * checker-path.h (call_event::get_desc): Drop "FINAL".
3083 (call_event::get_caller_fndecl): New decl.
3084 (call_event::get_callee_fndecl): New decl.
3085 (class call_event): Make fields protected.
3086 * diagnostic-manager.cc (null_assignment_sm_context::warn): New
3087 overload.
3088 (null_assignment_sm_context::get_new_program_state): New.
3089 (diagnostic_manager::add_events_for_superedge): Move case
3090 SUPEREDGE_CALL to a new pending_diagnostic::add_call_event vfunc.
3091 * engine.cc (impl_sm_context::warn): Implement new override.
3092 (impl_sm_context::get_new_program_state): New.
3093 * pending-diagnostic.cc: Include "analyzer/diagnostic-manager.h",
3094 "cpplib.h", "digraph.h", "ordered-hash-map.h", "cfg.h",
3095 "basic-block.h", "gimple.h", "gimple-iterator.h", "cgraph.h"
3096 "analyzer/supergraph.h", "analyzer/program-state.h",
3097 "alloc-pool.h", "fibonacci_heap.h", "shortest-paths.h",
3098 "sbitmap.h", "analyzer/exploded-graph.h", "diagnostic-path.h",
3099 and "analyzer/checker-path.h".
3100 (ht_ident_eq): New.
3101 (fixup_location_in_macro_p): New.
3102 (pending_diagnostic::fixup_location): New.
3103 (pending_diagnostic::add_call_event): New.
3104 * pending-diagnostic.h (pending_diagnostic::fixup_location): Drop
3105 no-op inline implementation in favor of the more complex
3106 implementation above.
3107 (pending_diagnostic::add_call_event): New vfunc.
3108 * region-model-impl-calls.cc: Include "analyzer/sm.h",
3109 "diagnostic-path.h", and "analyzer/pending-diagnostic.h".
3110 * region-model-manager.cc
3111 (region_model_manager::get_var_arg_region): New.
3112 (region_model_manager::log_stats): Log m_var_arg_regions.
3113 * region-model.cc (region_model::on_call_pre): Handle IFN_VA_ARG,
3114 BUILT_IN_VA_START, and BUILT_IN_VA_COPY.
3115 (region_model::on_call_post): Handle BUILT_IN_VA_END.
3116 (region_model::get_representative_path_var_1): Handle RK_VAR_ARG.
3117 (region_model::push_frame): Push variadic arguments.
3118 * region-model.h (region_model_manager::get_var_arg_region): New
3119 decl.
3120 (region_model_manager::m_var_arg_regions): New field.
3121 (region_model::impl_call_va_start): New decl.
3122 (region_model::impl_call_va_copy): New decl.
3123 (region_model::impl_call_va_arg): New decl.
3124 (region_model::impl_call_va_end): New decl.
3125 * region.cc (alloca_region::dump_to_pp): Dump the id.
3126 (var_arg_region::dump_to_pp): New.
3127 (var_arg_region::get_frame_region): New.
3128 * region.h (enum region_kind): Add RK_VAR_ARG.
3129 (region::dyn_cast_var_arg_region): New.
3130 (class var_arg_region): New.
3131 (is_a_helper <const var_arg_region *>::test): New.
3132 (struct default_hash_traits<var_arg_region::key_t>): New.
3133 * sm.cc (make_checkers): Call make_va_list_state_machine.
3134 * sm.h (sm_context::warn): New vfunc.
3135 (sm_context::get_old_svalue): Drop unused decl.
3136 (sm_context::get_new_program_state): New vfunc.
3137 (make_va_list_state_machine): New decl.
3138 * varargs.cc: New file.
3139
3140 2022-05-16 Martin Liska <mliska@suse.cz>
3141
3142 * engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE.
3143 * function-set.cc (test_stdio_example): Likewise.
3144 * sm-file.cc (get_file_using_fns): Likewise.
3145 * sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise.
3146 * sm-signal.cc (get_async_signal_unsafe_fns): Likewise.
3147
3148 2022-05-13 Richard Biener <rguenther@suse.de>
3149
3150 * supergraph.cc: Re-order gimple-fold.h include.
3151
3152 2022-05-11 David Malcolm <dmalcolm@redhat.com>
3153
3154 * checker-path.cc (state_change_event::get_desc): Call maybe_free
3155 on label_text temporaries.
3156 * diagnostic-manager.cc
3157 (diagnostic_manager::prune_for_sm_diagnostic): Likewise.
3158 * engine.cc (exploded_graph::~exploded_graph): Fix leak of
3159 m_per_point_data and m_per_call_string_data values. Simplify
3160 cleanup of m_per_function_stats and m_per_point_data values.
3161 (feasibility_state::maybe_update_for_edge): Fix leak of result of
3162 superedge::get_description.
3163 * region-model-manager.cc
3164 (region_model_manager::~region_model_manager): Move cleanup of
3165 m_setjmp_values to match the ordering of the fields within
3166 region_model_manager. Fix leak of values within
3167 m_repeated_values_map, m_bits_within_values_map,
3168 m_asm_output_values_map, and m_const_fn_result_values_map.
3169
3170 2022-04-28 David Malcolm <dmalcolm@redhat.com>
3171
3172 PR analyzer/105285
3173 * store.cc (binding_cluster::get_any_binding): Handle accessing
3174 sub_svalues of clusters where the base region has a symbolic
3175 binding.
3176
3177 2022-04-28 David Malcolm <dmalcolm@redhat.com>
3178
3179 * diagnostic-manager.cc (epath_finder::process_worklist_item):
3180 Call dump_feasible_path when a path that reaches the the target
3181 enode is found.
3182 (epath_finder::dump_feasible_path): New.
3183 * engine.cc (feasibility_state::dump_to_pp): New.
3184 * exploded-graph.h (feasibility_state::dump_to_pp): New decl.
3185 * feasible-graph.cc (feasible_graph::dump_feasible_path): New.
3186 * feasible-graph.h (feasible_graph::dump_feasible_path): New
3187 decls.
3188 * program-point.cc (function_point::print): Fix missing trailing
3189 newlines.
3190 * program-point.h (program_point::print_source_line): Remove
3191 unimplemented decl.
3192
3193 2022-04-25 David Malcolm <dmalcolm@redhat.com>
3194
3195 PR analyzer/105365
3196 PR analyzer/105366
3197 * svalue.cc
3198 (cmp_cst): Rename to...
3199 (cmp_csts_same_type): ...this. Convert all recursive calls to
3200 calls to...
3201 (cmp_csts_and_types): ....this new function.
3202 (svalue::cmp_ptr): Update for renaming of cmp_cst
3203
3204 2022-04-14 David Malcolm <dmalcolm@redhat.com>
3205
3206 PR analyzer/105264
3207 * region-model-reachability.cc (reachable_regions::handle_parm):
3208 Use maybe_get_deref_base_region rather than just region_svalue, to
3209 handle pointer arithmetic also.
3210 * svalue.cc (svalue::maybe_get_deref_base_region): New.
3211 * svalue.h (svalue::maybe_get_deref_base_region): New decl.
3212
3213 2022-04-14 David Malcolm <dmalcolm@redhat.com>
3214
3215 PR analyzer/105252
3216 * svalue.cc (cmp_cst): When comparing VECTOR_CSTs, compare the
3217 types of the encoded elements before calling cmp_cst on them.
3218
3219 2022-04-09 David Malcolm <dmalcolm@redhat.com>
3220
3221 PR analyzer/103892
3222 * region-model-manager.cc
3223 (region_model_manager::get_unknown_symbolic_region): New,
3224 extracted from...
3225 (region_model_manager::get_field_region): ...here.
3226 (region_model_manager::get_element_region): Use it here.
3227 (region_model_manager::get_offset_region): Likewise.
3228 (region_model_manager::get_sized_region): Likewise.
3229 (region_model_manager::get_cast_region): Likewise.
3230 (region_model_manager::get_bit_range): Likewise.
3231 * region-model.h
3232 (region_model_manager::get_unknown_symbolic_region): New decl.
3233 * region.cc (symbolic_region::symbolic_region): Handle sval_ptr
3234 having NULL type.
3235 (symbolic_region::dump_to_pp): Handle having NULL type.
3236
3237 2022-04-07 David Malcolm <dmalcolm@redhat.com>
3238
3239 PR analyzer/102208
3240 * store.cc (binding_map::remove_overlapping_bindings): Add
3241 "always_overlap" param, using it to generalize to the case where
3242 we want to remove all bindings. Update "uncertainty" logic to
3243 only record maybe-bound values for cases where there is a symbolic
3244 write involved.
3245 (binding_cluster::mark_region_as_unknown): Split param "reg" into
3246 "reg_to_bind" and "reg_for_overlap".
3247 (binding_cluster::maybe_get_compound_binding): Pass "false" to
3248 binding_map::remove_overlapping_bindings new "always_overlap" param.
3249 (binding_cluster::remove_overlapping_bindings): Determine
3250 "always_overlap" and pass it to
3251 binding_map::remove_overlapping_bindings.
3252 (store::set_value): Pass uncertainty to remove_overlapping_bindings
3253 call. Update for new param of
3254 binding_cluster::mark_region_as_unknown, passing both the base
3255 region of the iter_cluster, and the lhs_reg.
3256 (store::mark_region_as_unknown): Update for new param of
3257 binding_cluster::mark_region_as_unknown, passing "reg" for both.
3258 (store::remove_overlapping_bindings): Add param "uncertainty", and
3259 pass it on to call to
3260 binding_cluster::remove_overlapping_bindings.
3261 * store.h (binding_map::remove_overlapping_bindings): Add
3262 "always_overlap" param.
3263 (binding_cluster::mark_region_as_unknown): Split param "reg" into
3264 "reg_to_bind" and "reg_for_overlap".
3265 (store::remove_overlapping_bindings): Add param "uncertainty".
3266
3267 2022-03-29 David Malcolm <dmalcolm@redhat.com>
3268
3269 PR testsuite/105085
3270 * region-model-manager.cc (dump_untracked_region): Skip decls in
3271 the constant pool.
3272
3273 2022-03-29 David Malcolm <dmalcolm@redhat.com>
3274
3275 PR analyzer/105087
3276 * analyzer.h (class conjured_purge): New forward decl.
3277 * region-model-asm.cc (region_model::on_asm_stmt): Add
3278 conjured_purge param to calls binding_cluster::on_asm and
3279 region_model_manager::get_or_create_conjured_svalue.
3280 * region-model-impl-calls.cc
3281 (call_details::get_or_create_conjured_svalue): Likewise for call
3282 to region_model_manager::get_or_create_conjured_svalue.
3283 (region_model::impl_call_fgets): Remove call to
3284 region_model::purge_state_involving, as this is now done
3285 implicitly by call_details::get_or_create_conjured_svalue.
3286 (region_model::impl_call_fread): Likewise.
3287 (region_model::impl_call_strchr): Pass conjured_purge param to
3288 call to region_model_manager::get_or_create_conjured_svalue.
3289 * region-model-manager.cc (conjured_purge::purge): New.
3290 (region_model_manager::get_or_create_conjured_svalue): Add
3291 param "p". Use it to purge state when reusing an existing
3292 conjured_svalue.
3293 * region-model.cc (region_model::on_call_pre): Replace call to
3294 region_model::purge_state_involving with passing conjured_purge
3295 to region_model_manager::get_or_create_conjured_svalue.
3296 (region_model::handle_unrecognized_call): Pass conjured_purge to
3297 store::on_unknown_fncall.
3298 * region-model.h
3299 (region_model_manager::get_or_create_conjured_svalue): Add param
3300 "p".
3301 * store.cc (binding_cluster::on_unknown_fncall): Likewise. Pass
3302 it on to region_model_manager::get_or_create_conjured_svalue.
3303 (binding_cluster::on_asm): Likewise.
3304 (store::on_unknown_fncall): Add param "p" and pass it on to
3305 binding_cluster::on_unknown_fncall.
3306 * store.h (binding_cluster::on_unknown_fncall): Add param p.
3307 (binding_cluster::on_asm): Likewise.
3308 (store::on_unknown_fncall): Likewise.
3309 * svalue.h (class conjured_purge): New.
3310
3311 2022-03-29 David Malcolm <dmalcolm@redhat.com>
3312
3313 PR analyzer/105074
3314 * region.cc (ipa_ref_requires_tracking): Drop "context_fndecl",
3315 instead using the ref->referring to get the cgraph node of the
3316 caller.
3317 (symnode_requires_tracking_p): Likewise.
3318
3319 2022-03-26 David Malcolm <dmalcolm@redhat.com>
3320
3321 PR analyzer/105057
3322 * store.cc (binding_cluster::make_unknown_relative_to): Reject
3323 attempts to create a cluster for untracked base regions.
3324 (store::set_value): Likewise.
3325 (store::fill_region): Likewise.
3326 (store::mark_region_as_unknown): Likewise.
3327
3328 2022-03-25 David Malcolm <dmalcolm@redhat.com>
3329
3330 PR analyzer/104954
3331 * analyzer.opt (-fdump-analyzer-untracked): New option.
3332 * engine.cc (impl_run_checkers): Handle it.
3333 * region-model-asm.cc (region_model::on_asm_stmt): Don't attempt
3334 to clobber regions with !tracked_p ().
3335 * region-model-manager.cc (dump_untracked_region): New.
3336 (region_model_manager::dump_untracked_regions): New.
3337 (frame_region::dump_untracked_regions): New.
3338 * region-model.h (region_model_manager::dump_untracked_regions):
3339 New decl.
3340 * region.cc (ipa_ref_requires_tracking): New.
3341 (symnode_requires_tracking_p): New.
3342 (decl_region::calc_tracked_p): New.
3343 * region.h (region::tracked_p): New vfunc.
3344 (frame_region::dump_untracked_regions): New decl.
3345 (class decl_region): Note that this is also used fo SSA names.
3346 (decl_region::decl_region): Initialize m_tracked.
3347 (decl_region::tracked_p): New.
3348 (decl_region::calc_tracked_p): New decl.
3349 (decl_region::m_tracked): New.
3350 * store.cc (store::get_or_create_cluster): Assert that we
3351 don't try to create clusters for base regions that aren't
3352 trackable.
3353 (store::mark_as_escaped): Don't mark base regions that we're not
3354 tracking.
3355
3356 2022-03-23 David Malcolm <dmalcolm@redhat.com>
3357
3358 PR analyzer/104979
3359 * engine.cc (impl_run_checkers): Create the engine after the
3360 supergraph, and pass the supergraph to the engine.
3361 * region-model.cc (region_model::get_lvalue_1): Pass ctxt to
3362 frame_region::get_region_for_local.
3363 (region_model::update_for_return_gcall): Pass the lvalue for the
3364 result to pop_frame as a tree, rather than as a region.
3365 (region_model::pop_frame): Update for above change, determining
3366 the destination region after the frame is popped and thus with
3367 respect to the caller frame rather than the called frame.
3368 Likewise, set the value of the region to the return value after
3369 the frame is popped.
3370 (engine::engine): Add supergraph pointer.
3371 (selftest::test_stack_frames): Set the DECL_CONTECT of PARM_DECLs.
3372 (selftest::test_get_representative_path_var): Likewise.
3373 (selftest::test_state_merging): Likewise.
3374 * region-model.h (region_model::pop_frame): Convert first param
3375 from a const region * to a tree.
3376 (engine::engine): Add param "sg".
3377 (engine::m_sg): New field.
3378 * region.cc: Include "analyzer/sm.h" and
3379 "analyzer/program-state.h".
3380 (frame_region::get_region_for_local): Add "ctxt" param.
3381 Add assertions that VAR_DECLs are locals, and that expr is for the
3382 correct function.
3383 * region.h (frame_region::get_region_for_local): Add "ctxt" param.
3384
3385 2022-03-23 David Malcolm <dmalcolm@redhat.com>
3386
3387 PR analyzer/105017
3388 * sm-taint.cc (taint_diagnostic::subclass_equal_p): Check
3389 m_has_bounds as well as m_arg.
3390 (tainted_allocation_size::subclass_equal_p): Chain up to base
3391 class implementation. Also check m_mem_space.
3392 (tainted_allocation_size::emit): Add note showing stack-based vs
3393 heap-based allocations.
3394
3395 2022-03-23 David Malcolm <dmalcolm@redhat.com>
3396
3397 PR analyzer/104997
3398 * diagnostic-manager.cc (diagnostic_manager::add_diagnostic):
3399 Convert return type from "void" to "bool", reporting success vs
3400 failure to caller, for both overloads.
3401 * diagnostic-manager.h (diagnostic_manager::add_diagnostic):
3402 Likewise.
3403 * engine.cc (impl_region_model_context::warn): Propagate return
3404 value from diagnostic_manager::add_diagnostic.
3405
3406 2022-03-18 David Malcolm <dmalcolm@redhat.com>
3407
3408 PR analyzer/104943
3409 PR analyzer/104954
3410 PR analyzer/103533
3411 * analyzer.h (class state_purge_per_decl): New forward decl.
3412 * engine.cc (impl_run_checkers): Pass region_model_manager to
3413 state_purge_map ctor.
3414 * program-point.cc (function_point::final_stmt_p): New.
3415 (function_point::get_next): New.
3416 * program-point.h (function_point::final_stmt_p): New decl.
3417 (function_point::get_next): New decl.
3418 * program-state.cc (program_state::prune_for_point): Generalize to
3419 purge local decls as well as SSA names.
3420 (program_state::can_purge_base_region_p): New.
3421 * program-state.h (program_state::can_purge_base_region_p): New
3422 decl.
3423 * region-model.cc (struct append_ssa_names_cb_data): Rename to...
3424 (struct append_regions_cb_data): ...this.
3425 (region_model::get_ssa_name_regions_for_current_frame): Rename
3426 to...
3427 (region_model::get_regions_for_current_frame): ...this, updating
3428 for other renamings.
3429 (region_model::append_ssa_names_cb): Rename to...
3430 (region_model::append_regions_cb): ...this, and drop the requirement
3431 that the subregion be a SSA name.
3432 * region-model.h (struct append_ssa_names_cb_data): Rename decl
3433 to...
3434 (struct append_regions_cb_data): ...this.
3435 (region_model::get_ssa_name_regions_for_current_frame): Rename
3436 decl to...
3437 (region_model::get_regions_for_current_frame): ...this.
3438 (region_model::append_ssa_names_cb): Rename decl to...
3439 (region_model::append_regions_cb): ...this.
3440 * state-purge.cc: Include "tristate.h", "selftest.h",
3441 "analyzer/store.h", "analyzer/region-model.h", and
3442 "gimple-walk.h".
3443 (get_candidate_for_purging): New.
3444 (class gimple_op_visitor): New.
3445 (my_load_cb): New.
3446 (my_store_cb): New.
3447 (my_addr_cb): New.
3448 (state_purge_map::state_purge_map): Add "mgr" param. Update for
3449 renamings. Find uses of local variables.
3450 (state_purge_map::~state_purge_map): Update for renaming of m_map
3451 to m_ssa_map. Clean up m_decl_map.
3452 (state_purge_map::get_or_create_data_for_decl): New.
3453 (state_purge_per_ssa_name::state_purge_per_ssa_name): Update for
3454 inheriting from state_purge_per_tree.
3455 (state_purge_per_ssa_name::add_to_worklist): Likewise.
3456 (state_purge_per_decl::state_purge_per_decl): New.
3457 (state_purge_per_decl::add_needed_at): New.
3458 (state_purge_per_decl::add_pointed_to_at): New.
3459 (state_purge_per_decl::process_worklists): New.
3460 (state_purge_per_decl::add_to_worklist): New.
3461 (same_binding_p): New.
3462 (fully_overwrites_p): New.
3463 (state_purge_per_decl::process_point_backwards): New.
3464 (state_purge_per_decl::process_point_forwards): New.
3465 (state_purge_per_decl::needed_at_point_p): New.
3466 (state_purge_annotator::print_needed): Generalize to print local
3467 decls as well as SSA names.
3468 * state-purge.h (class state_purge_map): Update leading comment.
3469 (state_purge_map::map_t): Rename to...
3470 (state_purge_map::ssa_map_t): ...this.
3471 (state_purge_map::iterator): Rename to...
3472 (state_purge_map::ssa_iterator): ...this.
3473 (state_purge_map::decl_map_t): New typedef.
3474 (state_purge_map::decl_iterator): New typedef.
3475 (state_purge_map::state_purge_map): Add "mgr" param.
3476 (state_purge_map::get_data_for_ssa_name): Update for renaming.
3477 (state_purge_map::get_any_data_for_decl): New.
3478 (state_purge_map::get_or_create_data_for_decl): New decl.
3479 (state_purge_map::begin): Rename to...
3480 (state_purge_map::begin_ssas): ...this.
3481 (state_purge_map::end): Rename to...
3482 (state_purge_map::end_ssa): ...this.
3483 (state_purge_map::begin_decls): New.
3484 (state_purge_map::end_decls): New.
3485 (state_purge_map::m_map): Rename to...
3486 (state_purge_map::m_ssa_map): ...this.
3487 (state_purge_map::m_decl_map): New field.
3488 (class state_purge_per_tree): New class.
3489 (class state_purge_per_ssa_name): Inherit from state_purge_per_tree.
3490 (state_purge_per_ssa_name::get_function): Move to base class.
3491 (state_purge_per_ssa_name::point_set_t): Likewise.
3492 (state_purge_per_ssa_name::m_fun): Likewise.
3493 (class state_purge_per_decl): New.
3494
3495 2022-03-17 David Malcolm <dmalcolm@redhat.com>
3496
3497 * state-purge.cc (state_purge_annotator::add_node_annotations):
3498 Avoid duplicate before-supernode annotations when returning from
3499 an interprocedural call. Show after-supernode annotations.
3500
3501 2022-03-17 David Malcolm <dmalcolm@redhat.com>
3502
3503 * program-point.cc (program_point::get_next): Fix missing
3504 increment of index.
3505
3506 2022-03-16 David Malcolm <dmalcolm@redhat.com>
3507
3508 PR analyzer/104955
3509 * diagnostic-manager.cc (get_emission_location): New.
3510 (diagnostic_manager::diagnostic_manager): Initialize
3511 m_num_disabled_diagnostics.
3512 (diagnostic_manager::add_diagnostic): Reject diagnostics that
3513 will eventually be rejected due to being disabled.
3514 (diagnostic_manager::emit_saved_diagnostics): Log the number
3515 of disabled diagnostics.
3516 (diagnostic_manager::emit_saved_diagnostic): Split out logic for
3517 determining emission location to get_emission_location.
3518 * diagnostic-manager.h
3519 (diagnostic_manager::m_num_disabled_diagnostics): New field.
3520 * engine.cc (stale_jmp_buf::get_controlling_option): New.
3521 (stale_jmp_buf::emit): Use it.
3522 * pending-diagnostic.h
3523 (pending_diagnostic::get_controlling_option): New vfunc.
3524 * region-model.cc
3525 (poisoned_value_diagnostic::get_controlling_option): New.
3526 (poisoned_value_diagnostic::emit): Use it.
3527 (shift_count_negative_diagnostic::get_controlling_option): New.
3528 (shift_count_negative_diagnostic::emit): Use it.
3529 (shift_count_overflow_diagnostic::get_controlling_option): New.
3530 (shift_count_overflow_diagnostic::emit): Use it.
3531 (dump_path_diagnostic::get_controlling_option): New.
3532 (dump_path_diagnostic::emit): Use it.
3533 (write_to_const_diagnostic::get_controlling_option): New.
3534 (write_to_const_diagnostic::emit): Use it.
3535 (write_to_string_literal_diagnostic::get_controlling_option): New.
3536 (write_to_string_literal_diagnostic::emit): Use it.
3537 * sm-file.cc (double_fclose::get_controlling_option): New.
3538 (double_fclose::emit): Use it.
3539 (file_leak::get_controlling_option): New.
3540 (file_leak::emit): Use it.
3541 * sm-malloc.cc (mismatching_deallocation::get_controlling_option):
3542 New.
3543 (mismatching_deallocation::emit): Use it.
3544 (double_free::get_controlling_option): New.
3545 (double_free::emit): Use it.
3546 (possible_null_deref::get_controlling_option): New.
3547 (possible_null_deref::emit): Use it.
3548 (possible_null_arg::get_controlling_option): New.
3549 (possible_null_arg::emit): Use it.
3550 (null_deref::get_controlling_option): New.
3551 (null_deref::emit): Use it.
3552 (null_arg::get_controlling_option): New.
3553 (null_arg::emit): Use it.
3554 (use_after_free::get_controlling_option): New.
3555 (use_after_free::emit): Use it.
3556 (malloc_leak::get_controlling_option): New.
3557 (malloc_leak::emit): Use it.
3558 (free_of_non_heap::get_controlling_option): New.
3559 (free_of_non_heap::emit): Use it.
3560 * sm-pattern-test.cc (pattern_match::get_controlling_option): New.
3561 (pattern_match::emit): Use it.
3562 * sm-sensitive.cc
3563 (exposure_through_output_file::get_controlling_option): New.
3564 (exposure_through_output_file::emit): Use it.
3565 * sm-signal.cc (signal_unsafe_call::get_controlling_option): New.
3566 (signal_unsafe_call::emit): Use it.
3567 * sm-taint.cc (tainted_array_index::get_controlling_option): New.
3568 (tainted_array_index::emit): Use it.
3569 (tainted_offset::get_controlling_option): New.
3570 (tainted_offset::emit): Use it.
3571 (tainted_size::get_controlling_option): New.
3572 (tainted_size::emit): Use it.
3573 (tainted_divisor::get_controlling_option): New.
3574 (tainted_divisor::emit): Use it.
3575 (tainted_allocation_size::get_controlling_option): New.
3576 (tainted_allocation_size::emit): Use it.
3577
3578 2022-03-15 David Malcolm <dmalcolm@redhat.com>
3579
3580 * store.cc (store::store): Presize m_cluster_map.
3581
3582 2022-03-10 David Malcolm <dmalcolm@redhat.com>
3583
3584 PR analyzer/104863
3585 * constraint-manager.cc (constraint_manager::add_constraint):
3586 Refresh the EC IDs when adding constraints implied by offsets.
3587
3588 2022-03-10 David Malcolm <dmalcolm@redhat.com>
3589
3590 PR analyzer/104793
3591 * analyzer.h (class pending_note): New forward decl.
3592 * diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
3593 Initialize m_notes.
3594 (saved_diagnostic::operator==): Compare m_notes.
3595 (saved_diagnostic::add_note): New.
3596 (saved_diagnostic::emit_any_notes): New.
3597 (diagnostic_manager::add_note): New.
3598 (diagnostic_manager::emit_saved_diagnostic): Call emit_any_notes
3599 after emitting the warning.
3600 * diagnostic-manager.h (saved_diagnostic::add_note): New decl.
3601 (saved_diagnostic::emit_any_notes): New decl.
3602 (saved_diagnostic::m_notes): New field.
3603 (diagnostic_manager::add_note): New decl.
3604 * engine.cc (impl_region_model_context::add_note): New.
3605 * exploded-graph.h (impl_region_model_context::add_note): New
3606 decl.
3607 * pending-diagnostic.h (class pending_note): New.
3608 (class pending_note_subclass): New template.
3609 * region-model.cc (class reason_attr_access): New.
3610 (check_external_function_for_access_attr): Add class
3611 annotating_ctxt and use it when checking region.
3612 (noop_region_model_context::add_note): New.
3613 * region-model.h (region_model_context::add_note): New vfunc.
3614 (noop_region_model_context::add_note): New decl.
3615 (class region_model_context_decorator): New.
3616 (class note_adding_context): New.
3617
3618 2022-03-10 David Malcolm <dmalcolm@redhat.com>
3619
3620 PR analyzer/104793
3621 * region-model.cc
3622 (region_model::check_external_function_for_access_attr): New.
3623 (region_model::handle_unrecognized_call): Call it.
3624 * region-model.h
3625 (region_model::check_external_function_for_access_attr): New decl.
3626 (region_model::handle_unrecognized_call): New decl.
3627
3628 2022-03-10 David Malcolm <dmalcolm@redhat.com>
3629
3630 * sm-taint.cc (taint_state_machine::check_for_tainted_size_arg):
3631 Avoid generating duplicate saved_diagnostics by only handling the
3632 rdwr_map entry for the ptrarg, not the duplicate entry for the
3633 sizarg.
3634
3635 2022-03-07 David Malcolm <dmalcolm@redhat.com>
3636
3637 PR analyzer/101983
3638 * engine.cc (returning_from_function_p): New.
3639 (impl_region_model_context::on_state_leak): Use it when rejecting
3640 leaks at the return from "main".
3641
3642 2022-03-07 Jakub Jelinek <jakub@redhat.com>
3643
3644 * store.cc: Fix up duplicated word issue in a comment.
3645 * analyzer.cc: Likewise.
3646 * engine.cc: Likewise.
3647 * sm-taint.cc: Likewise.
3648
3649 2022-03-04 David Malcolm <dmalcolm@redhat.com>
3650
3651 PR analyzer/103521
3652 * analyzer.opt (-param=analyzer-max-svalue-depth=): Reduce from 13
3653 to 12.
3654
3655 2022-02-23 David Malcolm <dmalcolm@redhat.com>
3656
3657 PR analyzer/104434
3658 * analyzer.h (class const_fn_result_svalue): New decl.
3659 * region-model-impl-calls.cc (call_details::get_manager): New.
3660 * region-model-manager.cc
3661 (region_model_manager::get_or_create_const_fn_result_svalue): New.
3662 (region_model_manager::log_stats): Log
3663 m_const_fn_result_values_map.
3664 * region-model.cc (const_fn_p): New.
3665 (maybe_get_const_fn_result): New.
3666 (region_model::on_call_pre): Handle fndecls with
3667 __attribute__((const)) by calling the above rather than making
3668 a conjured_svalue.
3669 * region-model.h (visitor::visit_const_fn_result_svalue): New.
3670 (region_model_manager::get_or_create_const_fn_result_svalue): New
3671 decl.
3672 (region_model_manager::const_fn_result_values_map_t): New typedef.
3673 (region_model_manager::m_const_fn_result_values_map): New field.
3674 (call_details::get_manager): New decl.
3675 * svalue.cc (svalue::cmp_ptr): Handle SK_CONST_FN_RESULT.
3676 (const_fn_result_svalue::dump_to_pp): New.
3677 (const_fn_result_svalue::dump_input): New.
3678 (const_fn_result_svalue::accept): New.
3679 * svalue.h (enum svalue_kind): Add SK_CONST_FN_RESULT.
3680 (svalue::dyn_cast_const_fn_result_svalue): New.
3681 (class const_fn_result_svalue): New.
3682 (is_a_helper <const const_fn_result_svalue *>::test): New.
3683 (template <> struct default_hash_traits<const_fn_result_svalue::key_t>):
3684 New.
3685
3686 2022-02-17 David Malcolm <dmalcolm@redhat.com>
3687
3688 PR analyzer/104576
3689 * region-model.cc: Include "calls.h".
3690 (region_model::on_call_pre): Use flags_from_decl_or_type to
3691 generalize check for DECL_PURE_P to also check for ECF_CONST.
3692
3693 2022-02-16 David Malcolm <dmalcolm@redhat.com>
3694
3695 PR analyzer/104560
3696 * diagnostic-manager.cc (diagnostic_manager::build_emission_path):
3697 Add region creation events for globals of interest.
3698 (null_assignment_sm_context::get_old_program_state): New.
3699 (diagnostic_manager::add_events_for_eedge): Move check for
3700 changing dynamic extents from PK_BEFORE_STMT case to after the
3701 switch on the dst_point's kind so that we can emit them for the
3702 final stmt in a basic block.
3703 * engine.cc (impl_sm_context::get_old_program_state): New.
3704 * sm-malloc.cc (malloc_state_machine::get_default_state): Rewrite
3705 detection of m_non_heap to use get_memory_space.
3706 (free_of_non_heap::free_of_non_heap): Add freed_reg param.
3707 (free_of_non_heap::subclass_equal_p): Update for changes to
3708 fields.
3709 (free_of_non_heap::emit): Drop m_kind in favor of
3710 get_memory_space.
3711 (free_of_non_heap::describe_state_change): Remove logic for
3712 detecting alloca.
3713 (free_of_non_heap::mark_interesting_stuff): Add region-creation of
3714 m_freed_reg.
3715 (free_of_non_heap::get_memory_space): New.
3716 (free_of_non_heap::kind): Drop enum.
3717 (free_of_non_heap::m_freed_reg): New field.
3718 (free_of_non_heap::m_kind): Drop field.
3719 (malloc_state_machine::on_stmt): Drop transition to m_non_heap.
3720 (malloc_state_machine::handle_free_of_non_heap): New function,
3721 split out from on_deallocator_call and on_realloc_call, adding
3722 detection of the freed region.
3723 (malloc_state_machine::on_deallocator_call): Use it.
3724 (malloc_state_machine::on_realloc_call): Likewise.
3725 * sm.h (sm_context::get_old_program_state): New vfunc.
3726
3727 2022-02-15 David Malcolm <dmalcolm@redhat.com>
3728
3729 PR analyzer/104524
3730 * region-model-manager.cc
3731 (region_model_manager::maybe_fold_sub_svalue): Only call
3732 get_or_create_cast if type is non-NULL.
3733
3734 2022-02-15 David Malcolm <dmalcolm@redhat.com>
3735
3736 PR analyzer/102692
3737 * exploded-graph.h (impl_region_model_context::get_stmt): New.
3738 * region-model.cc: Include "gimple-ssa.h", "tree-phinodes.h",
3739 "tree-ssa-operands.h", and "ssa-iterators.h".
3740 (within_short_circuited_stmt_p): New.
3741 (region_model::check_for_poison): Don't warn about uninit values
3742 if within_short_circuited_stmt_p.
3743 * region-model.h (region_model_context::get_stmt): New vfunc.
3744 (noop_region_model_context::get_stmt): New.
3745
3746 2022-02-11 David Malcolm <dmalcolm@redhat.com>
3747
3748 PR analyzer/104274
3749 * region-model.cc (region_model::check_for_poison): Ignore
3750 uninitialized uses of empty types.
3751
3752 2022-02-10 David Malcolm <dmalcolm@redhat.com>
3753
3754 PR analyzer/98797
3755 * region-model-manager.cc
3756 (region_model_manager::maybe_fold_sub_svalue): Generalize getting
3757 individual chars of a STRING_CST from element_region to any
3758 subregion which is a concrete access of a single byte from its
3759 parent region.
3760 * region.cc (region::get_relative_concrete_byte_range): New.
3761 * region.h (region::get_relative_concrete_byte_range): New decl.
3762
3763 2022-02-09 David Malcolm <dmalcolm@redhat.com>
3764
3765 PR analyzer/104452
3766 * region-model.cc (selftest::test_bit_range_regions): New.
3767 (selftest::analyzer_region_model_cc_tests): Call it.
3768 * region.h (bit_range_region::key_t::hash): Fix hashing of m_bits
3769 to avoid using uninitialized data.
3770
3771 2022-02-07 David Malcolm <dmalcolm@redhat.com>
3772
3773 PR analyzer/104417
3774 * sm-taint.cc (tainted_allocation_size::tainted_allocation_size):
3775 Remove overzealous assertion.
3776 (tainted_allocation_size::emit): Likewise.
3777 (region_model::check_dynamic_size_for_taint): Likewise.
3778
3779 2022-02-07 David Malcolm <dmalcolm@redhat.com>
3780
3781 PR analyzer/103872
3782 * region-model-impl-calls.cc (region_model::impl_call_memcpy):
3783 Reimplement in terms of a get_store_value followed by a set_value.
3784
3785 2022-02-03 David Malcolm <dmalcolm@redhat.com>
3786
3787 PR analyzer/104369
3788 * engine.cc (exploded_graph::process_node): Use the node for any
3789 diagnostics, avoiding ICE if a bifurcation update adds a
3790 saved_diagnostic, such as for a tainted realloc size.
3791 * region-model-impl-calls.cc
3792 (region_model::impl_call_realloc::success_no_move::update_model):
3793 Require the old pointer to be non-NULL to be able successfully
3794 grow in place. Use model->deref_rvalue rather than maybe_get_region
3795 to support the old pointer being symbolic.
3796 (region_model::impl_call_realloc::success_with_move::update_model):
3797 Likewise. Add a constraint that the new pointer != the old pointer.
3798 Use a sized_region when setting the value of the new region.
3799 Handle the case where we don't know the dynamic size of the old
3800 region by marking the new region as unknown.
3801 * sm-taint.cc (tainted_allocation_size::tainted_allocation_size):
3802 Update assertion to also allow for MEMSPACE_UNKNOWN.
3803 (tainted_allocation_size::emit): Likewise.
3804 (region_model::check_dynamic_size_for_taint): Likewise.
3805
3806 2022-02-03 David Malcolm <dmalcolm@redhat.com>
3807
3808 * region-model-impl-calls.cc (region_model::impl_call_calloc): Use
3809 a sized_region when calling zero_fill_region.
3810
3811 2022-02-02 David Malcolm <dmalcolm@redhat.com>
3812
3813 * region-model.cc (region_model::on_return): Replace usage of
3814 copy_region with get_rvalue/set_value pair.
3815 (region_model::pop_frame): Likewise.
3816 (selftest::test_compound_assignment): Likewise.
3817 * region-model.h (region_model::copy_region): Delete decl.
3818 * region.cc (region_model::copy_region): Delete.
3819
3820 2022-02-02 David Malcolm <dmalcolm@redhat.com>
3821
3822 * region.cc (region::calc_offset): Consolidate effectively
3823 identical cases.
3824
3825 2022-02-02 David Malcolm <dmalcolm@redhat.com>
3826
3827 * analyzer.h (class bit_range_region): New forward decl.
3828 * region-model-manager.cc (region_model_manager::get_bit_range):
3829 New.
3830 (region_model_manager::log_stats): Handle m_bit_range_regions.
3831 * region-model.cc (region_model::get_lvalue_1): Handle
3832 BIT_FIELD_REF.
3833 * region-model.h (region_model_manager::get_bit_range): New decl.
3834 (region_model_manager::m_bit_range_regions): New field.
3835 * region.cc (region::get_base_region): Handle RK_BIT_RANGE.
3836 (region::base_region_p): Likewise.
3837 (region::calc_offset): Likewise.
3838 (bit_range_region::dump_to_pp): New.
3839 (bit_range_region::get_byte_size): New.
3840 (bit_range_region::get_bit_size): New.
3841 (bit_range_region::get_byte_size_sval): New.
3842 (bit_range_region::get_relative_concrete_offset): New.
3843 * region.h (enum region_kind): Add RK_BIT_RANGE.
3844 (region::dyn_cast_bit_range_region): New vfunc.
3845 (class bit_range_region): New.
3846 (is_a_helper <const bit_range_region *>::test): New.
3847 (default_hash_traits<bit_range_region::key_t>): New.
3848
3849 2022-02-02 David Malcolm <dmalcolm@redhat.com>
3850
3851 PR analyzer/104270
3852 * region-model.cc (region_model::on_call_pre): Handle
3853 IFN_DEFERRED_INIT.
3854
3855 2022-01-27 David Malcolm <dmalcolm@redhat.com>
3856
3857 * checker-path.cc (event_kind_to_string): Handle
3858 EK_REGION_CREATION.
3859 (region_creation_event::region_creation_event): New.
3860 (region_creation_event::get_desc): New.
3861 (checker_path::add_region_creation_event): New.
3862 * checker-path.h (enum event_kind): Add EK_REGION_CREATION.
3863 (class region_creation_event): New subclass.
3864 (checker_path::add_region_creation_event): New decl.
3865 * diagnostic-manager.cc
3866 (diagnostic_manager::emit_saved_diagnostic): Pass NULL for new
3867 param to add_events_for_eedge when handling trailing eedge.
3868 (diagnostic_manager::build_emission_path): Create an interesting_t
3869 instance, allow the pending diagnostic to populate it, and pass it
3870 to the calls to add_events_for_eedge.
3871 (diagnostic_manager::add_events_for_eedge): Add "interest" param.
3872 Use it to add region_creation_events for on-stack regions created
3873 within at function entry, and when pertinent dynamically-sized
3874 regions are created.
3875 (diagnostic_manager::prune_for_sm_diagnostic): Add case for
3876 EK_REGION_CREATION.
3877 * diagnostic-manager.h (diagnostic_manager::add_events_for_eedge):
3878 Add "interest" param.
3879 * pending-diagnostic.cc: Include "selftest.h", "tristate.h",
3880 "analyzer/call-string.h", "analyzer/program-point.h",
3881 "analyzer/store.h", and "analyzer/region-model.h".
3882 (interesting_t::add_region_creation): New.
3883 (interesting_t::dump_to_pp): New.
3884 * pending-diagnostic.h (struct interesting_t): New.
3885 (pending_diagnostic::mark_interesting_stuff): New vfunc.
3886 * region-model.cc
3887 (poisoned_value_diagnostic::poisoned_value_diagnostic): Add
3888 (poisoned_value_diagnostic::operator==): Compare m_pkind and
3889 m_src_region fields.
3890 (poisoned_value_diagnostic::mark_interesting_stuff): New.
3891 (poisoned_value_diagnostic::m_src_region): New.
3892 (region_model::check_for_poison): Call
3893 get_region_for_poisoned_expr for uninit values and pass the resul
3894 to the diagnostic.
3895 (region_model::get_region_for_poisoned_expr): New.
3896 (region_model::deref_rvalue): Pass NULL for
3897 poisoned_value_diagnostic's src_region.
3898 * region-model.h (region_model::get_region_for_poisoned_expr): New
3899 decl.
3900 * region.h (frame_region::get_fndecl): New.
3901
3902 2022-01-27 Martin Liska <mliska@suse.cz>
3903
3904 PR analyzer/104247
3905 * constraint-manager.cc (bounded_ranges_manager::log_stats):
3906 Cast to long for format purpose.
3907 * region-model-manager.cc (log_uniq_map): Likewise.
3908
3909 2022-01-26 David Malcolm <dmalcolm@redhat.com>
3910
3911 PR analyzer/104224
3912 * region-model.cc (region_model::check_call_args): New.
3913 (region_model::on_call_pre): Call it when ignoring stdio builtins.
3914 * region-model.h (region_model::check_call_args): New decl
3915
3916 2022-01-26 David Malcolm <dmalcolm@redhat.com>
3917
3918 PR analyzer/94362
3919 * constraint-manager.cc (range::add_bound): Fix tests for
3920 discarding redundant constraints. Perform test for rejecting
3921 unsatisfiable constraints earlier so that they don't update
3922 the object on failure.
3923 (selftest::test_range): New.
3924 (selftest::test_constant_comparisons): Add test coverage for
3925 existing constraints becoming narrower until they are
3926 unsatisfiable.
3927 (selftest::run_constraint_manager_tests): Call test_range.
3928
3929 2022-01-22 David Malcolm <dmalcolm@redhat.com>
3930
3931 PR analyzer/104159
3932 * region-model-manager.cc
3933 (region_model_manager::get_or_create_cast): Bail out if the types
3934 are the same. Don't attempt to handle casts involving vector
3935 types.
3936
3937 2022-01-20 David Malcolm <dmalcolm@redhat.com>
3938
3939 PR analyzer/94362
3940 * constraint-manager.cc (bound::ensure_closed): Convert param to
3941 enum bound_kind.
3942 (range::constrained_to_single_element): Likewise.
3943 (range::add_bound): New.
3944 (constraint_manager::add_constraint): Handle SVAL + OFFSET
3945 compared to a constant.
3946 (constraint_manager::get_ec_bounds): Rewrite in terms of
3947 range::add_bound.
3948 (constraint_manager::eval_condition): Reject if range::add_bound
3949 fails.
3950 (selftest::test_constant_comparisons): Add test coverage for
3951 various impossible combinations of integer comparisons.
3952 * constraint-manager.h (enum bound_kind): New.
3953 (struct bound): Likewise.
3954 (bound::ensure_closed): Convert to param to enum bound_kind.
3955 (struct range): Convert to...
3956 (class range): ...this, making fields private.
3957 (range::add_bound): New decls.
3958 * region-model.cc (region_model::add_constraint): Fail if
3959 constraint_manager::add_constraint fails.
3960
3961 2022-01-18 David Malcolm <dmalcolm@redhat.com>
3962
3963 PR analyzer/104089
3964 * region-model-manager.cc
3965 (region_model_manager::get_or_create_constant_svalue): Assert that
3966 we have a CONSTANT_CLASS_P.
3967 (region_model_manager::maybe_fold_unaryop): Only fold a constant
3968 when fold_unary's result is a constant or a cast of a constant.
3969
3970 2022-01-18 David Malcolm <dmalcolm@redhat.com>
3971
3972 PR analyzer/104062
3973 * region-model-manager.cc
3974 (region_model_manager::maybe_fold_sub_svalue): Avoid casting to
3975 NULL type when folding access to repeated svalue.
3976
3977 2022-01-17 Martin Liska <mliska@suse.cz>
3978
3979 * analyzer.cc (is_special_named_call_p): Rename .c names to .cc.
3980 (is_named_call_p): Likewise.
3981 * region-model-asm.cc (deterministic_p): Likewise.
3982 * region.cc (field_region::get_relative_concrete_offset): Likewise.
3983 * sm-malloc.cc (method_p): Likewise.
3984 * supergraph.cc (superedge::dump_dot): Likewise.
3985
3986 2022-01-14 David Malcolm <dmalcolm@redhat.com>
3987
3988 * sm-taint.cc (taint_state_machine::combine_states): Handle combination
3989 of has_ub and has_lb.
3990
3991 2022-01-14 David Malcolm <dmalcolm@redhat.com>
3992
3993 PR analyzer/104029
3994 * sm-taint.cc (taint_state_machine::alt_get_inherited_state):
3995 Remove gcc_unreachable from default case for unary ops.
3996
3997 2022-01-14 David Malcolm <dmalcolm@redhat.com>
3998
3999 * engine.cc: Include "stringpool.h", "attribs.h", and
4000 "tree-dfa.h".
4001 (mark_params_as_tainted): New.
4002 (class tainted_args_function_custom_event): New.
4003 (class tainted_args_function_info): New.
4004 (exploded_graph::add_function_entry): Handle functions with
4005 "tainted_args" attribute.
4006 (class tainted_args_field_custom_event): New.
4007 (class tainted_args_callback_custom_event): New.
4008 (class tainted_args_call_info): New.
4009 (add_tainted_args_callback): New.
4010 (add_any_callbacks): New.
4011 (exploded_graph::build_initial_worklist): Likewise.
4012 (exploded_graph::build_initial_worklist): Find callbacks that are
4013 reachable from global initializers, calling add_any_callbacks on
4014 them.
4015
4016 2022-01-12 David Malcolm <dmalcolm@redhat.com>
4017
4018 PR analyzer/103940
4019 * engine.cc (impl_sm_context::impl_sm_context): Add
4020 "unknown_side_effects" param and use it to initialize
4021 new m_unknown_side_effects field.
4022 (impl_sm_context::unknown_side_effects_p): New.
4023 (impl_sm_context::m_unknown_side_effects): New.
4024 (exploded_node::on_stmt): Pass unknown_side_effects to sm_ctxt
4025 ctor.
4026 * sm-taint.cc: Include "stringpool.h" and "attribs.h".
4027 (tainted_size::tainted_size): Drop "dir" param.
4028 (tainted_size::get_kind): Drop "FINAL".
4029 (tainted_size::emit): Likewise.
4030 (tainted_size::m_dir): Drop unused field.
4031 (class tainted_access_attrib_size): New subclass.
4032 (taint_state_machine::on_stmt): Call check_for_tainted_size_arg on
4033 external functions with unknown side effects.
4034 (taint_state_machine::check_for_tainted_size_arg): New.
4035 (region_model::check_region_for_taint): Drop "dir" param from
4036 tainted_size ctor.
4037 * sm.h (sm_context::unknown_side_effects_p): New.
4038
4039 2022-01-11 David Malcolm <dmalcolm@redhat.com>
4040
4041 PR analyzer/102692
4042 * diagnostic-manager.cc
4043 (class auto_disable_complexity_checks): Rename to...
4044 (class auto_checking_feasibility): ...this, updating
4045 the calls accordingly.
4046 (epath_finder::explore_feasible_paths): Update for renaming.
4047 * region-model-manager.cc
4048 (region_model_manager::region_model_manager): Update for change from
4049 m_check_complexity to m_checking_feasibility.
4050 (region_model_manager::reject_if_too_complex): Likewise.
4051 (region_model_manager::get_or_create_unknown_svalue): Handle
4052 m_checking_feasibility.
4053 (region_model_manager::create_unique_svalue): New.
4054 (region_model_manager::maybe_fold_binop): Handle BIT_AND_EXPR and
4055 BIT_IOR_EXPRs on booleans where we know the result.
4056 * region-model.cc (test_binop_svalue_folding): Add test coverage
4057 for the above.
4058 * region-model.h (region_model_manager::create_unique_svalue): New
4059 decl.
4060 (region_model_manager::enable_complexity_check): Replace with...
4061 (region_model_manager::begin_checking_feasibility): ...this.
4062 (region_model_manager::disable_complexity_check): Replace with...
4063 (region_model_manager::end_checking_feasibility): ...this.
4064 (region_model_manager::m_check_complexity): Replace with...
4065 (region_model_manager::m_checking_feasibility): ...this.
4066 (region_model_manager::m_managed_dynamic_svalues): New field.
4067
4068 2022-01-08 David Malcolm <dmalcolm@redhat.com>
4069
4070 * engine.cc (impl_run_checkers): Pass logger to engine ctor.
4071 * region-model-manager.cc
4072 (region_model_manager::region_model_manager): Add logger param and
4073 use it to initialize m_logger.
4074 * region-model.cc (engine::engine): New.
4075 * region-model.h (region_model_manager::region_model_manager):
4076 Add logger param.
4077 (region_model_manager::get_logger): New.
4078 (region_model_manager::m_logger): New field.
4079 (engine::engine): New.
4080 * store.cc (store_manager::get_logger): New.
4081 (store::set_value): Log scope. Log when marking a cluster as
4082 unknown due to possible aliasing.
4083 * store.h (store_manager::get_logger): New decl.
4084
4085 2022-01-08 David Malcolm <dmalcolm@redhat.com>
4086
4087 * region-model-impl-calls.cc (cmp_decls): New.
4088 (cmp_decls_ptr_ptr): New.
4089 (region_model::impl_call_analyzer_dump_escaped): New.
4090 * region-model.cc (region_model::on_stmt_pre): Handle
4091 __analyzer_dump_escaped.
4092 * region-model.h (region_model::impl_call_analyzer_dump_escaped):
4093 New decl.
4094 * store.h (binding_cluster::get_base_region): New accessor.
4095
4096 2022-01-08 David Malcolm <dmalcolm@redhat.com>
4097
4098 * region.cc (region::is_named_decl_p): New.
4099 * region.h (region::is_named_decl_p): New decl.
4100
4101 2022-01-06 David Malcolm <dmalcolm@redhat.com>
4102
4103 PR analyzer/103546
4104 * store.cc (store::eval_alias_1): Refactor handling of decl
4105 regions, adding a test for may_be_aliased, rejecting those for
4106 which it returns false.
4107
4108 2021-12-12 Jonathan Wakely <jwakely@redhat.com>
4109
4110 * engine.cc: Define INCLUDE_MEMORY instead of INCLUDE_UNIQUE_PTR.
4111
4112 2021-12-06 David Malcolm <dmalcolm@redhat.com>
4113
4114 PR analyzer/103533
4115 * constraint-manager.cc (equiv_class::contains_non_constant_p):
4116 New.
4117 (constraint_manager::canonicalize): Call it when determining
4118 redundant ECs.
4119 (selftest::test_purging): New selftest.
4120 (selftest::run_constraint_manager_tests): Likewise.
4121 * constraint-manager.h (equiv_class::contains_non_constant_p):
4122 New decl.
4123
4124 2021-12-01 David Malcolm <dmalcolm@redhat.com>
4125
4126 PR analyzer/102471
4127 * region-model-reachability.cc (reachable_regions::handle_parm):
4128 Treat all svalues within a compound parm has reachable, and those
4129 wrapped in a cast.
4130
4131 2021-11-29 David Malcolm <dmalcolm@redhat.com>
4132
4133 PR analyzer/103217
4134 * store.cc (binding_cluster::can_merge_p): For the "key is bound"
4135 vs "key is not bound" merger case, check that the bound svalue
4136 is mergeable before merging it to "unknown", rejecting the merger
4137 otherwise.
4138
4139 2021-11-19 David Malcolm <dmalcolm@redhat.com>
4140
4141 PR analyzer/103217
4142 * engine.cc (exploded_graph::get_or_create_node): Pass in
4143 m_ext_state to program_state::can_merge_with_p.
4144 (exploded_graph::process_worklist): Likewise.
4145 (exploded_graph::maybe_process_run_of_before_supernode_enodes):
4146 Likewise.
4147 (exploded_graph::process_node): Add missing call to detect_leaks
4148 when handling phi nodes.
4149 * program-state.cc (program_state::can_merge_with_p): Add
4150 "ext_state" param. Pass it and state ptrs to
4151 region_model::can_merge_with_p.
4152 (selftest::test_program_state_merging): Update for new ext_state
4153 param of program_state::can_merge_with_p.
4154 (selftest::test_program_state_merging_2): Likewise.
4155 * program-state.h (program_state::can_purge_p): Make const.
4156 (program_state::can_merge_with_p): Add "ext_state" param.
4157 * region-model.cc: Include "analyzer/program-state.h".
4158 (region_model::can_merge_with_p): Add params "ext_state",
4159 "state_a", and "state_b", use them when creating model_merger
4160 object.
4161 (model_merger::mergeable_svalue_p): New.
4162 * region-model.h (region_model::can_merge_with_p): Add params
4163 "ext_state", "state_a", and "state_b".
4164 (model_merger::model_merger) Likewise, initializing new fields.
4165 (model_merger::mergeable_svalue_p): New decl.
4166 (model_merger::m_ext_state): New field.
4167 (model_merger::m_state_a): New field.
4168 (model_merger::m_state_b): New field.
4169 * svalue.cc (svalue::can_merge_p): Call
4170 model_merger::mergeable_svalue_p on both states and reject the
4171 merger accordingly.
4172
4173 2021-11-17 David Malcolm <dmalcolm@redhat.com>
4174
4175 PR analyzer/102695
4176 * region-model-impl-calls.cc (region_model::impl_call_strchr): New.
4177 * region-model-manager.cc
4178 (region_model_manager::maybe_fold_unaryop): Simplify cast to
4179 pointer type of an existing pointer to a region.
4180 * region-model.cc (region_model::on_call_pre): Handle
4181 BUILT_IN_STRCHR and "strchr".
4182 (write_to_const_diagnostic::emit): Add auto_diagnostic_group. Add
4183 alternate wordings for functions and labels.
4184 (write_to_const_diagnostic::describe_final_event): Add alternate
4185 wordings for functions and labels.
4186 (region_model::check_for_writable_region): Handle RK_FUNCTION and
4187 RK_LABEL.
4188 * region-model.h (region_model::impl_call_strchr): New decl.
4189
4190 2021-11-16 David Malcolm <dmalcolm@redhat.com>
4191
4192 PR analyzer/102662
4193 * constraint-manager.cc (bounded_range::operator==): Require the
4194 types to be the same for equality.
4195
4196 2021-11-13 David Malcolm <dmalcolm@redhat.com>
4197
4198 * analyzer.opt (Wanalyzer-tainted-allocation-size): New.
4199 (Wanalyzer-tainted-divisor): New.
4200 (Wanalyzer-tainted-offset): New.
4201 (Wanalyzer-tainted-size): New.
4202 * engine.cc (impl_region_model_context::get_taint_map): New.
4203 * exploded-graph.h (impl_region_model_context::get_taint_map):
4204 New decl.
4205 * program-state.cc (sm_state_map::get_state): Call
4206 alt_get_inherited_state.
4207 (sm_state_map::impl_set_state): Modify states within
4208 compound svalues.
4209 (program_state::impl_call_analyzer_dump_state): Undo casts.
4210 (selftest::test_program_state_1): Update for new context param of
4211 create_region_for_heap_alloc.
4212 (selftest::test_program_state_merging): Likewise.
4213 * region-model-impl-calls.cc (region_model::impl_call_alloca):
4214 Likewise.
4215 (region_model::impl_call_calloc): Likewise.
4216 (region_model::impl_call_malloc): Likewise.
4217 (region_model::impl_call_operator_new): Likewise.
4218 (region_model::impl_call_realloc): Likewise.
4219 * region-model.cc (region_model::check_region_access): Call
4220 check_region_for_taint.
4221 (region_model::get_representative_path_var_1): Handle binops.
4222 (region_model::create_region_for_heap_alloc): Add "ctxt" param and
4223 pass it to set_dynamic_extents.
4224 (region_model::create_region_for_alloca): Likewise.
4225 (region_model::set_dynamic_extents): Add "ctxt" param and use it
4226 to call check_dynamic_size_for_taint.
4227 (selftest::test_state_merging): Update for new context param of
4228 create_region_for_heap_alloc.
4229 (selftest::test_malloc_constraints): Likewise.
4230 (selftest::test_malloc): Likewise.
4231 (selftest::test_alloca): Likewise for create_region_for_alloca.
4232 * region-model.h (region_model::create_region_for_heap_alloc): Add
4233 "ctxt" param.
4234 (region_model::create_region_for_alloca): Likewise.
4235 (region_model::set_dynamic_extents): Likewise.
4236 (region_model::check_dynamic_size_for_taint): New decl.
4237 (region_model::check_region_for_taint): New decl.
4238 (region_model_context::get_taint_map): New vfunc.
4239 (noop_region_model_context::get_taint_map): New.
4240 * sm-taint.cc: Remove include of "diagnostic-event-id.h"; add
4241 includes of "gimple-iterator.h", "tristate.h", "selftest.h",
4242 "ordered-hash-map.h", "cgraph.h", "cfg.h", "digraph.h",
4243 "analyzer/supergraph.h", "analyzer/call-string.h",
4244 "analyzer/program-point.h", "analyzer/store.h",
4245 "analyzer/region-model.h", and "analyzer/program-state.h".
4246 (enum bounds): Move to top of file.
4247 (class taint_diagnostic): New.
4248 (class tainted_array_index): Convert to subclass of taint_diagnostic.
4249 (tainted_array_index::emit): Add CWE-129. Reword warning to use
4250 "attacker-controlled" rather than "tainted".
4251 (tainted_array_index::describe_state_change): Move to
4252 taint_diagnostic::describe_state_change.
4253 (tainted_array_index::describe_final_event): Reword to use
4254 "attacker-controlled" rather than "tainted".
4255 (class tainted_offset): New.
4256 (class tainted_size): New.
4257 (class tainted_divisor): New.
4258 (class tainted_allocation_size): New.
4259 (taint_state_machine::alt_get_inherited_state): New.
4260 (taint_state_machine::on_stmt): In assignment handling, remove
4261 ARRAY_REF handling in favor of check_region_for_taint. Add
4262 detection of tainted divisors.
4263 (taint_state_machine::get_taint): New.
4264 (taint_state_machine::combine_states): New.
4265 (region_model::check_region_for_taint): New.
4266 (region_model::check_dynamic_size_for_taint): New.
4267 * sm.h (state_machine::alt_get_inherited_state): New.
4268
4269 2021-11-12 David Malcolm <dmalcolm@redhat.com>
4270
4271 * engine.cc (exploded_node::on_stmt_pre): Return when handling
4272 "__analyzer_dump_state".
4273
4274 2021-11-11 Richard Biener <rguenther@suse.de>
4275
4276 * supergraph.cc: Include bitmap.h.
4277
4278 2021-11-04 David Malcolm <dmalcolm@redhat.com>
4279
4280 * program-state.cc (sm_state_map::dump): Use default_tree_printer
4281 as format decoder.
4282
4283 2021-09-16 Maxim Blinov <maxim.blinov@embecosm.com>
4284
4285 PR bootstrap/102242
4286 * engine.cc (INCLUDE_UNIQUE_PTR): Define.
4287
4288 2021-09-08 David Malcolm <dmalcolm@redhat.com>
4289
4290 PR analyzer/102225
4291 * analyzer.h (compat_types_p): New decl.
4292 * constraint-manager.cc
4293 (constraint_manager::get_or_add_equiv_class): Guard against NULL
4294 type when checking for pointer types.
4295 * region-model-impl-calls.cc (region_model::impl_call_realloc):
4296 Guard against NULL lhs type/region. Guard against the size value
4297 not being of a compatible type for dynamic extents.
4298 * region-model.cc (compat_types_p): Make non-static.
4299
4300 2021-08-30 David Malcolm <dmalcolm@redhat.com>
4301
4302 PR analyzer/99260
4303 * analyzer.h (class custom_edge_info): New class, adapted from
4304 exploded_edge::custom_info_t. Make member functions const.
4305 Make update_model return bool, converting edge param from
4306 reference to a pointer, and adding a ctxt param.
4307 (class path_context): New class.
4308 * call-info.cc: New file.
4309 * call-info.h: New file.
4310 * engine.cc: Include "analyzer/call-info.h" and <memory>.
4311 (impl_region_model_context::impl_region_model_context): Update for
4312 new m_path_ctxt field.
4313 (impl_region_model_context::bifurcate): New.
4314 (impl_region_model_context::terminate_path): New.
4315 (impl_region_model_context::get_malloc_map): New.
4316 (impl_sm_context::impl_sm_context): Update for new m_path_ctxt
4317 field.
4318 (impl_sm_context::get_fndecl_for_call): Likewise.
4319 (impl_sm_context::set_next_state): Likewise.
4320 (impl_sm_context::warn): Likewise.
4321 (impl_sm_context::is_zero_assignment): Likewise.
4322 (impl_sm_context::get_path_context): New.
4323 (impl_sm_context::m_path_ctxt): New.
4324 (impl_region_model_context::on_condition): Update for new
4325 path_ctxt param. Handle m_enode_for_diag being NULL.
4326 (impl_region_model_context::on_phi): Update for new path_ctxt
4327 param.
4328 (exploded_node::on_stmt): Add path_ctxt param, updating ctor calls
4329 to use it as necessary. Use it to bail out after sm-handling,
4330 if needed.
4331 (exploded_node::detect_leaks): Update for new path_ctxt param.
4332 (dynamic_call_info_t::update_model): Update for conversion of
4333 exploded_edge::custom_info_t to custom_edge_info.
4334 (dynamic_call_info_t::add_events_to_path): Likewise.
4335 (rewind_info_t::update_model): Likewise.
4336 (rewind_info_t::add_events_to_path): Likewise.
4337 (exploded_edge::exploded_edge): Likewise.
4338 (exploded_graph::add_edge): Likewise.
4339 (exploded_graph::maybe_process_run_of_before_supernode_enodes):
4340 Update for new path_ctxt param.
4341 (class impl_path_context): New.
4342 (exploded_graph::process_node): Update for new path_ctxt param.
4343 Create an impl_path_context and pass it to exploded_node::on_stmt.
4344 Use it to terminate iterating stmts if terminate_path is called
4345 on it. After processing a run of stmts, query path_ctxt to
4346 potentially terminate the analysis path, and/or to "bifurcate" the
4347 analysis into multiple additional paths.
4348 (feasibility_state::maybe_update_for_edge): Update for new
4349 update_model ctxt param.
4350 * exploded-graph.h
4351 (impl_region_model_context::impl_region_model_context): Add
4352 path_ctxt param.
4353 (impl_region_model_context::bifurcate): New.
4354 (impl_region_model_context::terminate_path): New
4355 (impl_region_model_context::get_ext_state): New.
4356 (impl_region_model_context::get_malloc_map): New.
4357 (impl_region_model_context::m_path_ctxt): New field.
4358 (exploded_node::on_stmt): Add path_ctxt param.
4359 (class exploded_edge::custom_info_t): Move to analyzer.h, renaming
4360 to custom_edge_info, and making the changes as noted in analyzer.h
4361 above.
4362 (exploded_edge::exploded_edge): Update for these changes to
4363 exploded_edge::custom_info_t.
4364 (exploded_edge::m_custom_info): Likewise.
4365 (class dynamic_call_info_t): Likewise.
4366 (class rewind_info_t): Likewise.
4367 (exploded_graph::add_edge): Likewise.
4368 * program-state.cc (program_state::on_edge): Update for new
4369 path_ctxt param.
4370 (program_state::push_call): Likewise.
4371 (program_state::returning_call): Likewise.
4372 (program_state::prune_for_point): Likewise.
4373 * region-model-impl-calls.cc: Include "analyzer/call-info.h".
4374 (call_details::get_fndecl_for_call): New.
4375 (region_model::impl_call_realloc): Reimplement.
4376 * region-model.cc (region_model::on_call_pre): Move call to
4377 impl_call_realloc to...
4378 (region_model::on_call_post): ...here. Consolidate creation
4379 of call_details instance.
4380 (noop_region_model_context::bifurcate): New.
4381 (noop_region_model_context::terminate_path): New.
4382 * region-model.h (call_details::get_call_stmt): New.
4383 (call_details::get_fndecl_for_call): New.
4384 (region_model::on_realloc_with_move): New.
4385 (region_model_context::bifurcate): New.
4386 (region_model_context::terminate_path): New.
4387 (region_model_context::get_ext_state): New.
4388 (region_model_context::get_malloc_map): New.
4389 (noop_region_model_context::bifurcate): New.
4390 (noop_region_model_context::terminate_path): New.
4391 (noop_region_model_context::get_ext_state): New.
4392 (noop_region_model_context::get_malloc_map): New.
4393 * sm-malloc.cc: Include "analyzer/program-state.h".
4394 (malloc_state_machine::on_realloc_call): Reimplement.
4395 (malloc_state_machine::on_realloc_with_move): New.
4396 (region_model::on_realloc_with_move): New.
4397 * sm-signal.cc (class signal_delivery_edge_info_t): Update for
4398 conversion from exploded_edge::custom_info_t to custom_edge_info.
4399 * sm.h (sm_context::get_path_context): New.
4400 * svalue.cc (svalue::maybe_get_constant): Call
4401 unwrap_any_unmergeable.
4402
4403 2021-08-25 Ankur Saini <arsenic@sourceware.org>
4404
4405 PR analyzer/101980
4406 * engine.cc (exploded_graph::maybe_create_dynamic_call): Don't create
4407 calls if max recursion limit is reached.
4408
4409 2021-08-23 David Malcolm <dmalcolm@redhat.com>
4410
4411 * analyzer.h (struct rejected_constraint): Convert to...
4412 (class rejected_constraint): ...this.
4413 (class bounded_ranges): New forward decl.
4414 (class bounded_ranges_manager): New forward decl.
4415 * constraint-manager.cc: Include "analyzer/analyzer-logging.h" and
4416 "tree-pretty-print.h".
4417 (can_plus_one_p): New.
4418 (plus_one): New.
4419 (can_minus_one_p): New.
4420 (minus_one): New.
4421 (bounded_range::bounded_range): New.
4422 (dump_cst): New.
4423 (bounded_range::dump_to_pp): New.
4424 (bounded_range::dump): New.
4425 (bounded_range::to_json): New.
4426 (bounded_range::set_json_attr): New.
4427 (bounded_range::contains_p): New.
4428 (bounded_range::intersects_p): New.
4429 (bounded_range::operator==): New.
4430 (bounded_range::cmp): New.
4431 (bounded_ranges::bounded_ranges): New.
4432 (bounded_ranges::bounded_ranges): New.
4433 (bounded_ranges::bounded_ranges): New.
4434 (bounded_ranges::canonicalize): New.
4435 (bounded_ranges::validate): New.
4436 (bounded_ranges::operator==): New.
4437 (bounded_ranges::dump_to_pp): New.
4438 (bounded_ranges::dump): New.
4439 (bounded_ranges::to_json): New.
4440 (bounded_ranges::eval_condition): New.
4441 (bounded_ranges::contain_p): New.
4442 (bounded_ranges::cmp): New.
4443 (bounded_ranges_manager::~bounded_ranges_manager): New.
4444 (bounded_ranges_manager::get_or_create_empty): New.
4445 (bounded_ranges_manager::get_or_create_point): New.
4446 (bounded_ranges_manager::get_or_create_range): New.
4447 (bounded_ranges_manager::get_or_create_union): New.
4448 (bounded_ranges_manager::get_or_create_intersection): New.
4449 (bounded_ranges_manager::get_or_create_inverse): New.
4450 (bounded_ranges_manager::consolidate): New.
4451 (bounded_ranges_manager::get_or_create_ranges_for_switch): New.
4452 (bounded_ranges_manager::create_ranges_for_switch): New.
4453 (bounded_ranges_manager::make_case_label_ranges): New.
4454 (bounded_ranges_manager::log_stats): New.
4455 (bounded_ranges_constraint::print): New.
4456 (bounded_ranges_constraint::to_json): New.
4457 (bounded_ranges_constraint::operator==): New.
4458 (bounded_ranges_constraint::add_to_hash): New.
4459 (constraint_manager::constraint_manager): Update for new field
4460 m_bounded_ranges_constraints.
4461 (constraint_manager::operator=): Likewise.
4462 (constraint_manager::hash): Likewise.
4463 (constraint_manager::operator==): Likewise.
4464 (constraint_manager::print): Likewise.
4465 (constraint_manager::dump_to_pp): Likewise.
4466 (constraint_manager::to_json): Likewise.
4467 (constraint_manager::add_unknown_constraint): Update the lhs_ec_id
4468 if necessary in existing constraints when combining equivalence
4469 classes. Add similar code for handling
4470 m_bounded_ranges_constraints.
4471 (constraint_manager::add_constraint_internal): Add comment.
4472 (constraint_manager::add_bounded_ranges): New.
4473 (constraint_manager::eval_condition): Use new field
4474 m_bounded_ranges_constraints.
4475 (constraint_manager::purge): Update bounded_ranges_constraint
4476 instances.
4477 (constraint_manager::canonicalize): Update for new field.
4478 (merger_fact_visitor::on_ranges): New.
4479 (constraint_manager::for_each_fact): Use new field
4480 m_bounded_ranges_constraints.
4481 (constraint_manager::validate): Fix off-by-one error needed due
4482 to bug fixed above in add_unknown_constraint. Validate the EC IDs
4483 in m_bounded_ranges_constraints.
4484 (constraint_manager::get_range_manager): New.
4485 (selftest::assert_dump_bounded_range_eq): New.
4486 (ASSERT_DUMP_BOUNDED_RANGE_EQ): New.
4487 (selftest::test_bounded_range): New.
4488 (selftest::assert_dump_bounded_ranges_eq): New.
4489 (ASSERT_DUMP_BOUNDED_RANGES_EQ): New.
4490 (selftest::test_bounded_ranges): New.
4491 (selftest::run_constraint_manager_tests): Call the new selftests.
4492 * constraint-manager.h (struct bounded_range): New.
4493 (struct bounded_ranges): New.
4494 (template <> struct default_hash_traits<bounded_ranges::key_t>): New.
4495 (class bounded_ranges_manager): New.
4496 (fact_visitor::on_ranges): New pure virtual function.
4497 (class bounded_ranges_constraint): New.
4498 (constraint_manager::add_bounded_ranges): New decl.
4499 (constraint_manager::get_range_manager): New decl.
4500 (constraint_manager::m_bounded_ranges_constraints): New field.
4501 * diagnostic-manager.cc (epath_finder::process_worklist_item):
4502 Transfer ownership of rc to add_feasibility_problem.
4503 * engine.cc (feasibility_problem::dump_to_pp): Use get_model.
4504 * feasible-graph.cc (infeasible_node::dump_dot): Update for
4505 conversion of m_rc to a pointer.
4506 (feasible_graph::add_feasibility_problem): Pass RC by pointer and
4507 take ownership.
4508 * feasible-graph.h (infeasible_node::infeasible_node): Pass RC by
4509 pointer and take ownership.
4510 (infeasible_node::~infeasible_node): New.
4511 (infeasible_node::m_rc): Convert to a pointer.
4512 (feasible_graph::add_feasibility_problem): Pass RC by pointer and
4513 take ownership.
4514 * region-model-manager.cc: Include
4515 "analyzer/constraint-manager.h".
4516 (region_model_manager::region_model_manager): Initializer new
4517 field m_range_mgr.
4518 (region_model_manager::~region_model_manager): Delete it.
4519 (region_model_manager::log_stats): Call log_stats on it.
4520 * region-model.cc (region_model::add_constraint): Use new subclass
4521 rejected_op_constraint.
4522 (region_model::apply_constraints_for_gswitch): Reimplement using
4523 bounded_ranges_manager.
4524 (rejected_constraint::dump_to_pp): Convert to...
4525 (rejected_op_constraint::dump_to_pp): ...this.
4526 (rejected_ranges_constraint::dump_to_pp): New.
4527 * region-model.h (struct purge_stats): Add field
4528 m_num_bounded_ranges_constraints.
4529 (region_model_manager::get_range_manager): New.
4530 (region_model_manager::m_range_mgr): New.
4531 (region_model::get_range_manager): New.
4532 (struct rejected_constraint): Split into...
4533 (class rejected_constraint):...this new abstract base class,
4534 and...
4535 (class rejected_op_constraint): ...this new concrete subclass.
4536 (class rejected_ranges_constraint): New.
4537 * supergraph.cc: Include "tree-cfg.h".
4538 (supergraph::supergraph): Drop idx param from add_cfg_edge.
4539 (supergraph::add_cfg_edge): Drop idx param.
4540 (switch_cfg_superedge::switch_cfg_superedge): Move here from
4541 header. Populate m_case_labels with all cases which go to DST.
4542 (switch_cfg_superedge::dump_label_to_pp): Reimplement to use
4543 m_case_labels.
4544 (switch_cfg_superedge::get_case_label): Delete.
4545 * supergraph.h (supergraphadd_cfg_edge): Drop "idx" param.
4546 (switch_cfg_superedge::switch_cfg_superedge): Drop idx param and
4547 move implementation to supergraph.cc.
4548 (switch_cfg_superedge::get_case_label): Delete.
4549 (switch_cfg_superedge::get_case_labels): New.
4550 (switch_cfg_superedge::m_idx): Delete.
4551 (switch_cfg_superedge::m_case_labels): New field.
4552
4553 2021-08-23 David Malcolm <dmalcolm@redhat.com>
4554
4555 PR analyzer/101875
4556 * sm-file.cc (file_diagnostic::describe_state_change): Handle
4557 change.m_expr being NULL.
4558
4559 2021-08-23 David Malcolm <dmalcolm@redhat.com>
4560
4561 PR analyzer/101837
4562 * analyzer.cc (maybe_reconstruct_from_def_stmt): Bail if fn is
4563 NULL, and assert that it's non-NULL before passing it to
4564 build_call_array_loc.
4565
4566 2021-08-23 David Malcolm <dmalcolm@redhat.com>
4567
4568 PR analyzer/101962
4569 * region-model.cc (region_model::eval_condition_without_cm):
4570 Refactor comparison against zero, adding a check for
4571 POINTER_PLUS_EXPR of non-NULL.
4572
4573 2021-08-23 David Malcolm <dmalcolm@redhat.com>
4574
4575 * store.cc (bit_range::intersects_p): New overload.
4576 (bit_range::operator-): New.
4577 (binding_cluster::maybe_get_compound_binding): Handle the partial
4578 overlap case.
4579 (selftest::test_bit_range_intersects_p): Add test coverage for
4580 new overload of bit_range::intersects_p.
4581 * store.h (bit_range::intersects_p): New overload.
4582 (bit_range::operator-): New.
4583
4584 2021-08-23 Ankur Saini <arsenic@sourceware.org>
4585
4586 PR analyzer/102020
4587 * diagnostic-manager.cc
4588 (diagnostic_manager::prune_for_sm_diagnostic)<case EK_CALL_EDGE>: Fix typo.
4589
4590 2021-08-21 Ankur Saini <arsenic@sourceware.org>
4591
4592 PR analyzer/101980
4593 * diagnostic-manager.cc
4594 (diagnostic_manager::prune_for_sm_diagnostic)<case EK_CALL_EDGE>: Use
4595 caller_model only when the supergraph_edge doesn't exixt.
4596 (diagnostic_manager::prune_for_sm_diagnostic)<case EK_RETURN_EDGE>:
4597 Likewise.
4598 * engine.cc (exploded_graph::create_dynamic_call): Rename to...
4599 (exploded_graph::maybe_create_dynamic_call): ...this, return call
4600 creation status.
4601 (exploded_graph::process_node): Handle calls which were not dynamically
4602 discovered.
4603 * exploded-graph.h (exploded_graph::create_dynamic_call): Rename to...
4604 (exploded_graph::maybe_create_dynamic_call): ...this.
4605 * region-model.cc (region_model::update_for_gcall): New param, use it
4606 to push call to frame.
4607 (region_model::update_for_call_superedge): Pass callee function to
4608 update_for_gcall.
4609 * region-model.h (region_model::update_for_gcall): New param.
4610
4611 2021-08-18 Ankur Saini <arsenic@sourceware.org>
4612
4613 PR analyzer/97114
4614 * region-model.cc (region_model::get_rvalue_1): Add case for
4615 OBJ_TYPE_REF.
4616
4617 2021-08-18 Ankur Saini <arsenic@sourceware.org>
4618
4619 PR analyzer/100546
4620 * analysis-plan.cc (analysis_plan::use_summary_p): Don't use call
4621 summaries if there is no callgraph edge
4622 * checker-path.cc (call_event::call_event): Handle calls events that
4623 are not represented by a supergraph call edge
4624 (return_event::return_event): Likewise.
4625 (call_event::get_desc): Work with new call_event structure.
4626 (return_event::get_desc): Likeise.
4627 * checker-path.h (call_event::m_src_snode): New field.
4628 (call_event::m_dest_snode): New field.
4629 (return_event::m_src_snode): New field.
4630 (return_event::m_dest_snode): New field.
4631 * diagnostic-manager.cc
4632 (diagnostic_manager::prune_for_sm_diagnostic)<case EK_CALL_EDGE>:
4633 Refactor to work with edges without callgraph edge.
4634 (diagnostic_manager::prune_for_sm_diagnostic)<case EK_RETURN_EDGE>:
4635 Likewise.
4636 * engine.cc (dynamic_call_info_t::update_model): New function.
4637 (dynamic_call_info_t::add_events_to_path): New function.
4638 (exploded_graph::create_dynamic_call): New function.
4639 (exploded_graph::process_node): Work with dynamically discovered calls.
4640 * exploded-graph.h (class dynamic_call_info_t): New class.
4641 (exploded_graph::create_dynamic_call): New decl.
4642 * program-point.cc (program_point::push_to_call_stack): New function.
4643 (program_point::pop_from_call_stack): New function.
4644 * program-point.h (program_point::push_to_call_stack): New decl.
4645 (program_point::pop_from_call_stack): New decl.
4646 * program-state.cc (program_state::push_call): New function.
4647 (program_state::returning_call): New function.
4648 * program-state.h (program_state::push_call): New decl.
4649 (program_state::returning_call): New decl.
4650 * region-model.cc (region_model::update_for_gcall) New function.
4651 (region_model::update_for_return_gcall): New function.
4652 (egion_model::update_for_call_superedge): Get the underlying gcall and
4653 update for gcall.
4654 (region_model::update_for_return_superedge): Likewise.
4655 * region-model.h (region_model::update_for_gcall): New decl.
4656 (region_model::update_for_return_gcall): New decl.
4657 * state-purge.cc (state_purge_per_ssa_name::process_point): Update to
4658 work with calls without underlying cgraph edge.
4659 * supergraph.cc (supergraph::supergraph) Split snodes at every callsite.
4660 * supergraph.h (supernode::get_returning_call) New accessor.
4661
4662 2021-08-04 David Malcolm <dmalcolm@redhat.com>
4663
4664 PR analyzer/101570
4665 * analyzer.cc (maybe_reconstruct_from_def_stmt): Add GIMPLE_ASM
4666 case.
4667 * analyzer.h (class asm_output_svalue): New forward decl.
4668 (class reachable_regions): New forward decl.
4669 * complexity.cc (complexity::from_vec_svalue): New.
4670 * complexity.h (complexity::from_vec_svalue): New decl.
4671 * engine.cc (feasibility_state::maybe_update_for_edge): Handle
4672 asm stmts by calling on_asm_stmt.
4673 * region-model-asm.cc: New file.
4674 * region-model-manager.cc
4675 (region_model_manager::maybe_fold_asm_output_svalue): New.
4676 (region_model_manager::get_or_create_asm_output_svalue): New.
4677 (region_model_manager::log_stats): Log m_asm_output_values_map.
4678 * region-model.cc (region_model::on_stmt_pre): Handle GIMPLE_ASM.
4679 * region-model.h (visitor::visit_asm_output_svalue): New.
4680 (region_model_manager::get_or_create_asm_output_svalue): New decl.
4681 (region_model_manager::maybe_fold_asm_output_svalue): New decl.
4682 (region_model_manager::asm_output_values_map_t): New typedef.
4683 (region_model_manager::m_asm_output_values_map): New field.
4684 (region_model::on_asm_stmt): New.
4685 * store.cc (binding_cluster::on_asm): New.
4686 * store.h (binding_cluster::on_asm): New decl.
4687 * svalue.cc (svalue::cmp_ptr): Handle SK_ASM_OUTPUT.
4688 (asm_output_svalue::dump_to_pp): New.
4689 (asm_output_svalue::dump_input): New.
4690 (asm_output_svalue::input_idx_to_asm_idx): New.
4691 (asm_output_svalue::accept): New.
4692 * svalue.h (enum svalue_kind): Add SK_ASM_OUTPUT.
4693 (svalue::dyn_cast_asm_output_svalue): New.
4694 (class asm_output_svalue): New.
4695 (is_a_helper <const asm_output_svalue *>::test): New.
4696 (struct default_hash_traits<asm_output_svalue::key_t>): New.
4697
4698 2021-08-03 Jakub Jelinek <jakub@redhat.com>
4699
4700 PR analyzer/101721
4701 * sm-malloc.cc (known_allocator_p): Only check DECL_FUNCTION_CODE on
4702 BUILT_IN_NORMAL builtins.
4703
4704 2021-07-29 Ankur Saini <arsenic@sourceware.org>
4705
4706 * call-string.cc (call_string::element_t::operator==): New operator.
4707 (call_String::element_t::operator!=): New operator.
4708 (call_string::element_t::get_caller_function): New function.
4709 (call_string::element_t::get_callee_function): New function.
4710 (call_string::call_string): Refactor to Initialise m_elements.
4711 (call_string::operator=): Refactor to work with m_elements.
4712 (call_string::operator==): Likewise.
4713 (call_string::to_json): Likewise.
4714 (call_string::hash): Refactor to hash e.m_caller.
4715 (call_string::push_call): Refactor to work with m_elements.
4716 (call_string::push_call): New overload to push call via supernodes.
4717 (call_string::pop): Refactor to work with m_elements.
4718 (call_string::calc_recursion_depth): Likewise.
4719 (call_string::cmp): Likewise.
4720 (call_string::validate): Likewise.
4721 (call_string::operator[]): Likewise.
4722 * call-string.h (class supernode): New forward decl.
4723 (struct call_string::element_t): New struct.
4724 (call_string::call_string): Refactor to initialise m_elements.
4725 (call_string::bool empty_p): Refactor to work with m_elements.
4726 (call_string::get_callee_node): New decl.
4727 (call_string::get_caller_node): New decl.
4728 (m_elements): Replaces m_return_edges.
4729 * program-point.cc (program_point::get_function_at_depth): Refactor to
4730 work with new call-string format.
4731 (program_point::validate): Likewise.
4732 (program_point::on_edge): Likewise.
4733
4734 2021-07-28 David Malcolm <dmalcolm@redhat.com>
4735
4736 * region-model.cc (region_model::on_call_pre): Treat
4737 IFN_UBSAN_BOUNDS, BUILT_IN_STACK_SAVE, and BUILT_IN_STACK_RESTORE
4738 as no-ops, rather than handling them as unknown functions.
4739
4740 2021-07-28 David Malcolm <dmalcolm@redhat.com>
4741
4742 * region-model-impl-calls.cc (region_model::impl_call_alloca):
4743 Drop redundant return value.
4744 (region_model::impl_call_builtin_expect): Likewise.
4745 (region_model::impl_call_calloc): Likewise.
4746 (region_model::impl_call_malloc): Likewise.
4747 (region_model::impl_call_memset): Likewise.
4748 (region_model::impl_call_operator_new): Likewise.
4749 (region_model::impl_call_operator_delete): Likewise.
4750 (region_model::impl_call_strlen): Likewise.
4751 * region-model.cc (region_model::on_call_pre): Fix return value of
4752 known functions that don't have unknown side-effects.
4753 * region-model.h (region_model::impl_call_alloca): Drop redundant
4754 return value.
4755 (region_model::impl_call_builtin_expect): Likewise.
4756 (region_model::impl_call_calloc): Likewise.
4757 (region_model::impl_call_malloc): Likewise.
4758 (region_model::impl_call_memset): Likewise.
4759 (region_model::impl_call_strlen): Likewise.
4760 (region_model::impl_call_operator_new): Likewise.
4761 (region_model::impl_call_operator_delete): Likewise.
4762
4763 2021-07-28 Siddhesh Poyarekar <siddhesh@gotplt.org>
4764
4765 * analyzer.cc (is_named_call_p, is_std_named_call_p): Make
4766 first argument a const_tree.
4767 * analyzer.h (is_named_call_p, -s_std_named_call_p): Likewise.
4768 * sm-malloc.cc (known_allocator_p): New function.
4769 (malloc_state_machine::on_stmt): Use it.
4770
4771 2021-07-28 Siddhesh Poyarekar <siddhesh@gotplt.org>
4772
4773 * sm-malloc.cc
4774 (malloc_state_machine::get_or_create_deallocator): Recognize
4775 __builtin_free.
4776
4777 2021-07-26 David Malcolm <dmalcolm@redhat.com>
4778
4779 * region-model.cc (region_model::on_call_pre): Always set conjured
4780 LHS, not just for SSA names.
4781
4782 2021-07-23 David Malcolm <dmalcolm@redhat.com>
4783
4784 * diagnostic-manager.cc
4785 (class auto_disable_complexity_checks): New.
4786 (epath_finder::explore_feasible_paths): Use it to disable
4787 complexity checks whilst processing the worklist.
4788 * region-model-manager.cc
4789 (region_model_manager::region_model_manager): Initialize
4790 m_check_complexity.
4791 (region_model_manager::reject_if_too_complex): Bail if
4792 m_check_complexity is false.
4793 * region-model.h
4794 (region_model_manager::enable_complexity_check): New.
4795 (region_model_manager::disable_complexity_check): New.
4796 (region_model_manager::m_check_complexity): New.
4797
4798 2021-07-21 David Malcolm <dmalcolm@redhat.com>
4799
4800 PR analyzer/101547
4801 * sm-file.cc (file_leak::emit): Handle m_arg being NULL.
4802 (file_leak::describe_final_event): Handle ev.m_expr being NULL.
4803
4804 2021-07-21 David Malcolm <dmalcolm@redhat.com>
4805
4806 PR analyzer/101522
4807 * store.cc (binding_cluster::purge_state_involving): Don't change
4808 m_map whilst iterating through it.
4809
4810 2021-07-21 David Malcolm <dmalcolm@redhat.com>
4811
4812 * region-model.cc (region_model::handle_phi): Add "old_state"
4813 param and use it.
4814 (region_model::update_for_phis): Update so that all of the phi
4815 stmts are effectively handled simultaneously, rather than in
4816 order.
4817 * region-model.h (region_model::handle_phi): Add "old_state"
4818 param.
4819 * state-purge.cc (self_referential_phi_p): Replace with...
4820 (name_used_by_phis_p): ...this new function.
4821 (state_purge_per_ssa_name::process_point): Update to use the
4822 above, so that all phi stmts at a basic block are effectively
4823 considered simultaneously, and only consider the phi arguments for
4824 the pertinent in-edge.
4825 * supergraph.cc (cfg_superedge::get_phi_arg_idx): New.
4826 (cfg_superedge::get_phi_arg): Use the above.
4827 * supergraph.h (cfg_superedge::get_phi_arg_idx): New decl.
4828
4829 2021-07-21 David Malcolm <dmalcolm@redhat.com>
4830
4831 * state-purge.cc (state_purge_annotator::add_node_annotations):
4832 Rather than erroneously always using the NULL in-edge, determine
4833 each relevant in-edge, and print the appropriate data for each
4834 in-edge. Use print_needed to print the data as comma-separated
4835 lists of SSA names.
4836 (print_vec_of_names): Add "within_table" param and use it.
4837 (state_purge_annotator::add_stmt_annotations): Factor out
4838 collation and printing code into...
4839 (state_purge_annotator::print_needed): ...this new function.
4840 * state-purge.h (state_purge_annotator::print_needed): New decl.
4841
4842 2021-07-21 David Malcolm <dmalcolm@redhat.com>
4843
4844 * program-point.cc (function_point::print): Show src BB index at
4845 BEFORE_SUPERNODE.
4846
4847 2021-07-21 David Malcolm <dmalcolm@redhat.com>
4848
4849 * svalue.cc (infix_p): New.
4850 (binop_svalue::dump_to_pp): Use it to print MIN_EXPR and MAX_EXPR
4851 in prefix form, rather than infix.
4852
4853 2021-07-19 David Malcolm <dmalcolm@redhat.com>
4854
4855 PR analyzer/101503
4856 * constraint-manager.cc (constraint_manager::add_constraint): Use
4857 can_have_associated_state_p rather than testing for unknown.
4858 (constraint_manager::get_or_add_equiv_class): Likewise.
4859 * program-state.cc (sm_state_map::set_state): Likewise.
4860 (sm_state_map::impl_set_state): Add assertion.
4861 * region-model-manager.cc
4862 (region_model_manager::maybe_fold_unaryop): Handle poisoned
4863 values.
4864 (region_model_manager::maybe_fold_binop): Move handling of unknown
4865 values...
4866 (region_model_manager::get_or_create_binop): ...to here, and
4867 generalize to use can_have_associated_state_p.
4868 (region_model_manager::maybe_fold_sub_svalue): Use
4869 can_have_associated_state_p rather than testing for unknown.
4870 (region_model_manager::maybe_fold_repeated_svalue): Use unknown
4871 when the size or repeated value is "unknown"/"poisoned".
4872 * region-model.cc (region_model::purge_state_involving): Reject
4873 attempts to purge unknown/poisoned svalues, as these svalues
4874 should not have state associated with them.
4875 * svalue.cc (sub_svalue::sub_svalue): Assert that we're building
4876 on top of an svalue with can_have_associated_state_p.
4877 (repeated_svalue::repeated_svalue): Likewise.
4878 (bits_within_svalue::bits_within_svalue): Likewise.
4879 * svalue.h (svalue::can_have_associated_state_p): New.
4880 (unknown_svalue::can_have_associated_state_p): New.
4881 (poisoned_svalue::can_have_associated_state_p): New.
4882 (unaryop_svalue::unaryop_svalue): Assert that we're building on
4883 top of an svalue with can_have_associated_state_p.
4884 (binop_svalue::binop_svalue): Likewise.
4885 (widening_svalue::widening_svalue): Likewise.
4886
4887 2021-07-16 David Malcolm <dmalcolm@redhat.com>
4888
4889 * analyzer.h (enum access_direction): New.
4890 * engine.cc (exploded_node::on_longjmp): Update for new param of
4891 get_store_value.
4892 * program-state.cc (program_state::prune_for_point): Likewise.
4893 * region-model-impl-calls.cc (region_model::impl_call_memcpy):
4894 Replace call to check_for_writable_region with call to
4895 check_region_for_write.
4896 (region_model::impl_call_memset): Likewise.
4897 (region_model::impl_call_strcpy): Likewise.
4898 * region-model-reachability.cc (reachable_regions::add): Update
4899 for new param of get_store_value.
4900 * region-model.cc (region_model::get_rvalue_1): Likewise, also for
4901 get_rvalue_for_bits.
4902 (region_model::get_store_value): Add ctxt param and use it to call
4903 check_region_for_read.
4904 (region_model::get_rvalue_for_bits): Add ctxt param and use it to
4905 call get_store_value.
4906 (region_model::check_region_access): New.
4907 (region_model::check_region_for_write): New.
4908 (region_model::check_region_for_read): New.
4909 (region_model::set_value): Update comment. Replace call to
4910 check_for_writable_region with call to check_region_for_write.
4911 * region-model.h (region_model::get_rvalue_for_bits): Add ctxt
4912 param.
4913 (region_model::get_store_value): Add ctxt param.
4914 (region_model::check_region_access): New decl.
4915 (region_model::check_region_for_write): New decl.
4916 (region_model::check_region_for_read): New decl.
4917 * region.cc (region_model::copy_region): Update call to
4918 get_store_value.
4919 * svalue.cc (initial_svalue::implicitly_live_p): Likewise.
4920
4921 2021-07-16 David Malcolm <dmalcolm@redhat.com>
4922
4923 * engine.cc (exploded_node::on_stmt_pre): Handle
4924 __analyzer_dump_state.
4925 * program-state.cc (extrinsic_state::get_sm_idx_by_name): New.
4926 (program_state::impl_call_analyzer_dump_state): New.
4927 * program-state.h (extrinsic_state::get_sm_idx_by_name): New decl.
4928 (program_state::impl_call_analyzer_dump_state): New decl.
4929 * region-model-impl-calls.cc
4930 (call_details::get_arg_string_literal): New.
4931 * region-model.h (call_details::get_arg_string_literal): New decl.
4932
4933 2021-07-16 David Malcolm <dmalcolm@redhat.com>
4934
4935 * program-state.cc (program_state::detect_leaks): Simplify using
4936 svalue::maybe_get_region.
4937 * region-model-impl-calls.cc (region_model::impl_call_fgets): Likewise.
4938 (region_model::impl_call_fread): Likewise.
4939 (region_model::impl_call_free): Likewise.
4940 (region_model::impl_call_operator_delete): Likewise.
4941 * region-model.cc (selftest::test_stack_frames): Likewise.
4942 (selftest::test_state_merging): Likewise.
4943 * svalue.cc (svalue::maybe_get_region): New.
4944 * svalue.h (svalue::maybe_get_region): New decl.
4945
4946 2021-07-15 David Malcolm <dmalcolm@redhat.com>
4947
4948 * svalue.h (is_a_helper <placeholder_svalue *>::test): Make
4949 param and template param const.
4950 (is_a_helper <widening_svalue *>::test): Likewise.
4951 (is_a_helper <compound_svalue *>::test): Likewise.
4952 (is_a_helper <conjured_svalue *>::test): Likewise.
4953
4954 2021-07-15 David Malcolm <dmalcolm@redhat.com>
4955
4956 PR analyzer/95006
4957 PR analyzer/94713
4958 PR analyzer/94714
4959 * analyzer.cc (maybe_reconstruct_from_def_stmt): Split out
4960 GIMPLE_ASSIGN case into...
4961 (get_diagnostic_tree_for_gassign_1): New.
4962 (get_diagnostic_tree_for_gassign): New.
4963 * analyzer.h (get_diagnostic_tree_for_gassign): New decl.
4964 * analyzer.opt (Wanalyzer-write-to-string-literal): New.
4965 * constraint-manager.cc (class svalue_purger): New.
4966 (constraint_manager::purge_state_involving): New.
4967 * constraint-manager.h
4968 (constraint_manager::purge_state_involving): New.
4969 * diagnostic-manager.cc (saved_diagnostic::supercedes_p): New.
4970 (dedupe_winners::handle_interactions): New.
4971 (diagnostic_manager::emit_saved_diagnostics): Call it.
4972 * diagnostic-manager.h (saved_diagnostic::supercedes_p): New decl.
4973 * engine.cc (impl_region_model_context::warn): Convert return type
4974 to bool. Return false if the diagnostic isn't saved.
4975 (impl_region_model_context::purge_state_involving): New.
4976 (impl_sm_context::get_state): Use NULL ctxt when querying old
4977 rvalue.
4978 (impl_sm_context::set_next_state): Use new sval when querying old
4979 state.
4980 (class dump_path_diagnostic): Move to region-model.cc
4981 (exploded_node::on_stmt): Move to on_stmt_pre and on_stmt_post.
4982 Remove call to purge_state_involving.
4983 (exploded_node::on_stmt_pre): New, based on the above. Move most
4984 of it to region_model::on_stmt_pre.
4985 (exploded_node::on_stmt_post): Likewise, moving to
4986 region_model::on_stmt_post.
4987 (class stale_jmp_buf): Fix parent class to use curiously recurring
4988 template pattern.
4989 (feasibility_state::maybe_update_for_edge): Call on_call_pre and
4990 on_call_post on gcalls.
4991 * exploded-graph.h (impl_region_model_context::warn): Return bool.
4992 (impl_region_model_context::purge_state_involving): New decl.
4993 (exploded_node::on_stmt_pre): New decl.
4994 (exploded_node::on_stmt_post): New decl.
4995 * pending-diagnostic.h (pending_diagnostic::use_of_uninit_p): New.
4996 (pending_diagnostic::supercedes_p): New.
4997 * program-state.cc (sm_state_map::get_state): Inherit state for
4998 conjured_svalue as well as initial_svalue.
4999 (sm_state_map::purge_state_involving): Also support SK_CONJURED.
5000 * region-model-impl-calls.cc (call_details::get_uncertainty):
5001 Handle m_ctxt being NULL.
5002 (call_details::get_or_create_conjured_svalue): New.
5003 (region_model::impl_call_fgets): New.
5004 (region_model::impl_call_fread): New.
5005 * region-model-manager.cc
5006 (region_model_manager::get_or_create_initial_value): Return an
5007 uninitialized poisoned value for regions that can't have initial
5008 values.
5009 * region-model-reachability.cc
5010 (reachable_regions::mark_escaped_clusters): Handle ctxt being
5011 NULL.
5012 * region-model.cc (region_to_value_map::purge_state_involving): New.
5013 (poisoned_value_diagnostic::use_of_uninit_p): New.
5014 (poisoned_value_diagnostic::emit): Handle POISON_KIND_UNINIT.
5015 (poisoned_value_diagnostic::describe_final_event): Likewise.
5016 (region_model::check_for_poison): New.
5017 (region_model::on_assignment): Call it.
5018 (class dump_path_diagnostic): Move here from engine.cc.
5019 (region_model::on_stmt_pre): New, based on exploded_node::on_stmt.
5020 (region_model::on_call_pre): Move the setting of the LHS to a
5021 conjured svalue to before the checks for specific functions.
5022 Handle "fgets", "fgets_unlocked", and "fread".
5023 (region_model::purge_state_involving): New.
5024 (region_model::handle_unrecognized_call): Handle ctxt being NULL.
5025 (region_model::get_rvalue): Call check_for_poison.
5026 (selftest::test_stack_frames): Use NULL for context when getting
5027 uninitialized rvalue.
5028 (selftest::test_alloca): Likewise.
5029 * region-model.h (region_to_value_map::purge_state_involving): New
5030 decl.
5031 (call_details::get_or_create_conjured_svalue): New decl.
5032 (region_model::on_stmt_pre): New decl.
5033 (region_model::purge_state_involving): New decl.
5034 (region_model::impl_call_fgets): New decl.
5035 (region_model::impl_call_fread): New decl.
5036 (region_model::check_for_poison): New decl.
5037 (region_model_context::warn): Return bool.
5038 (region_model_context::purge_state_involving): New.
5039 (noop_region_model_context::warn): Return bool.
5040 (noop_region_model_context::purge_state_involving): New.
5041 (test_region_model_context:: warn): Return bool.
5042 * region.cc (region::get_memory_space): New.
5043 (region::can_have_initial_svalue_p): New.
5044 (region::involves_p): New.
5045 * region.h (enum memory_space): New.
5046 (region::get_memory_space): New decl.
5047 (region::can_have_initial_svalue_p): New decl.
5048 (region::involves_p): New decl.
5049 * sm-malloc.cc (use_after_free::supercedes_p): New.
5050 * store.cc (binding_cluster::purge_state_involving): New.
5051 (store::purge_state_involving): New.
5052 * store.h (class symbolic_binding): New forward decl.
5053 (binding_key::dyn_cast_symbolic_binding): New.
5054 (symbolic_binding::dyn_cast_symbolic_binding): New.
5055 (binding_cluster::purge_state_involving): New.
5056 (store::purge_state_involving): New.
5057 * svalue.cc (svalue::can_merge_p): Reject attempts to merge
5058 poisoned svalues with other svalues, so that we identify
5059 paths in which a variable is conditionally uninitialized.
5060 (involvement_visitor::visit_conjured_svalue): New.
5061 (svalue::involves_p): Also handle SK_CONJURED.
5062 (poison_kind_to_str): Handle POISON_KIND_UNINIT.
5063 (poisoned_svalue::maybe_fold_bits_within): New.
5064 * svalue.h (enum poison_kind): Add POISON_KIND_UNINIT.
5065 (poisoned_svalue::maybe_fold_bits_within): New decl.
5066
5067 2021-07-15 David Malcolm <dmalcolm@redhat.com>
5068
5069 * analyzer.opt (fdump-analyzer-exploded-paths): New.
5070 * diagnostic-manager.cc
5071 (diagnostic_manager::emit_saved_diagnostic): Implement it.
5072 * engine.cc (exploded_path::dump_to_pp): Add ext_state param and
5073 use it to dump states if non-NULL.
5074 (exploded_path::dump): Likewise.
5075 (exploded_path::dump_to_file): New.
5076 * exploded-graph.h (exploded_path::dump_to_pp): Add ext_state
5077 param.
5078 (exploded_path::dump): Likewise.
5079 (exploded_path::dump): Likewise.
5080 (exploded_path::dump_to_file): New.
5081
5082 2021-07-15 David Malcolm <dmalcolm@redhat.com>
5083
5084 * analyzer.cc (fixup_tree_for_diagnostic_1): Use DECL_DEBUG_EXPR
5085 if it's available.
5086 * engine.cc (readability): Likewise.
5087
5088 2021-07-15 David Malcolm <dmalcolm@redhat.com>
5089
5090 * state-purge.cc (self_referential_phi_p): New.
5091 (state_purge_per_ssa_name::process_point): Don't purge an SSA name
5092 at its def-stmt if the def-stmt is self-referential.
5093
5094 2021-07-07 David Malcolm <dmalcolm@redhat.com>
5095
5096 * diagnostic-manager.cc (null_assignment_sm_context::get_state):
5097 New overload.
5098 (null_assignment_sm_context::set_next_state): New overload.
5099 (null_assignment_sm_context::get_diagnostic_tree): New.
5100 * engine.cc (impl_sm_context::get_state): New overload.
5101 (impl_sm_context::set_next_state): New overload.
5102 (impl_sm_context::get_diagnostic_tree): New overload.
5103 (impl_region_model_context::on_condition): Convert params from
5104 tree to const svalue *.
5105 * exploded-graph.h (impl_region_model_context::on_condition):
5106 Likewise.
5107 * region-model.cc (region_model::on_call_pre): Move handling of
5108 internal calls to before checking for get_fndecl_for_call.
5109 (region_model::add_constraints_from_binop): New.
5110 (region_model::add_constraint): Split out into a new overload
5111 working on const svalue * rather than tree. Call
5112 add_constraints_from_binop. Drop call to
5113 add_any_constraints_from_ssa_def_stmt.
5114 (region_model::add_any_constraints_from_ssa_def_stmt): Delete.
5115 (region_model::add_any_constraints_from_gassign): Delete.
5116 (region_model::add_any_constraints_from_gcall): Delete.
5117 * region-model.h
5118 (region_model::add_any_constraints_from_ssa_def_stmt): Delete.
5119 (region_model::add_any_constraints_from_gassign): Delete.
5120 (region_model::add_any_constraints_from_gcall): Delete.
5121 (region_model::add_constraint): Add overload decl.
5122 (region_model::add_constraints_from_binop): New decl.
5123 (region_model_context::on_condition): Convert params from tree to
5124 const svalue *.
5125 (noop_region_model_context::on_condition): Likewise.
5126 * sm-file.cc (fileptr_state_machine::condition): Likewise.
5127 * sm-malloc.cc (malloc_state_machine::on_condition): Likewise.
5128 * sm-pattern-test.cc: Include tristate.h, selftest.h,
5129 analyzer/call-string.h, analyzer/program-point.h,
5130 analyzer/store.h, and analyzer/region-model.h.
5131 (pattern_test_state_machine::on_condition): Convert params from tree to
5132 const svalue *.
5133 * sm-sensitive.cc (sensitive_state_machine::on_condition): Delete.
5134 * sm-signal.cc (signal_state_machine::on_condition): Delete.
5135 * sm-taint.cc (taint_state_machine::on_condition): Convert params
5136 from tree to const svalue *.
5137 * sm.cc: Include tristate.h, selftest.h, analyzer/call-string.h,
5138 analyzer/program-point.h, analyzer/store.h, and
5139 analyzer/region-model.h.
5140 (any_pointer_p): Add overload taking const svalue *sval.
5141 * sm.h (any_pointer_p): Add overload taking const svalue *sval.
5142 (state_machine::on_condition): Convert params from tree to
5143 const svalue *. Provide no-op default implementation.
5144 (sm_context::get_state): Add overload taking const svalue *sval.
5145 (sm_context::set_next_state): Likewise.
5146 (sm_context::on_transition): Likewise.
5147 (sm_context::get_diagnostic_tree): Likewise.
5148 * svalue.cc (svalue::all_zeroes_p): New.
5149 (constant_svalue::all_zeroes_p): New.
5150 (repeated_svalue::all_zeroes_p): Convert to vfunc.
5151 * svalue.h (svalue::all_zeroes_p): New decl.
5152 (constant_svalue::all_zeroes_p): New decl.
5153 (repeated_svalue::all_zeroes_p): Convert decl to vfunc.
5154
5155 2021-06-30 David Malcolm <dmalcolm@redhat.com>
5156
5157 PR analyzer/95006
5158 * analyzer.h (class repeated_svalue): New forward decl.
5159 (class bits_within_svalue): New forward decl.
5160 (class sized_region): New forward decl.
5161 (get_field_at_bit_offset): New forward decl.
5162 * engine.cc (exploded_graph::get_or_create_node): Validate the
5163 merged state.
5164 (exploded_graph::maybe_process_run_of_before_supernode_enodes):
5165 Validate the states at each stage.
5166 * program-state.cc (program_state::validate): Validate
5167 m_region_model.
5168 * region-model-impl-calls.cc (region_model::impl_call_memset):
5169 Replace special-case logic for handling constant sizes with
5170 a call to fill_region of a sized_region with the given fill value.
5171 * region-model-manager.cc (maybe_undo_optimize_bit_field_compare):
5172 Drop DK_direct.
5173 (region_model_manager::maybe_fold_sub_svalue): Fold element-based
5174 subregions of an initial value into initial values of an element.
5175 Fold subvalues of repeated svalues.
5176 (region_model_manager::maybe_fold_repeated_svalue): New.
5177 (region_model_manager::get_or_create_repeated_svalue): New.
5178 (get_bit_range_for_field): New.
5179 (get_byte_range_for_field): New.
5180 (get_field_at_byte_range): New.
5181 (region_model_manager::maybe_fold_bits_within_svalue): New.
5182 (region_model_manager::get_or_create_bits_within): New.
5183 (region_model_manager::get_sized_region): New.
5184 (region_model_manager::log_stats): Update for addition of
5185 m_repeated_values_map, m_bits_within_values_map, and
5186 m_sized_regions.
5187 * region-model.cc (region_model::validate): New.
5188 (region_model::on_assignment): Drop enum binding_kind.
5189 (region_model::get_initial_value_for_global): Likewise.
5190 (region_model::get_rvalue_for_bits): Replace body with call to
5191 get_or_create_bits_within.
5192 (region_model::get_capacity): Handle RK_SIZED.
5193 (region_model::set_value): Drop enum binding_kind.
5194 (region_model::fill_region): New.
5195 (region_model::get_representative_path_var_1): Handle RK_SIZED.
5196 * region-model.h (visitor::visit_repeated_svalue): New.
5197 (visitor::visit_bits_within_svalue): New.
5198 (region_model_manager::get_or_create_repeated_svalue): New decl.
5199 (region_model_manager::get_or_create_bits_within): New decl.
5200 (region_model_manager::get_sized_region): New decl.
5201 (region_model_manager::maybe_fold_repeated_svalue): New decl.
5202 (region_model_manager::maybe_fold_bits_within_svalue): New decl.
5203 (region_model_manager::repeated_values_map_t): New typedef.
5204 (region_model_manager::m_repeated_values_map): New field.
5205 (region_model_manager::bits_within_values_map_t): New typedef.
5206 (region_model_manager::m_bits_within_values_map): New field.
5207 (region_model_manager::m_sized_regions): New field.
5208 (region_model::fill_region): New decl.
5209 * region.cc (region::get_base_region): Handle RK_SIZED.
5210 (region::base_region_p): Likewise.
5211 (region::get_byte_size_sval): New.
5212 (get_field_at_bit_offset): Make non-static.
5213 (region::calc_offset): Move implementation of cases to
5214 get_relative_concrete_offset vfunc implementations. Handle
5215 RK_SIZED.
5216 (region::get_relative_concrete_offset): New.
5217 (decl_region::get_svalue_for_initializer): Drop enum binding_kind.
5218 (field_region::get_relative_concrete_offset): New, from
5219 region::calc_offset.
5220 (element_region::get_relative_concrete_offset): Likewise.
5221 (offset_region::get_relative_concrete_offset): Likewise.
5222 (sized_region::accept): New.
5223 (sized_region::dump_to_pp): New.
5224 (sized_region::get_byte_size): New.
5225 (sized_region::get_bit_size): New.
5226 * region.h (enum region_kind): Add RK_SIZED.
5227 (region::dyn_cast_sized_region): New.
5228 (region::get_byte_size): Make virtual.
5229 (region::get_bit_size): Likewise.
5230 (region::get_byte_size_sval): New decl.
5231 (region::get_relative_concrete_offset): New decl.
5232 (field_region::get_relative_concrete_offset): New decl.
5233 (element_region::get_relative_concrete_offset): Likewise.
5234 (offset_region::get_relative_concrete_offset): Likewise.
5235 (class sized_region): New.
5236 * store.cc (binding_kind_to_string): Delete.
5237 (binding_key::make): Drop enum binding_kind.
5238 (binding_key::dump_to_pp): Delete.
5239 (binding_key::cmp_ptrs): Drop enum binding_kind.
5240 (bit_range::contains_p): New.
5241 (byte_range::dump): New.
5242 (byte_range::contains_p): New.
5243 (byte_range::cmp): New.
5244 (concrete_binding::dump_to_pp): Drop enum binding_kind.
5245 (concrete_binding::cmp_ptr_ptr): Likewise.
5246 (symbolic_binding::dump_to_pp): Likewise.
5247 (symbolic_binding::cmp_ptr_ptr): Likewise.
5248 (binding_map::apply_ctor_val_to_range): Likewise.
5249 (binding_map::apply_ctor_pair_to_child_region): Likewise.
5250 (binding_map::get_overlapping_bindings): New.
5251 (binding_map::remove_overlapping_bindings): New.
5252 (binding_cluster::validate): New.
5253 (binding_cluster::bind): Drop enum binding_kind.
5254 (binding_cluster::bind_compound_sval): Likewise.
5255 (binding_cluster::purge_region): Likewise.
5256 (binding_cluster::zero_fill_region): Reimplement in terms of...
5257 (binding_cluster::fill_region): New.
5258 (binding_cluster::mark_region_as_unknown): Drop enum binding_kind.
5259 (binding_cluster::get_binding): Likewise.
5260 (binding_cluster::get_binding_recursive): Likewise.
5261 (binding_cluster::get_any_binding): Likewise.
5262 (binding_cluster::maybe_get_compound_binding): Reimplement.
5263 (binding_cluster::get_overlapping_bindings): Delete.
5264 (binding_cluster::remove_overlapping_bindings): Reimplement in
5265 terms of binding_map::remove_overlapping_bindings.
5266 (binding_cluster::can_merge_p): Update for removal of
5267 enum binding_kind.
5268 (binding_cluster::on_unknown_fncall): Drop enum binding_kind.
5269 (binding_cluster::maybe_get_simple_value): Likewise.
5270 (store_manager::get_concrete_binding): Likewise.
5271 (store_manager::get_symbolic_binding): Likewise.
5272 (store::validate): New.
5273 (store::set_value): Drop enum binding_kind.
5274 (store::zero_fill_region): Reimplement in terms of...
5275 (store::fill_region): New.
5276 (selftest::test_binding_key_overlap): Drop enum binding_kind.
5277 * store.h (enum binding_kind): Delete.
5278 (binding_kind_to_string): Delete decl.
5279 (binding_key::make): Drop enum binding_kind.
5280 (binding_key::dump_to_pp): Make pure virtual.
5281 (binding_key::get_kind): Delete.
5282 (binding_key::mark_deleted): Delete.
5283 (binding_key::mark_empty): Delete.
5284 (binding_key::is_deleted): Delete.
5285 (binding_key::is_empty): Delete.
5286 (binding_key::binding_key): Delete.
5287 (binding_key::impl_hash): Delete.
5288 (binding_key::impl_eq): Delete.
5289 (binding_key::m_kind): Delete.
5290 (bit_range::get_last_bit_offset): New.
5291 (bit_range::contains_p): New.
5292 (byte_range::contains_p): New.
5293 (byte_range::operator==): New.
5294 (byte_range::get_start_byte_offset): New.
5295 (byte_range::get_next_byte_offset): New.
5296 (byte_range::get_last_byte_offset): New.
5297 (byte_range::as_bit_range): New.
5298 (byte_range::cmp): New.
5299 (concrete_binding::concrete_binding): Drop enum binding_kind.
5300 (concrete_binding::hash): Likewise.
5301 (concrete_binding::operator==): Likewise.
5302 (concrete_binding::mark_deleted): New.
5303 (concrete_binding::mark_empty): New.
5304 (concrete_binding::is_deleted): New.
5305 (concrete_binding::is_empty): New.
5306 (default_hash_traits<ana::concrete_binding>::empty_zero_p): Make false.
5307 (symbolic_binding::symbolic_binding): Drop enum binding_kind.
5308 (symbolic_binding::hash): Likewise.
5309 (symbolic_binding::operator==): Likewise.
5310 (symbolic_binding::mark_deleted): New.
5311 (symbolic_binding::mark_empty): New.
5312 (symbolic_binding::is_deleted): New.
5313 (symbolic_binding::is_empty): New.
5314 (binding_map::remove_overlapping_bindings): New decl.
5315 (binding_map::get_overlapping_bindings): New decl.
5316 (binding_cluster::validate): New decl.
5317 (binding_cluster::bind): Drop enum binding_kind.
5318 (binding_cluster::fill_region): New decl.
5319 (binding_cluster::get_binding): Drop enum binding_kind.
5320 (binding_cluster::get_binding_recursive): Likewise.
5321 (binding_cluster::get_overlapping_bindings): Delete.
5322 (store::validate): New decl.
5323 (store::set_value): Drop enum binding_kind.
5324 (store::fill_region): New decl.
5325 (store_manager::get_concrete_binding): Drop enum binding_kind.
5326 (store_manager::get_symbolic_binding): Likewise.
5327 * svalue.cc (svalue::cmp_ptr): Handle SK_REPEATED and
5328 SK_BITS_WITHIN.
5329 (svalue::extract_bit_range): New.
5330 (svalue::maybe_fold_bits_within): New.
5331 (constant_svalue::maybe_fold_bits_within): New.
5332 (unknown_svalue::maybe_fold_bits_within): New.
5333 (unaryop_svalue::maybe_fold_bits_within): New.
5334 (repeated_svalue::repeated_svalue): New.
5335 (repeated_svalue::dump_to_pp): New.
5336 (repeated_svalue::accept): New.
5337 (repeated_svalue::all_zeroes_p): New.
5338 (repeated_svalue::maybe_fold_bits_within): New.
5339 (bits_within_svalue::bits_within_svalue): New.
5340 (bits_within_svalue::dump_to_pp): New.
5341 (bits_within_svalue::maybe_fold_bits_within): New.
5342 (bits_within_svalue::accept): New.
5343 (bits_within_svalue::implicitly_live_p): New.
5344 (compound_svalue::maybe_fold_bits_within): New.
5345 * svalue.h (enum svalue_kind): Add SK_REPEATED and SK_BITS_WITHIN.
5346 (svalue::dyn_cast_repeated_svalue): New.
5347 (svalue::dyn_cast_bits_within_svalue): New.
5348 (svalue::extract_bit_range): New decl.
5349 (svalue::maybe_fold_bits_within): New vfunc decl.
5350 (region_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5351 (region_svalue::key_t::is_empty): Likewise.
5352 (default_hash_traits<region_svalue::key_t>::empty_zero_p): Make false.
5353 (constant_svalue::maybe_fold_bits_within): New.
5354 (unknown_svalue::maybe_fold_bits_within): New.
5355 (poisoned_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5356 (poisoned_svalue::key_t::is_empty): Likewise.
5357 (default_hash_traits<poisoned_svalue::key_t>::empty_zero_p): Make
5358 false.
5359 (setjmp_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5360 (setjmp_svalue::key_t::is_empty): Likewise.
5361 (default_hash_traits<setjmp_svalue::key_t>::empty_zero_p): Make
5362 false.
5363 (unaryop_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5364 (unaryop_svalue::key_t::is_empty): Likewise.
5365 (unaryop_svalue::maybe_fold_bits_within): New.
5366 (default_hash_traits<unaryop_svalue::key_t>::empty_zero_p): Make
5367 false.
5368 (binop_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5369 (binop_svalue::key_t::is_empty): Likewise.
5370 (default_hash_traits<binop_svalue::key_t>::empty_zero_p): Make
5371 false.
5372 (sub_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5373 (sub_svalue::key_t::is_empty): Likewise.
5374 (default_hash_traits<sub_svalue::key_t>::empty_zero_p): Make
5375 false.
5376 (class repeated_svalue): New.
5377 (is_a_helper <const repeated_svalue *>::test): New.
5378 (struct default_hash_traits<repeated_svalue::key_t>): New.
5379 (class bits_within_svalue): New.
5380 (is_a_helper <const bits_within_svalue *>::test): New.
5381 (struct default_hash_traits<bits_within_svalue::key_t>): New.
5382 (widening_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5383 (widening_svalue::key_t::is_empty): Likewise.
5384 (default_hash_traits<widening_svalue::key_t>::empty_zero_p): Make
5385 false.
5386 (compound_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
5387 (compound_svalue::key_t::is_empty): Likewise.
5388 (compound_svalue::maybe_fold_bits_within): New.
5389 (default_hash_traits<compound_svalue::key_t>::empty_zero_p): Make
5390 false.
5391
5392 2021-06-28 David Malcolm <dmalcolm@redhat.com>
5393
5394 * analyzer.h (byte_offset_t): New typedef.
5395 * store.cc (bit_range::dump_to_pp): Dump as a byte range if
5396 possible.
5397 (bit_range::as_byte_range): New.
5398 (byte_range::dump_to_pp): New.
5399 * store.h (class byte_range): New forward decl.
5400 (struct bit_range): Add comment.
5401 (bit_range::as_byte_range): New decl.
5402 (struct byte_range): New.
5403
5404 2021-06-22 David Malcolm <dmalcolm@redhat.com>
5405
5406 PR analyzer/101143
5407 * region-model.cc (compat_types_p): New function.
5408 (region_model::create_region_for_heap_alloc): Convert assertion to
5409 an error check.
5410 (region_model::create_region_for_alloca): Likewise.
5411
5412 2021-06-18 David Malcolm <dmalcolm@redhat.com>
5413
5414 * store.cc (binding_cluster::get_any_binding): Make symbolic reads
5415 from a cluster with concrete bindings return unknown.
5416
5417 2021-06-18 David Malcolm <dmalcolm@redhat.com>
5418
5419 * region-model-manager.cc
5420 (region_model_manager::get_or_create_int_cst): New.
5421 (region_model_manager::maybe_undo_optimize_bit_field_compare): Use
5422 it to simplify away a local tree.
5423 * region-model.cc (region_model::on_setjmp): Likewise.
5424 (region_model::on_longjmp): Likewise.
5425 * region-model.h (region_model_manager::get_or_create_int_cst):
5426 New decl.
5427 * store.cc (binding_cluster::zero_fill_region): Use it to simplify
5428 away a local tree.
5429
5430 2021-06-18 David Malcolm <dmalcolm@redhat.com>
5431
5432 * checker-path.cc (class custom_event): Make abstract to allow for
5433 custom vfuncs, splitting existing implementation into...
5434 (class precanned_custom_event): New subclass.
5435 (custom_event::get_desc): Move to...
5436 (precanned_custom_event::get_desc): ...subclass.
5437 * checker-path.h (class custom_event): Make abstract to allow for
5438 custom vfuncs, splitting existing implementation into...
5439 (class precanned_custom_event): New subclass.
5440 * diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
5441 Use precanned_custom_event.
5442 * engine.cc
5443 (stale_jmp_buf::maybe_add_custom_events_for_superedge): Likewise.
5444 * sm-signal.cc (signal_delivery_edge_info_t::add_events_to_path):
5445 Likewise.
5446
5447 2021-06-15 David Malcolm <dmalcolm@redhat.com>
5448
5449 PR analyzer/99212
5450 PR analyzer/101082
5451 * engine.cc: Include "target.h".
5452 (impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
5453 WORDS_BIG_ENDIAN.
5454 * region-model-manager.cc
5455 (region_model_manager::maybe_fold_binop): Move support for masking
5456 via ARG0 & CST into...
5457 (region_model_manager::maybe_undo_optimize_bit_field_compare):
5458 ...this new function. Flatten by converting from nested
5459 conditionals to a series of early return statements to reject
5460 failures. Reject if type is not unsigned_char_type_node.
5461 Handle BYTES_BIG_ENDIAN when determining which bits are bound
5462 in the binding_map.
5463 * region-model.h
5464 (region_model_manager::maybe_undo_optimize_bit_field_compare):
5465 New decl.
5466 * store.cc (bit_range::dump): New function.
5467 * store.h (bit_range::dump): New decl.
5468
5469 2021-06-15 David Malcolm <dmalcolm@redhat.com>
5470
5471 * engine.cc (exploded_node::on_stmt): Handle __analyzer_dump_capacity.
5472 (exploded_node::on_stmt): Drop m_sm_changes from on_stmt_flags.
5473 (state_change_requires_new_enode_p): New function...
5474 (exploded_graph::process_node): Call it, rather than querying
5475 flags.m_sm_changes, so that dynamic-extent differences can also
5476 trigger the splitting of nodes.
5477 * exploded-graph.h (struct on_stmt_flags): Drop field m_sm_changes.
5478 * program-state.cc (program_state::detect_leaks): Purge dead
5479 heap-allocated regions from dynamic extents.
5480 (selftest::test_program_state_1): Fix type of "size_in_bytes".
5481 (selftest::test_program_state_merging): Likewise.
5482 * region-model-impl-calls.cc
5483 (region_model::impl_call_analyzer_dump_capacity): New.
5484 (region_model::impl_call_free): Remove dynamic extents from the
5485 freed region.
5486 * region-model-reachability.h
5487 (reachable_regions::begin_mutable_base_regs): New.
5488 (reachable_regions::end_mutable_base_regs): New.
5489 * region-model.cc: Include "tree-object-size.h".
5490 (region_model::region_model): Support new field m_dynamic_extents.
5491 (region_model::operator=): Likewise.
5492 (region_model::operator==): Likewise.
5493 (region_model::dump_to_pp): Dump sizes of dynamic regions.
5494 (region_model::handle_unrecognized_call): Purge dynamic extents
5495 from any regions that have escaped mutably:.
5496 (region_model::get_capacity): New function.
5497 (region_model::add_constraint): Unset dynamic extents when a
5498 heap-allocated region's address is NULL.
5499 (region_model::unbind_region_and_descendents): Purge dynamic
5500 extents of unbound regions.
5501 (region_model::can_merge_with_p): Call
5502 m_dynamic_extents.can_merge_with_p.
5503 (region_model::create_region_for_heap_alloc): Assert that
5504 size_in_bytes's type is compatible with size_type_node. Update
5505 for renaming of record_dynamic_extents to set_dynamic_extents.
5506 (region_model::create_region_for_alloca): Likewise.
5507 (region_model::record_dynamic_extents): Rename to...
5508 (region_model::set_dynamic_extents): ...this. Assert that
5509 size_in_bytes's type is compatible with size_type_node. Add it
5510 to the m_dynamic_extents map.
5511 (region_model::get_dynamic_extents): New.
5512 (region_model::unset_dynamic_extents): New.
5513 (selftest::test_state_merging): Fix type of "size".
5514 (selftest::test_malloc_constraints): Likewise.
5515 (selftest::test_malloc): Verify dynamic extents.
5516 (selftest::test_alloca): Likewise.
5517 * region-model.h (region_to_value_map::is_empty): New.
5518 (region_model::dynamic_extents_t): New typedef.
5519 (region_model::impl_call_analyzer_dump_capacity): New decl.
5520 (region_model::get_dynamic_extents): New function.
5521 (region_model::get_dynamic_extents): New decl.
5522 (region_model::set_dynamic_extents): New decl.
5523 (region_model::unset_dynamic_extents): New decl.
5524 (region_model::get_capacity): New decl.
5525 (region_model::record_dynamic_extents): Rename to set_dynamic_extents.
5526 (region_model::m_dynamic_extents): New field.
5527
5528 2021-06-15 David Malcolm <dmalcolm@redhat.com>
5529
5530 * region-model.cc (region_to_value_map::operator=): New.
5531 (region_to_value_map::operator==): New.
5532 (region_to_value_map::dump_to_pp): New.
5533 (region_to_value_map::dump): New.
5534 (region_to_value_map::can_merge_with_p): New.
5535 * region-model.h (class region_to_value_map): New class.
5536
5537 2021-06-13 Trevor Saunders <tbsaunde@tbsaunde.org>
5538
5539 * call-string.cc (call_string::call_string): Use range based for
5540 to iterate over vec<>.
5541 (call_string::to_json): Likewise.
5542 (call_string::hash): Likewise.
5543 (call_string::calc_recursion_depth): Likewise.
5544 * checker-path.cc (checker_path::fixup_locations): Likewise.
5545 * constraint-manager.cc (equiv_class::equiv_class): Likewise.
5546 (equiv_class::to_json): Likewise.
5547 (equiv_class::hash): Likewise.
5548 (constraint_manager::to_json): Likewise.
5549 * engine.cc (impl_region_model_context::on_svalue_leak):
5550 Likewise.
5551 (on_liveness_change): Likewise.
5552 (impl_region_model_context::on_unknown_change): Likewise.
5553 * program-state.cc (sm_state_map::set_state): Likewise.
5554 * region-model.cc (test_canonicalization_4): Likewise.
5555
5556 2021-06-11 David Malcolm <dmalcolm@redhat.com>
5557
5558 * engine.cc (worklist::key_t::cmp): Move sort by call_string to
5559 before SCC.
5560
5561 2021-06-09 David Malcolm <dmalcolm@redhat.com>
5562
5563 * region-model.cc (region_model::get_lvalue_1): Make const.
5564 (region_model::get_lvalue): Likewise.
5565 (region_model::get_rvalue_1): Likewise.
5566 (region_model::get_rvalue): Likewise.
5567 (region_model::deref_rvalue): Likewise.
5568 (region_model::get_rvalue_for_bits): Likewise.
5569 * region-model.h (region_model::get_lvalue): Likewise.
5570 (region_model::get_rvalue): Likewise.
5571 (region_model::deref_rvalue): Likewise.
5572 (region_model::get_rvalue_for_bits): Likewise.
5573 (region_model::get_lvalue_1): Likewise.
5574 (region_model::get_rvalue_1): Likewise.
5575
5576 2021-06-08 David Malcolm <dmalcolm@redhat.com>
5577
5578 PR analyzer/99212
5579 * region-model-manager.cc
5580 (region_model_manager::maybe_fold_binop): Add support for folding
5581 BIT_AND_EXPR of compound_svalue and a mask constant.
5582 * region-model.cc (region_model::get_rvalue_1): Implement
5583 BIT_FIELD_REF in terms of...
5584 (region_model::get_rvalue_for_bits): New function.
5585 * region-model.h (region_model::get_rvalue_for_bits): New decl.
5586 * store.cc (bit_range::from_mask): New function.
5587 (selftest::test_bit_range_intersects_p): New selftest.
5588 (selftest::assert_bit_range_from_mask_eq): New.
5589 (ASSERT_BIT_RANGE_FROM_MASK_EQ): New macro.
5590 (selftest::assert_no_bit_range_from_mask_eq): New.
5591 (ASSERT_NO_BIT_RANGE_FROM_MASK): New macro.
5592 (selftest::test_bit_range_from_mask): New selftest.
5593 (selftest::analyzer_store_cc_tests): Call the new selftests.
5594 * store.h (bit_range::intersects_p): New.
5595 (bit_range::from_mask): New decl.
5596 (concrete_binding::get_bit_range): New accessor.
5597 (store_manager::get_concrete_binding): New overload taking
5598 const bit_range &.
5599
5600 2021-06-08 David Malcolm <dmalcolm@redhat.com>
5601
5602 * analyzer.h (int_size_in_bits): New decl.
5603 * region.cc (int_size_in_bits): New function.
5604 (region::get_bit_size): Reimplement in terms of the above.
5605
5606 2021-06-08 David Malcolm <dmalcolm@redhat.com>
5607
5608 * store.cc (concrete_binding::dump_to_pp): Move bulk of
5609 implementation to...
5610 (bit_range::dump_to_pp): ...this new function.
5611 (bit_range::cmp): New.
5612 (concrete_binding::overlaps_p): Update for use of bit_range.
5613 (concrete_binding::cmp_ptr_ptr): Likewise.
5614 * store.h (struct bit_range): New.
5615 (class concrete_binding): Replace fields m_start_bit_offset and
5616 m_size_in_bits with new field m_bit_range.
5617
5618 2021-06-08 David Malcolm <dmalcolm@redhat.com>
5619
5620 * svalue.h (conjured_svalue::iterator_t): Delete.
5621
5622 2021-06-03 David Malcolm <dmalcolm@redhat.com>
5623
5624 * store.h (store::get_direct_binding): Remove unused decl.
5625 (store::get_default_binding): Likewise.
5626
5627 2021-06-03 David Malcolm <dmalcolm@redhat.com>
5628
5629 * svalue.cc (poisoned_svalue::dump_to_pp): Dump type.
5630 (compound_svalue::dump_to_pp): Dump any type.
5631
5632 2021-05-18 David Malcolm <dmalcolm@redhat.com>
5633
5634 PR analyzer/100615
5635 * sm-malloc.cc: Include "analyzer/function-set.h".
5636 (malloc_state_machine::on_stmt): Call unaffected_by_call_p and
5637 bail on the functions it recognizes.
5638 (malloc_state_machine::unaffected_by_call_p): New.
5639
5640 2021-05-10 Martin Liska <mliska@suse.cz>
5641
5642 * sm-file.cc (is_file_using_fn_p): Use startswith
5643 function instead of strncmp.
5644
5645 2021-05-10 Martin Liska <mliska@suse.cz>
5646
5647 * program-state.cc (program_state::operator=): Remove
5648 __cplusplus >= 201103.
5649 (program_state::program_state): Likewise.
5650 * program-state.h: Likewise.
5651 * region-model.h (class region_model): Remove dead code.
5652
5653 2021-04-24 David Malcolm <dmalcolm@redhat.com>
5654
5655 PR analyzer/100244
5656 * sm-malloc.cc (free_of_non_heap::describe_state_change):
5657 Bulletproof against change.m_expr being NULL.
5658
5659 2021-04-13 David Malcolm <dmalcolm@redhat.com>
5660
5661 PR analyzer/98599
5662 * supergraph.cc (saved_uids::make_uid_unique): New.
5663 (saved_uids::restore_uids): New.
5664 (supergraph::supergraph): Replace assignments to stmt->uid with
5665 calls to m_stmt_uids.make_uid_unique.
5666 (supergraph::~supergraph): New.
5667 * supergraph.h (class saved_uids): New.
5668 (supergraph::~supergraph): New decl.
5669 (supergraph::m_stmt_uids): New field.
5670
5671 2021-04-10 David Malcolm <dmalcolm@redhat.com>
5672
5673 PR analyzer/100011
5674 * region-model.cc (region_model::on_assignment): Avoid NULL
5675 dereference if ctxt is NULL when assigning from a STRING_CST.
5676
5677 2021-04-08 David Malcolm <dmalcolm@redhat.com>
5678
5679 PR analyzer/99042
5680 PR analyzer/99774
5681 * engine.cc
5682 (impl_region_model_context::impl_region_model_context): Add
5683 uncertainty param and use it to initialize m_uncertainty.
5684 (impl_region_model_context::get_uncertainty): New.
5685 (impl_sm_context::get_fndecl_for_call): Add NULL for new
5686 uncertainty param when constructing impl_region_model_context.
5687 (impl_sm_context::get_state): Likewise.
5688 (impl_sm_context::set_next_state): Likewise.
5689 (impl_sm_context::warn): Likewise.
5690 (exploded_node::on_stmt): Add uncertainty param
5691 and use it when constructing impl_region_model_context.
5692 (exploded_node::on_edge): Add uncertainty param and pass
5693 to on_edge call.
5694 (exploded_node::detect_leaks): Create uncertainty_t and pass to
5695 impl_region_model_context.
5696 (exploded_graph::get_or_create_node): Create uncertainty_t and
5697 pass to prune_for_point.
5698 (maybe_process_run_of_before_supernode_enodes): Create
5699 uncertainty_t and pass to impl_region_model_context.
5700 (exploded_graph::process_node): Create uncertainty_t instances and
5701 pass around as needed.
5702 * exploded-graph.h
5703 (impl_region_model_context::impl_region_model_context): Add
5704 uncertainty param.
5705 (impl_region_model_context::get_uncertainty): New decl.
5706 (impl_region_model_context::m_uncertainty): New field.
5707 (exploded_node::on_stmt): Add uncertainty param.
5708 (exploded_node::on_edge): Likewise.
5709 * program-state.cc (sm_state_map::on_liveness_change): Get
5710 uncertainty from context and use it to unset sm-state from
5711 svalues as appropriate.
5712 (program_state::on_edge): Add uncertainty param and use it when
5713 constructing impl_region_model_context. Fix indentation.
5714 (program_state::prune_for_point): Add uncertainty param and use it
5715 when constructing impl_region_model_context.
5716 (program_state::detect_leaks): Get any uncertainty from ctxt and
5717 use it to get maybe-live svalues for dest_state, rather than
5718 definitely-live ones; use this when determining which svalues
5719 have leaked.
5720 (selftest::test_program_state_merging): Create uncertainty_t and
5721 pass to impl_region_model_context.
5722 * program-state.h (program_state::on_edge): Add uncertainty param.
5723 (program_state::prune_for_point): Likewise.
5724 * region-model-impl-calls.cc (call_details::get_uncertainty): New.
5725 (region_model::impl_call_memcpy): Pass uncertainty to
5726 mark_region_as_unknown call.
5727 (region_model::impl_call_memset): Likewise.
5728 (region_model::impl_call_strcpy): Likewise.
5729 * region-model-reachability.cc (reachable_regions::handle_sval):
5730 Also add sval to m_mutable_svals.
5731 * region-model.cc (region_model::on_assignment): Pass any
5732 uncertainty from ctxt to the store::set_value call.
5733 (region_model::handle_unrecognized_call): Get any uncertainty from
5734 ctxt and use it to record mutable svalues at the unknown call.
5735 (region_model::get_reachable_svalues): Add uncertainty param and
5736 use it to mark any maybe-bound svalues as being reachable.
5737 (region_model::set_value): Pass any uncertainty from ctxt to the
5738 store::set_value call.
5739 (region_model::mark_region_as_unknown): Add uncertainty param and
5740 pass it on to the store::mark_region_as_unknown call.
5741 (region_model::update_for_call_summary): Add uncertainty param and
5742 pass it on to the region_model::mark_region_as_unknown call.
5743 * region-model.h (call_details::get_uncertainty): New decl.
5744 (region_model::get_reachable_svalues): Add uncertainty param.
5745 (region_model::mark_region_as_unknown): Add uncertainty param.
5746 (region_model_context::get_uncertainty): New vfunc.
5747 (noop_region_model_context::get_uncertainty): New vfunc
5748 implementation.
5749 * store.cc (dump_svalue_set): New.
5750 (uncertainty_t::dump_to_pp): New.
5751 (uncertainty_t::dump): New.
5752 (binding_cluster::clobber_region): Pass NULL for uncertainty to
5753 remove_overlapping_bindings.
5754 (binding_cluster::mark_region_as_unknown): Add uncertainty param
5755 and pass it to remove_overlapping_bindings.
5756 (binding_cluster::remove_overlapping_bindings): Add uncertainty param.
5757 Use it to record any svalues that were in clobbered bindings.
5758 (store::set_value): Add uncertainty param. Pass it to
5759 binding_cluster::mark_region_as_unknown when handling symbolic
5760 regions.
5761 (store::mark_region_as_unknown): Add uncertainty param and pass it
5762 to binding_cluster::mark_region_as_unknown.
5763 (store::remove_overlapping_bindings): Add uncertainty param and
5764 pass it to binding_cluster::remove_overlapping_bindings.
5765 * store.h (binding_cluster::mark_region_as_unknown): Add
5766 uncertainty param.
5767 (binding_cluster::remove_overlapping_bindings): Likewise.
5768 (store::set_value): Likewise.
5769 (store::mark_region_as_unknown): Likewise.
5770
5771 2021-04-05 David Malcolm <dmalcolm@redhat.com>
5772
5773 PR analyzer/99906
5774 * analyzer.cc (maybe_reconstruct_from_def_stmt): Fix NULL
5775 dereference on calls with zero arguments.
5776 * sm-malloc.cc (malloc_state_machine::on_stmt): When handling
5777 __attribute__((nonnull)), only call get_diagnostic_tree if the
5778 result will be used.
5779
5780 2021-04-05 David Malcolm <dmalcolm@redhat.com>
5781
5782 PR analyzer/99886
5783 * diagnostic-manager.cc
5784 (diagnostic_manager::prune_interproc_events): Use signed integers
5785 when subtracting one from path->num_events ().
5786 (diagnostic_manager::consolidate_conditions): Likewise. Convert
5787 next_idx to a signed int.
5788
5789 2021-04-01 David Malcolm <dmalcolm@redhat.com>
5790
5791 * diagnostic-manager.cc (diagnostic_manager::add_diagnostic): Make
5792 enode param non-constant, and call add_diagnostic on it. Add
5793 enode index to log message.
5794 (diagnostic_manager::add_diagnostic): Make enode param
5795 non-constant.
5796 * diagnostic-manager.h (diagnostic_manager::add_diagnostic):
5797 Likewise for both decls.
5798 * engine.cc
5799 (impl_region_model_context::impl_region_model_context): Likewise
5800 for enode_for_diag.
5801 (impl_sm_context::impl_sm_context): Likewise.
5802 (impl_sm_context::m_enode_for_diag): Likewise.
5803 (exploded_node::dump_dot): Don't pass the diagnostic manager
5804 to dump_saved_diagnostics.
5805 (exploded_node::dump_saved_diagnostics): Drop param. Iterate
5806 directly through all saved diagnostics for the enode, rather
5807 than all saved diagnostics in the diagnostic_manager and
5808 filtering.
5809 (exploded_node::on_stmt): Make non-const.
5810 (exploded_node::on_edge): Likewise.
5811 (exploded_node::on_longjmp): Likewise.
5812 (exploded_node::detect_leaks): Likewise.
5813 (exploded_graph::get_or_create_node): Make enode_for_diag param
5814 non-const.
5815 (exploded_graph_annotator::print_enode): Iterate
5816 directly through all saved diagnostics for the enode, rather
5817 than all saved diagnostics in the diagnostic_manager and
5818 filtering.
5819 * exploded-graph.h
5820 (impl_region_model_context::impl_region_model_context): Make
5821 enode_for_diag param non-constant.
5822 (impl_region_model_context::m_enode_for_diag): Likewise.
5823 (exploded_node::dump_saved_diagnostics): Drop param.
5824 (exploded_node::on_stmt): Make non-const.
5825 (exploded_node::on_edge): Likewise.
5826 (exploded_node::on_longjmp): Likewise.
5827 (exploded_node::detect_leaks): Likewise.
5828 (exploded_node::add_diagnostic): New.
5829 (exploded_node::get_num_diagnostics): New.
5830 (exploded_node::get_saved_diagnostic): New.
5831 (exploded_node::m_saved_diagnostics): New.
5832 (exploded_graph::get_or_create_node): Make enode_for_diag param
5833 non-constant.
5834 * feasible-graph.cc (feasible_node::dump_dot): Drop
5835 diagnostic_manager from call to dump_saved_diagnostics.
5836 * program-state.cc (program_state::on_edge): Convert enode param
5837 to non-const pointer.
5838 (program_state::prune_for_point): Likewise for enode_for_diag
5839 param.
5840 * program-state.h (program_state::on_edge): Convert enode param
5841 to non-const pointer.
5842 (program_state::prune_for_point): Likewise for enode_for_diag
5843 param.
5844
5845 2021-03-31 David Malcolm <dmalcolm@redhat.com>
5846
5847 PR analyzer/99771
5848 * analyzer.cc (maybe_reconstruct_from_def_stmt): New.
5849 (fixup_tree_for_diagnostic_1): New.
5850 (fixup_tree_for_diagnostic): New.
5851 * analyzer.h (fixup_tree_for_diagnostic): New decl.
5852 * checker-path.cc (call_event::get_desc): Call
5853 fixup_tree_for_diagnostic and use it for the call_with_state call.
5854 (warning_event::get_desc): Likewise for the final_event and
5855 make_label_text calls.
5856 * engine.cc (impl_region_model_context::on_state_leak): Likewise
5857 for the on_leak and add_diagnostic calls.
5858 * region-model.cc (region_model::get_representative_tree):
5859 Likewise for the result.
5860
5861 2021-03-30 David Malcolm <dmalcolm@redhat.com>
5862
5863 * region.h (region::dump_to_pp): Remove old decl.
5864
5865 2021-03-30 David Malcolm <dmalcolm@redhat.com>
5866
5867 * sm-file.cc (fileptr_state_machine::on_stmt): Only call
5868 get_diagnostic_tree if the result will be used.
5869 * sm-malloc.cc (malloc_state_machine::on_stmt): Likewise.
5870 (malloc_state_machine::on_deallocator_call): Likewise.
5871 (malloc_state_machine::on_realloc_call): Likewise.
5872 (malloc_state_machine::on_realloc_call): Likewise.
5873 * sm-sensitive.cc
5874 (sensitive_state_machine::warn_for_any_exposure): Likewise.
5875 * sm-taint.cc (taint_state_machine::on_stmt): Likewise.
5876
5877 2021-03-25 David Malcolm <dmalcolm@redhat.com>
5878
5879 PR analyzer/93695
5880 PR analyzer/99044
5881 PR analyzer/99716
5882 * engine.cc (exploded_node::on_stmt): Clear sm-state involving
5883 an SSA name at the def-stmt of that SSA name.
5884 * program-state.cc (sm_state_map::purge_state_involving): New.
5885 * program-state.h (sm_state_map::purge_state_involving): New decl.
5886 * region-model.cc (selftest::test_involves_p): New.
5887 (selftest::analyzer_region_model_cc_tests): Call it.
5888 * svalue.cc (class involvement_visitor): New class
5889 (svalue::involves_p): New.
5890 * svalue.h (svalue::involves_p): New decl.
5891
5892 2021-03-19 David Malcolm <dmalcolm@redhat.com>
5893
5894 PR analyzer/99614
5895 * diagnostic-manager.cc (class epath_finder): Add
5896 DISABLE_COPY_AND_ASSIGN.
5897
5898 2021-03-15 Martin Liska <mliska@suse.cz>
5899
5900 * sm-file.cc (get_file_using_fns): Add missing comma in initializer.
5901
5902 2021-03-11 David Malcolm <dmalcolm@redhat.com>
5903
5904 PR analyzer/96374
5905 * analyzer.opt (-param=analyzer-max-infeasible-edges=): New param.
5906 (fdump-analyzer-feasibility): New flag.
5907 * diagnostic-manager.cc: Include "analyzer/trimmed-graph.h" and
5908 "analyzer/feasible-graph.h".
5909 (epath_finder::epath_finder): Convert m_sep to a pointer and
5910 only create it if !flag_analyzer_feasibility.
5911 (epath_finder::~epath_finder): New.
5912 (epath_finder::m_sep): Convert to a pointer.
5913 (epath_finder::get_best_epath): Add param "diag_idx" and use it
5914 when logging. Rather than finding the shortest path and then
5915 checking feasibility, instead use explore_feasible_paths unless
5916 !flag_analyzer_feasibility, in which case simply use the shortest
5917 path, and note if it is infeasible. Update for m_sep becoming a
5918 pointer.
5919 (class feasible_worklist): New.
5920 (epath_finder::explore_feasible_paths): New.
5921 (epath_finder::process_worklist_item): New.
5922 (class dump_eg_with_shortest_path): New.
5923 (epath_finder::dump_trimmed_graph): New.
5924 (epath_finder::dump_feasible_graph): New.
5925 (saved_diagnostic::saved_diagnostic): Add "idx" param, using it
5926 on new field m_idx.
5927 (saved_diagnostic::to_json): Dump m_idx.
5928 (saved_diagnostic::calc_best_epath): Pass m_idx to get_best_epath.
5929 Remove assertion that m_problem was set when m_best_epath is NULL.
5930 (diagnostic_manager::add_diagnostic): Pass an index when created
5931 saved_diagnostic instances.
5932 * diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Add
5933 "idx" param.
5934 (saved_diagnostic::get_index): New accessor.
5935 (saved_diagnostic::m_idx): New field.
5936 * engine.cc (exploded_node::dump_dot): Call args.dump_extra_info.
5937 Move code to...
5938 (exploded_node::dump_processed_stmts): ...this new function and...
5939 (exploded_node::dump_saved_diagnostics): ...this new function.
5940 Add index of each diagnostic.
5941 (exploded_edge::dump_dot): Move bulk of code to...
5942 (exploded_edge::dump_dot_label): ...this new function.
5943 * exploded-graph.h (eg_traits::dump_args_t::dump_extra_info): New
5944 vfunc.
5945 (exploded_node::dump_processed_stmts): New decl.
5946 (exploded_node::dump_saved_diagnostics): New decl.
5947 (exploded_edge::dump_dot_label): New decl.
5948 * feasible-graph.cc: New file.
5949 * feasible-graph.h: New file.
5950 * trimmed-graph.cc: New file.
5951 * trimmed-graph.h: New file.
5952
5953 2021-03-11 David Malcolm <dmalcolm@redhat.com>
5954
5955 * diagnostic-manager.cc (epath_finder::epath_finder):
5956 Update shortest_paths init for new param.
5957
5958 2021-03-10 David Malcolm <dmalcolm@redhat.com>
5959
5960 PR analyzer/96374
5961 * engine.cc (exploded_path::feasible_p): Move "snodes_visited" and
5962 "model" locals into a new class feasibility_state. Move heart
5963 of per-edge processing into
5964 feasibility_state::maybe_update_for_edge.
5965 (feasibility_state::feasibility_state): New.
5966 (feasibility_state::maybe_update_for_edge): New, based on loop
5967 body in exploded_path::feasible_p.
5968 * exploded-graph.h (class feasibility_state): New.
5969
5970 2021-03-10 David Malcolm <dmalcolm@redhat.com>
5971
5972 * supergraph.h
5973 (callgraph_superedge::dyn_cast_callgraph_superedge): New.
5974 (call_superedge::dyn_cast_callgraph_superedge): Delete.
5975 (return_superedge::dyn_cast_callgraph_superedge): Delete.
5976
5977 2021-03-02 Martin Liska <mliska@suse.cz>
5978
5979 * diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostics):
5980 Do not pass engine.
5981
5982 2021-02-26 David Malcolm <dmalcolm@redhat.com>
5983
5984 * engine.cc (exploded_path::exploded_path): New copy-ctor.
5985 * exploded-graph.h (exploded_path::operator=): Drop decl.
5986
5987 2021-02-26 David Malcolm <dmalcolm@redhat.com>
5988
5989 PR analyzer/96374
5990 * diagnostic-manager.cc (class epath_finder): New.
5991 (epath_finder::get_best_epath): New.
5992 (saved_diagnostic::saved_diagnostic): Update for replacement of
5993 m_state and m_epath_length with m_best_epath.
5994 (saved_diagnostic::~saved_diagnostic): Delete m_best_epath.
5995 (saved_diagnostic::to_json): Update "path_length" to be optional.
5996 (saved_diagnostic::calc_best_epath): New, based on
5997 dedupe_winners::add and parts of dedupe_key::dedupe_key.
5998 (saved_diagnostic::get_epath_length): New.
5999 (saved_diagnostic::add_duplicate): New.
6000 (dedupe_key::dedupe_key): Drop epath param. Move invocation of
6001 stmt_finder to saved_diagnostic::calc_best_epath.
6002 (class dedupe_candidate): Delete.
6003 (class dedupe_hash_map_traits): Update to use saved_diagnotic *
6004 rather than dedupe_candidate * as the value_type/compare_type.
6005 (dedupe_winners::~dedupe_winners): Don't delete the values.
6006 (dedupe_winners::add): Convert param from shortest_exploded_paths to
6007 epath_finder. Drop "eg" param. Drop dedupe_candidate, moving
6008 path generation and feasiblity checking to
6009 epath_finder::get_best_epath. Update winner-selection for move
6010 of epaths from dedupe_candidate to saved_diagnostic.
6011 (dedupe_winners::emit_best): Update for removal of class
6012 dedupe_candidate.
6013 (dedupe_winners::map_t): Update to use saved_diagnotic * rather
6014 than dedupe_candidate * as the value_type/compare_type.
6015 (diagnostic_manager::emit_saved_diagnostics): Move
6016 shortest_exploded_paths instance into epath_finder and pass that
6017 around instead.
6018 (diagnostic_manager::emit_saved_diagnostic): Drop epath, stmt
6019 and num_dupes params, instead getting these from the
6020 saved_diagnostic. Use correct location in inform_n call.
6021 * diagnostic-manager.h (class epath_finder): New forward decl.
6022 (saved_diagnostic::status): Drop enum.
6023 (saved_diagnostic::set_feasible): Drop.
6024 (saved_diagnostic::set_infeasible): Drop.
6025 (saved_diagnostic::get_status): Drop.
6026 (saved_diagnostic::calc_best_epath): New decl.
6027 (saved_diagnostic::get_best_epath): New decl.
6028 (saved_diagnostic::get_epath_length): New decl.
6029 (saved_diagnostic::set_epath_length): Drop.
6030 (saved_diagnostic::get_epath_length): Drop inline implementation.
6031 (saved_diagnostic::add_duplicate): New.
6032 (saved_diagnostic::get_num_dupes): New.
6033 (saved_diagnostic::m_d): Document ownership.
6034 (saved_diagnostic::m_trailing_eedge): Make const.
6035 (saved_diagnostic::m_status): Drop field.
6036 (saved_diagnostic::m_epath_length): Drop field.
6037 (saved_diagnostic::m_best_epath): New field.
6038 (saved_diagnostic::m_problem): Document ownership.
6039 (saved_diagnostic::m_duplicates): New field.
6040 (diagnostic_manager::emit_saved_diagnostic): Drop params epath,
6041 stmt, and num_dupes.
6042 * engine.cc (exploded_graph_annotator::print_saved_diagnostic):
6043 Update for changes to saved_diagnostic class.
6044 * exploded-graph.h (exploded_path::feasible_p): Drop unused
6045 overloaded decl.
6046
6047 2021-02-25 David Malcolm <dmalcolm@redhat.com>
6048
6049 PR analyzer/99193
6050 * region-model-impl-calls.cc (region_model::impl_call_realloc): New.
6051 * region-model.cc (region_model::on_call_pre): Call it.
6052 * region-model.h (region_model::impl_call_realloc): New decl.
6053 * sm-malloc.cc (enum wording): Add WORDING_REALLOCATED.
6054 (malloc_state_machine::m_realloc): New field.
6055 (use_after_free::describe_state_change): Add case for
6056 WORDING_REALLOCATED.
6057 (use_after_free::describe_final_event): Likewise.
6058 (malloc_state_machine::malloc_state_machine): Initialize
6059 m_realloc.
6060 (malloc_state_machine::on_stmt): Handle realloc by calling...
6061 (malloc_state_machine::on_realloc_call): New.
6062
6063 2021-02-22 David Malcolm <dmalcolm@redhat.com>
6064
6065 PR analyzer/99196
6066 * engine.cc (exploded_node::on_stmt): Provide terminate_path
6067 flag as a way for on_call_pre to terminate the current analysis
6068 path.
6069 * region-model-impl-calls.cc (call_details::num_args): New.
6070 (region_model::impl_call_error): New.
6071 * region-model.cc (region_model::on_call_pre): Add param
6072 "out_terminate_path". Handle "error" and "error_at_line".
6073 * region-model.h (call_details::num_args): New decl.
6074 (region_model::on_call_pre): Add param "out_terminate_path".
6075 (region_model::impl_call_error): New decl.
6076
6077 2021-02-17 David Malcolm <dmalcolm@redhat.com>
6078
6079 PR analyzer/98969
6080 * constraint-manager.cc (dead_svalue_purger::should_purge_p):
6081 Update for change to svalue::live_p.
6082 * program-state.cc (sm_state_map::on_liveness_change): Likewise.
6083 (program_state::detect_leaks): Likewise.
6084 * region-model-reachability.cc (reachable_regions::init_cluster):
6085 When dealing with a symbolic region, if the underlying pointer is
6086 implicitly live, add the region to the reachable regions.
6087 * region-model.cc (region_model::compare_initial_and_pointer):
6088 Move logic for detecting initial values of params to
6089 initial_svalue::initial_value_of_param_p.
6090 * svalue.cc (svalue::live_p): Convert "live_svalues" from a
6091 reference to a pointer; support it being NULL.
6092 (svalue::implicitly_live_p): Convert first param from a
6093 refererence to a pointer.
6094 (region_svalue::implicitly_live_p): Likewise.
6095 (constant_svalue::implicitly_live_p): Likewise.
6096 (initial_svalue::implicitly_live_p): Likewise. Treat the initial
6097 values of params for the top level frame as still live.
6098 (initial_svalue::initial_value_of_param_p): New function, taken
6099 from a test in region_model::compare_initial_and_pointer.
6100 (unaryop_svalue::implicitly_live_p): Convert first param from a
6101 refererence to a pointer.
6102 (binop_svalue::implicitly_live_p): Likewise.
6103 (sub_svalue::implicitly_live_p): Likewise.
6104 (unmergeable_svalue::implicitly_live_p): Likewise.
6105 * svalue.h (svalue::live_p): Likewise.
6106 (svalue::implicitly_live_p): Likewise.
6107 (region_svalue::implicitly_live_p): Likewise.
6108 (constant_svalue::implicitly_live_p): Likewise.
6109 (initial_svalue::implicitly_live_p): Likewise.
6110 (initial_svalue::initial_value_of_param_p): New decl.
6111 (unaryop_svalue::implicitly_live_p): Convert first param from a
6112 refererence to a pointer.
6113 (binop_svalue::implicitly_live_p): Likewise.
6114 (sub_svalue::implicitly_live_p): Likewise.
6115 (unmergeable_svalue::implicitly_live_p): Likewise.
6116
6117 2021-02-12 David Malcolm <dmalcolm@redhat.com>
6118
6119 PR analyzer/98969
6120 * engine.cc (readability): Add names for the various arbitrary
6121 values. Handle NOP_EXPR and INTEGER_CST.
6122 (readability_comparator): Combine the readability tests for
6123 tree and stack depth, rather than performing them sequentially.
6124 (impl_region_model_context::on_state_leak): Strip off top-level
6125 casts.
6126 * region-model.cc (region_model::get_representative_path_var): Add
6127 type-checking, moving the bulk of the implementation to...
6128 (region_model::get_representative_path_var_1): ...here. Respect
6129 types in casts by recursing and re-adding the cast, rather than
6130 merely stripping them off. Use the correct type when handling
6131 region_svalue.
6132 (region_model::get_representative_tree): Strip off any top-level
6133 cast.
6134 (region_model::get_representative_path_var): Add type-checking,
6135 moving the bulk of the implementation to...
6136 (region_model::get_representative_path_var_1): ...here.
6137 * region-model.h (region_model::get_representative_path_var_1):
6138 New decl
6139 (region_model::get_representative_path_var_1): New decl.
6140 * store.cc (append_pathvar_with_type): New.
6141 (binding_cluster::get_representative_path_vars): Cast path_vars
6142 to the correct type when adding them to *OUT_PVS.
6143
6144 2021-02-09 David Malcolm <dmalcolm@redhat.com>
6145
6146 PR analyzer/98575
6147 * sm-file.cc (is_file_using_fn_p): Support "_IO_"-prefixed
6148 variants.
6149
6150 2021-02-09 David Malcolm <dmalcolm@redhat.com>
6151
6152 PR analyzer/98575
6153 * store.cc (store::set_value): Treat a pointer written to *UNKNOWN
6154 as having escaped.
6155
6156 2021-02-02 David Malcolm <dmalcolm@redhat.com>
6157
6158 PR analyzer/93355
6159 PR analyzer/96374
6160 * engine.cc (toplevel_function_p): Simplify so that
6161 we only reject functions with a "__analyzer_" prefix.
6162 (add_any_callbacks): Delete.
6163 (exploded_graph::build_initial_worklist): Update for
6164 dropped param of toplevel_function_p.
6165 (exploded_graph::build_initial_worklist): Don't bother
6166 looking for callbacks that are reachable from global
6167 initializers.
6168
6169 2021-02-01 David Malcolm <dmalcolm@redhat.com>
6170
6171 PR analyzer/98918
6172 * region-model-manager.cc
6173 (region_model_manager::get_or_create_initial_value):
6174 Fold the initial value of *UNKNOWN_PTR to an UNKNOWN value.
6175 (region_model_manager::get_field_region): Fold the value
6176 of UNKNOWN_PTR->FIELD to *UNKNOWN_PTR_OF_&FIELD_TYPE.
6177
6178 2021-01-29 David Malcolm <dmalcolm@redhat.com>
6179
6180 * checker-path.cc (event_kind_to_string): Handle
6181 EK_START_CONSOLIDATED_CFG_EDGES and
6182 EK_END_CONSOLIDATED_CFG_EDGES.
6183 (start_consolidated_cfg_edges_event::get_desc): New.
6184 (checker_path::cfg_edge_pair_at_p): New.
6185 * checker-path.h (enum event_kind): Add
6186 EK_START_CONSOLIDATED_CFG_EDGES and
6187 EK_END_CONSOLIDATED_CFG_EDGES.
6188 (class start_consolidated_cfg_edges_event): New class.
6189 (class end_consolidated_cfg_edges_event): New class.
6190 (checker_path::delete_events): New.
6191 (checker_path::replace_event): New.
6192 (checker_path::cfg_edge_pair_at_p): New decl.
6193 * diagnostic-manager.cc (diagnostic_manager::prune_path): Call
6194 consolidate_conditions.
6195 (same_line_as_p): New.
6196 (diagnostic_manager::consolidate_conditions): New.
6197 * diagnostic-manager.h
6198 (diagnostic_manager::consolidate_conditions): New decl.
6199
6200 2021-01-18 David Malcolm <dmalcolm@redhat.com>
6201
6202 * analyzer.h (is_std_named_call_p): New decl.
6203 * diagnostic-manager.cc (path_builder::get_sm): New.
6204 (state_change_event_creator::state_change_event_creator): Add "pb"
6205 param.
6206 (state_change_event_creator::on_global_state_change): Don't consider
6207 state changes affecting other state_machines.
6208 (state_change_event_creator::on_state_change): Likewise.
6209 (state_change_event_creator::m_pb): New field.
6210 (diagnostic_manager::add_events_for_eedge): Pass pb to visitor
6211 ctor.
6212 * region-model-impl-calls.cc
6213 (region_model::impl_deallocation_call): New.
6214 * region-model.cc: Include "attribs.h".
6215 (region_model::on_call_post): Handle fndecls referenced by
6216 __attribute__((deallocated_by(FOO))).
6217 * region-model.h (region_model::impl_deallocation_call): New decl.
6218 * sm-malloc.cc: Include "stringpool.h" and "attribs.h". Add
6219 leading comment.
6220 (class api): Delete.
6221 (enum resource_state): Update comment for change from api to
6222 deallocator and deallocator_set.
6223 (allocation_state::allocation_state): Drop api param. Add
6224 "deallocators" and "deallocator".
6225 (allocation_state::m_api): Drop field in favor of...
6226 (allocation_state::m_deallocators): New field.
6227 (allocation_state::m_deallocator): New field.
6228 (enum wording): Add WORDING_DEALLOCATED.
6229 (struct deallocator): New.
6230 (struct standard_deallocator): New.
6231 (struct custom_deallocator): New.
6232 (struct deallocator_set): New.
6233 (struct custom_deallocator_set): New.
6234 (struct standard_deallocator_set): New.
6235 (struct deallocator_set_map_traits): New.
6236 (malloc_state_machine::m_malloc): Drop field
6237 (malloc_state_machine::m_scalar_new): Likewise.
6238 (malloc_state_machine::m_vector_new): Likewise.
6239 (malloc_state_machine::m_free): New field
6240 (malloc_state_machine::m_scalar_delete): Likewise.
6241 (malloc_state_machine::m_vector_delete): Likewise.
6242 (malloc_state_machine::deallocator_map_t): New typedef.
6243 (malloc_state_machine::m_deallocator_map): New field.
6244 (malloc_state_machine::deallocator_set_cache_t): New typedef.
6245 (malloc_state_machine::m_custom_deallocator_set_cache): New field.
6246 (malloc_state_machine::custom_deallocator_set_map_t): New typedef.
6247 (malloc_state_machine::m_custom_deallocator_set_map): New field.
6248 (malloc_state_machine::m_dynamic_sets): New field.
6249 (malloc_state_machine::m_dynamic_deallocators): New field.
6250 (api::api): Delete.
6251 (deallocator::deallocator): New ctor.
6252 (deallocator::hash): New.
6253 (deallocator::dump_to_pp): New.
6254 (deallocator::cmp): New.
6255 (deallocator::cmp_ptr_ptr): New.
6256 (standard_deallocator::standard_deallocator): New ctor.
6257 (deallocator_set::deallocator_set): New ctor.
6258 (deallocator_set::dump): New.
6259 (custom_deallocator_set::custom_deallocator_set): New ctor.
6260 (custom_deallocator_set::contains_p): New.
6261 (custom_deallocator_set::maybe_get_single): New.
6262 (custom_deallocator_set::dump_to_pp): New.
6263 (standard_deallocator_set::standard_deallocator_set): New ctor.
6264 (standard_deallocator_set::contains_p): New.
6265 (standard_deallocator_set::maybe_get_single): New.
6266 (standard_deallocator_set::dump_to_pp): New.
6267 (start_p): New.
6268 (class mismatching_deallocation): Update for conversion from api
6269 to deallocator_set and deallocator.
6270 (double_free::emit): Use %qs.
6271 (class use_after_free): Update for conversion from api to
6272 deallocator_set and deallocator.
6273 (malloc_leak::describe_state_change): Only emit "allocated here" on
6274 a start->nonnull transition, rather than on other transitions to
6275 nonnull.
6276 (allocation_state::dump_to_pp): Update for conversion from api to
6277 deallocator_set.
6278 (allocation_state::get_nonnull): Likewise.
6279 (malloc_state_machine::malloc_state_machine): Likewise.
6280 (malloc_state_machine::~malloc_state_machine): New.
6281 (malloc_state_machine::add_state): Update for conversion from api
6282 to deallocator_set.
6283 (malloc_state_machine::get_or_create_custom_deallocator_set): New.
6284 (malloc_state_machine::maybe_create_custom_deallocator_set): New.
6285 (malloc_state_machine::get_or_create_deallocator): New.
6286 (malloc_state_machine::on_stmt): Update for conversion from api
6287 to deallocator_set. Handle "__attribute__((malloc(FOO)))", and
6288 the special attribute set on FOO.
6289 (malloc_state_machine::on_allocator_call): Update for conversion
6290 from api to deallocator_set. Add "returns_nonnull" param and use
6291 it to affect which state to transition to.
6292 (malloc_state_machine::on_deallocator_call): Update for conversion
6293 from api to deallocator_set.
6294
6295 2021-01-14 David Malcolm <dmalcolm@redhat.com>
6296
6297 * engine.cc (strongly_connected_components::to_json): New.
6298 (worklist::to_json): New.
6299 (exploded_graph::to_json): JSON-ify the worklist.
6300 * exploded-graph.h (strongly_connected_components::to_json): New
6301 decl.
6302 (worklist::to_json): New decl.
6303 * store.cc (store::to_json): Fix comment.
6304 * supergraph.cc (supernode::to_json): Fix reference to
6305 "returning_call" in comment. Add optional "fun" to JSON.
6306 (edge_kind_to_string): New.
6307 (superedge::to_json): Add "kind" to JSON.
6308
6309 2021-01-14 David Malcolm <dmalcolm@redhat.com>
6310
6311 PR analyzer/98679
6312 * analyzer.h (region_offset::operator==): Make const.
6313 * pending-diagnostic.h (pending_diagnostic::equal_p): Likewise.
6314 * store.h (binding_cluster::for_each_value): Likewise.
6315 (binding_cluster::for_each_binding): Likewise.
6316
6317 2021-01-12 David Malcolm <dmalcolm@redhat.com>
6318
6319 PR analyzer/98628
6320 * store.cc (binding_cluster::make_unknown_relative_to): Don't mark
6321 dereferenced unknown pointers as having escaped.
6322
6323 2021-01-07 David Malcolm <dmalcolm@redhat.com>
6324
6325 PR analyzer/98580
6326 * region.cc (decl_region::get_svalue_for_initializer): Gracefully
6327 handle when LTO writes out DECL_INITIAL as error_mark_node.
6328
6329 2021-01-07 David Malcolm <dmalcolm@redhat.com>
6330
6331 PR analyzer/97074
6332 * store.cc (binding_cluster::can_merge_p): Add "out_store" param
6333 and pass to calls to binding_cluster::make_unknown_relative_to.
6334 (binding_cluster::make_unknown_relative_to): Add "out_store"
6335 param. Use it to mark base regions that are pointed to by
6336 pointers that become unknown as having escaped.
6337 (store::can_merge_p): Pass out_store to
6338 binding_cluster::can_merge_p.
6339 * store.h (binding_cluster::can_merge_p): Add "out_store" param.
6340 (binding_cluster::make_unknown_relative_to): Likewise.
6341 * svalue.cc (region_svalue::implicitly_live_p): New vfunc.
6342 * svalue.h (region_svalue::implicitly_live_p): New vfunc decl.
6343
6344 2021-01-07 David Malcolm <dmalcolm@redhat.com>
6345
6346 PR analyzer/98564
6347 * engine.cc (exploded_path::feasible_p): Add missing call to
6348 bitmap_clear.
6349
6350 2021-01-06 David Malcolm <dmalcolm@redhat.com>
6351
6352 PR analyzer/97072
6353 * region-model-reachability.cc (reachable_regions::init_cluster):
6354 Convert symbolic region handling to a switch statement. Add cases
6355 to handle SK_UNKNOWN and SK_CONJURED.
6356
6357 2021-01-05 David Malcolm <dmalcolm@redhat.com>
6358
6359 PR analyzer/98293
6360 * store.cc (binding_map::apply_ctor_to_region): When "index" is
6361 NULL, iterate through the fields for RECORD_TYPEs, rather than
6362 creating an INTEGER_CST index.
6363
6364 2020-11-30 David Malcolm <dmalcolm@redhat.com>
6365
6366 * analyzer-pass.cc: Include "analyzer/analyzer.h" for the
6367 declaration of sorry_no_analyzer; include "tree.h" and
6368 "function.h" as these are needed by it.
6369
6370 2020-11-30 David Malcolm <dmalcolm@redhat.com>
6371
6372 * analyzer-pass.cc (pass_analyzer::execute): Move sorry call to...
6373 (sorry_no_analyzer): New.
6374 * analyzer.h (class state_machine): New forward decl.
6375 (class logger): New forward decl.
6376 (class plugin_analyzer_init_iface): New.
6377 (sorry_no_analyzer): New decl.
6378 * checker-path.cc (checker_path::fixup_locations): New.
6379 * checker-path.h (checker_event::set_location): New.
6380 (checker_path::fixup_locations): New decl.
6381 * diagnostic-manager.cc
6382 (diagnostic_manager::emit_saved_diagnostic): Call
6383 checker_path::fixup_locations, and call fixup_location
6384 on the primary location.
6385 * engine.cc: Include "plugin.h".
6386 (class plugin_analyzer_init_impl): New.
6387 (impl_run_checkers): Invoke PLUGIN_ANALYZER_INIT callbacks.
6388 * pending-diagnostic.h (pending_diagnostic::fixup_location): New
6389 vfunc.
6390
6391 2020-11-18 David Malcolm <dmalcolm@redhat.com>
6392
6393 PR analyzer/97893
6394 * sm-malloc.cc (null_deref::emit): Use CWE-476 rather than
6395 CWE-690, as this isn't due to an unchecked return value.
6396 (null_arg::emit): Likewise.
6397
6398 2020-11-12 David Malcolm <dmalcolm@redhat.com>
6399
6400 * checker-path.h (checker_event::get_id_ptr): New.
6401 * diagnostic-manager.cc (path_builder::path_builder): Add "sd"
6402 param and use it to initialize new field "m_sd".
6403 (path_builder::get_pending_diagnostic): New.
6404 (path_builder::m_sd): New field.
6405 (diagnostic_manager::emit_saved_diagnostic): Pass sd to
6406 path_builder ctor.
6407 (diagnostic_manager::add_events_for_superedge): Call new
6408 maybe_add_custom_events_for_superedge vfunc.
6409 * engine.cc (stale_jmp_buf::stale_jmp_buf): Add "setjmp_point"
6410 param and use it to initialize new field "m_setjmp_point".
6411 Initialize new field "m_stack_pop_event".
6412 (stale_jmp_buf::maybe_add_custom_events_for_superedge): New vfunc
6413 implementation.
6414 (stale_jmp_buf::describe_final_event): New vfunc implementation.
6415 (stale_jmp_buf::m_setjmp_point): New field.
6416 (stale_jmp_buf::m_stack_pop_event): New field.
6417 (exploded_node::on_longjmp): Pass setjmp_point to stale_jmp_buf
6418 ctor.
6419 * pending-diagnostic.h
6420 (pending_diagnostic::maybe_add_custom_events_for_superedge): New
6421 vfunc.
6422
6423 2020-11-12 David Malcolm <dmalcolm@redhat.com>
6424
6425 PR tree-optimization/97424
6426 * analyzer.opt (Wanalyzer-shift-count-negative): New.
6427 (Wanalyzer-shift-count-overflow): New.
6428 * region-model.cc (class shift_count_negative_diagnostic): New.
6429 (class shift_count_overflow_diagnostic): New.
6430 (region_model::get_gassign_result): Complain about shift counts that
6431 are negative or are >= the operand's type's width.
6432
6433 2020-11-10 Martin Liska <mliska@suse.cz>
6434
6435 * constraint-manager.cc (constraint_manager::merge): Remove
6436 unused code.
6437 * constraint-manager.h: Likewise.
6438 * program-state.cc (sm_state_map::sm_state_map): Likewise.
6439 (program_state::program_state): Likewise.
6440 (test_sm_state_map): Likewise.
6441 * program-state.h: Likewise.
6442 * region-model-reachability.cc (reachable_regions::reachable_regions): Likewise.
6443 * region-model-reachability.h: Likewise.
6444 * region-model.cc (region_model::handle_unrecognized_call): Likewise.
6445 (region_model::get_reachable_svalues): Likewise.
6446 (region_model::can_merge_with_p): Likewise.
6447
6448 2020-11-05 David Malcolm <dmalcolm@redhat.com>
6449
6450 PR analyzer/97668
6451 * svalue.cc (cmp_cst): Handle COMPLEX_CST.
6452
6453 2020-10-29 David Malcolm <dmalcolm@redhat.com>
6454
6455 * program-state.cc (sm_state_map::on_liveness_change): Sort the
6456 leaking svalues before calling on_state_leak.
6457 (program_state::detect_leaks): Likewise when calling
6458 on_svalue_leak.
6459 * region-model-reachability.cc
6460 (reachable_regions::mark_escaped_clusters): Likewise when
6461 calling on_escaped_function.
6462
6463 2020-10-29 David Malcolm <dmalcolm@redhat.com>
6464
6465 PR analyzer/97608
6466 * region-model-reachability.cc (reachable_regions::handle_sval):
6467 Operands of reachable reversible operations are reachable.
6468
6469 2020-10-29 David Malcolm <dmalcolm@redhat.com>
6470
6471 * analyzer.h (class state_machine): New forward decl.
6472 (class logger): Likewise.
6473 (class visitor): Likewise.
6474 * complexity.cc: New file, taken from svalue.cc.
6475 * complexity.h: New file, taken from region-model.h.
6476 * region-model.h: Include "analyzer/svalue.h" and
6477 "analyzer/region.h". Move struct complexity to complexity.h.
6478 Move svalue, its subclasses and supporting decls to svalue.h.
6479 Move region, its subclasses and supporting decls to region.h.
6480 * region.cc: Include "analyzer/region.h".
6481 (symbolic_region::symbolic_region): Move here from region-model.h.
6482 * region.h: New file, based on material from region-model.h.
6483 * svalue.cc: Include "analyzer/svalue.h".
6484 (complexity::complexity): Move to complexity.cc.
6485 (complexity::from_pair): Likewise.
6486 * svalue.h: New file, based on material from region-model.h.
6487
6488 2020-10-29 David Malcolm <dmalcolm@redhat.com>
6489
6490 * program-state.cc (sm_state_map::print): Guard the printing of
6491 the origin pointer with !flag_dump_noaddr.
6492 * region.cc (string_region::dump_to_pp): Likewise for
6493 m_string_cst.
6494
6495 2020-10-27 David Malcolm <dmalcolm@redhat.com>
6496
6497 PR analyzer/97568
6498 * region-model.cc (region_model::get_initial_value_for_global):
6499 Move check that !DECL_EXTERNAL from here to...
6500 * region.cc (decl_region::get_svalue_for_initializer): ...here,
6501 using it to reject zero initialization.
6502
6503 2020-10-27 Markus Böck <markus.boeck02@gmail.com>
6504
6505 PR analyzer/96608
6506 * store.h (hash): Cast to intptr_t instead of long
6507
6508 2020-10-27 David Malcolm <dmalcolm@redhat.com>
6509
6510 * constraint-manager.cc (svalue_cmp_by_ptr): Delete.
6511 (equiv_class::canonicalize): Use svalue::cmp_ptr_ptr instead.
6512 (equiv_class_cmp): Eliminate pointer comparison.
6513 * diagnostic-manager.cc (dedupe_key::comparator): If they are at
6514 the same location, also compare epath ength and pending_diagnostic
6515 kind.
6516 * engine.cc (readability_comparator): If two path_vars have the
6517 same readability, then impose an arbitrary ordering on them.
6518 (worklist::key_t::cmp): If two points have the same plan ordering,
6519 continue the comparison. Call sm_state_map::cmp rather than
6520 comparing hash values.
6521 * program-state.cc (sm_state_map::entry_t::cmp): New.
6522 (sm_state_map::cmp): New.
6523 * program-state.h (sm_state_map::entry_t::cmp): New decl.
6524 (sm_state_map::elements): New.
6525 (sm_state_map::cmp): New.
6526
6527 2020-10-27 David Malcolm <dmalcolm@redhat.com>
6528
6529 * engine.cc (setjmp_record::cmp): New.
6530 (supernode_cluster::dump_dot): Avoid embedding pointer in cluster
6531 name.
6532 (supernode_cluster::cmp_ptr_ptr): New.
6533 (function_call_string_cluster::dump_dot): Avoid embedding pointer
6534 in cluster name. Sort m_map when dumping child clusters.
6535 (function_call_string_cluster::cmp_ptr_ptr): New.
6536 (root_cluster::dump_dot): Sort m_map when dumping child clusters.
6537 * program-point.cc (function_point::cmp): New.
6538 (function_point::cmp_ptr): New.
6539 * program-point.h (function_point::cmp): New decl.
6540 (function_point::cmp_ptr): New decl.
6541 * program-state.cc (sm_state_map::print): Sort the values. Guard
6542 the printing of pointers with !flag_dump_noaddr.
6543 (program_state::prune_for_point): Sort the regions.
6544 (log_set_of_svalues): Sort the values. Guard the printing of
6545 pointers with !flag_dump_noaddr.
6546 * region-model-manager.cc (log_uniq_map): Sort the values.
6547 * region-model-reachability.cc (dump_set): New function template.
6548 (reachable_regions::dump_to_pp): Use it.
6549 * region-model.h (svalue::cmp_ptr): New decl.
6550 (svalue::cmp_ptr_ptr): New decl.
6551 (setjmp_record::cmp): New decl.
6552 (placeholder_svalue::get_name): New accessor.
6553 (widening_svalue::get_point): New accessor.
6554 (compound_svalue::get_map): New accessor.
6555 (conjured_svalue::get_stmt): New accessor.
6556 (conjured_svalue::get_id_region): New accessor.
6557 (region::cmp_ptrs): Rename to...
6558 (region::cmp_ptr_ptr): ...this.
6559 * region.cc (region::cmp_ptrs): Rename to...
6560 (region::cmp_ptr_ptr): ...this.
6561 * state-purge.cc
6562 (state_purge_per_ssa_name::state_purge_per_ssa_name): Sort
6563 m_points_needing_name when dumping.
6564 * store.cc (concrete_binding::cmp_ptr_ptr): New.
6565 (symbolic_binding::cmp_ptr_ptr): New.
6566 (binding_map::cmp): New.
6567 (get_sorted_parent_regions): Update for renaming of
6568 region::cmp_ptrs to region::cmp_ptr_ptr.
6569 (store::dump_to_pp): Likewise.
6570 (store::to_json): Likewise.
6571 (store::can_merge_p): Sort the base regions before considering
6572 them.
6573 * store.h (concrete_binding::cmp_ptr_ptr): New decl.
6574 (symbolic_binding::cmp_ptr_ptr): New decl.
6575 (binding_map::cmp): New decl.
6576 * supergraph.cc (supergraph::supergraph): Assign UIDs to the
6577 gimple stmts.
6578 * svalue.cc (cmp_cst): New.
6579 (svalue::cmp_ptr): New.
6580 (svalue::cmp_ptr_ptr): New.
6581
6582 2020-10-27 David Malcolm <dmalcolm@redhat.com>
6583
6584 * engine.cc (exploded_graph::get_or_create_node): Fix off-by-one
6585 when imposing param_analyzer_max_enodes_per_program_point limit.
6586
6587 2020-10-27 David Malcolm <dmalcolm@redhat.com>
6588
6589 * region-model.cc (region_model::get_representative_path_var):
6590 Implement case RK_LABEL.
6591 * region-model.h (label_region::get_label): New accessor.
6592
6593 2020-10-22 David Malcolm <dmalcolm@redhat.com>
6594
6595 PR analyzer/97514
6596 * engine.cc (exploded_graph::add_function_entry): Handle failure
6597 to create an enode, rather than asserting.
6598
6599 2020-10-22 David Malcolm <dmalcolm@redhat.com>
6600
6601 PR analyzer/97489
6602 * engine.cc (exploded_graph::add_function_entry): Assert that we
6603 have a function body.
6604 (exploded_graph::on_escaped_function): Reject fndecls that don't
6605 have a function body.
6606
6607 2020-10-14 David Malcolm <dmalcolm@redhat.com>
6608
6609 PR analyzer/93388
6610 * region-model.cc (region_model::get_initial_value_for_global):
6611 Fall back to returning an initial_svalue if
6612 decl_region::get_svalue_for_initializer fails.
6613 * region.cc (decl_region::get_svalue_for_initializer): Don't
6614 attempt to create a compound_svalue if the region has an unknown
6615 size.
6616
6617 2020-10-14 David Malcolm <dmalcolm@redhat.com>
6618
6619 PR analyzer/93723
6620 * store.cc (binding_map::apply_ctor_to_region): Remove redundant
6621 assertion.
6622
6623 2020-10-12 David Malcolm <dmalcolm@redhat.com>
6624
6625 PR analyzer/97258
6626 * engine.cc (impl_region_model_context::on_escaped_function): New
6627 vfunc.
6628 (exploded_graph::add_function_entry): Use m_functions_with_enodes
6629 to implement idempotency.
6630 (add_any_callbacks): New.
6631 (exploded_graph::build_initial_worklist): Use the above to find
6632 callbacks that are reachable from global initializers.
6633 (exploded_graph::on_escaped_function): New.
6634 * exploded-graph.h
6635 (impl_region_model_context::on_escaped_function): New decl.
6636 (exploded_graph::on_escaped_function): New decl.
6637 (exploded_graph::m_functions_with_enodes): New field.
6638 * region-model-reachability.cc
6639 (reachable_regions::reachable_regions): Replace "store" param with
6640 "model" param; use it to initialize m_model.
6641 (reachable_regions::add): When getting the svalue for the region,
6642 call get_store_value on the model rather than using an initial
6643 value.
6644 (reachable_regions::mark_escaped_clusters): Add ctxt param and
6645 use it to call on_escaped_function when a function_region escapes.
6646 * region-model-reachability.h
6647 (reachable_regions::reachable_regions): Replace "store" param with
6648 "model" param.
6649 (reachable_regions::mark_escaped_clusters): Add ctxt param.
6650 (reachable_regions::m_model): New field.
6651 * region-model.cc (region_model::handle_unrecognized_call): Update
6652 for change in reachable_regions ctor.
6653 (region_model::handle_unrecognized_call): Pass ctxt to
6654 mark_escaped_clusters.
6655 (region_model::get_reachable_svalues): Update for change in
6656 reachable_regions ctor.
6657 (region_model::get_initial_value_for_global): Read-only variables
6658 keep their initial values.
6659 * region-model.h (region_model_context::on_escaped_function): New
6660 vfunc.
6661 (noop_region_model_context::on_escaped_function): New.
6662
6663 2020-10-12 David Malcolm <dmalcolm@redhat.com>
6664
6665 * analyzer.opt (Wanalyzer-write-to-const): New.
6666 (Wanalyzer-write-to-string-literal): New.
6667 * region-model-impl-calls.cc (region_model::impl_call_memcpy):
6668 Call check_for_writable_region.
6669 (region_model::impl_call_memset): Likewise.
6670 (region_model::impl_call_strcpy): Likewise.
6671 * region-model.cc (class write_to_const_diagnostic): New.
6672 (class write_to_string_literal_diagnostic): New.
6673 (region_model::check_for_writable_region): New.
6674 (region_model::set_value): Call check_for_writable_region.
6675 * region-model.h (region_model::check_for_writable_region): New
6676 decl.
6677
6678 2020-10-07 David Malcolm <dmalcolm@redhat.com>
6679
6680 PR analyzer/97116
6681 * sm-malloc.cc (method_p): New.
6682 (describe_argument_index): New.
6683 (inform_nonnull_attribute): Use describe_argument_index.
6684 (possible_null_arg::describe_final_event): Likewise.
6685 (null_arg::describe_final_event): Likewise.
6686
6687 2020-09-29 David Malcolm <dmalcolm@redhat.com>
6688
6689 PR analyzer/95188
6690 * engine.cc (stmt_requires_new_enode_p): Split enodes before
6691 "signal" calls.
6692
6693 2020-09-29 David Malcolm <dmalcolm@redhat.com>
6694
6695 * constraint-manager.cc
6696 (constraint_manager::add_constraint_internal): Whitespace fixes.
6697 Silence -Wsign-compare warning.
6698 * engine.cc (maybe_process_run_of_before_supernode_enodes):
6699 Silence -Wsign-compare warning.
6700
6701 2020-09-28 David Malcolm <dmalcolm@redhat.com>
6702
6703 * region-model.h (binop_svalue::dyn_cast_binop_svalue): Remove
6704 redundant "virtual". Add FINAL OVERRIDE.
6705 (widening_svalue::dyn_cast_widening_svalue): Add FINAL OVERRIDE.
6706 (compound_svalue::dyn_cast_compound_svalue): Likewise.
6707 (conjured_svalue::dyn_cast_conjured_svalue): Likewise.
6708
6709 2020-09-28 David Malcolm <dmalcolm@redhat.com>
6710
6711 * diagnostic-manager.cc (null_assignment_sm_context::m_visitor):
6712 Remove unused field.
6713
6714 2020-09-28 David Malcolm <dmalcolm@redhat.com>
6715
6716 PR analyzer/97233
6717 * analyzer.cc (is_longjmp_call_p): Require the initial argument
6718 to be a pointer.
6719 * engine.cc (exploded_node::on_longjmp): Likewise.
6720
6721 2020-09-28 David Malcolm <dmalcolm@redhat.com>
6722
6723 * program-state.cc (sm_state_map::print): Update check
6724 for m_global_state being the start state.
6725
6726 2020-09-26 David Malcolm <dmalcolm@redhat.com>
6727
6728 PR analyzer/96646
6729 PR analyzer/96841
6730 * region-model.cc (region_model::get_representative_path_var):
6731 When handling offset_region, wrap the MEM_REF's first argument in
6732 an ADDR_EXPR of pointer type, rather than simply using the tree
6733 for the parent region. Require the MEM_REF's second argument to
6734 be an integer constant.
6735
6736 2020-09-24 David Malcolm <dmalcolm@redhat.com>
6737
6738 * analyzer.h (struct rejected_constraint): New decl.
6739 * analyzer.opt (fanalyzer-feasibility): New option.
6740 * diagnostic-manager.cc (path_builder::path_builder): Add
6741 "problem" param and use it to initialize new field.
6742 (path_builder::get_feasibility_problem): New accessor.
6743 (path_builder::m_feasibility_problem): New field.
6744 (dedupe_winners::add): Remove inversion of logic in "if" clause,
6745 swapping if/else suites. In the !feasible_p suite, inspect
6746 flag_analyzer_feasibility and add code to handle when this
6747 is off, accepting the infeasible path, but recording the
6748 feasibility_problem.
6749 (diagnostic_manager::emit_saved_diagnostic): Pass the
6750 feasibility_problem to the path_builder.
6751 (diagnostic_manager::add_events_for_eedge): If we have
6752 a feasibility_problem at this edge, use it to add a custom event.
6753 * engine.cc (exploded_path::feasible_p): Pass a
6754 rejected_constraint ** to model.maybe_update_for_edge and transfer
6755 ownership of any created instance to any feasibility_problem.
6756 (feasibility_problem::dump_to_pp): New.
6757 * exploded-graph.h (feasibility_problem::feasibility_problem):
6758 Drop "model" param; add rejected_constraint * param.
6759 (feasibility_problem::~feasibility_problem): New.
6760 (feasibility_problem::dump_to_pp): New decl.
6761 (feasibility_problem::m_model): Drop field.
6762 (feasibility_problem::m_rc): New field.
6763 * program-point.cc (function_point::get_location): Handle
6764 PK_BEFORE_SUPERNODE and PK_AFTER_SUPERNODE.
6765 * program-state.cc (program_state::on_edge): Pass NULL to new
6766 param of region_model::maybe_update_for_edge.
6767 * region-model.cc (region_model::add_constraint): New overload
6768 adding a rejected_constraint ** param.
6769 (region_model::maybe_update_for_edge): Add rejected_constraint **
6770 param and pass it to the various apply_constraints_for_ calls.
6771 (region_model::apply_constraints_for_gcond): Add
6772 rejected_constraint ** param and pass it to add_constraint calls.
6773 (region_model::apply_constraints_for_gswitch): Likewise.
6774 (region_model::apply_constraints_for_exception): Likewise.
6775 (rejected_constraint::dump_to_pp): New.
6776 * region-model.h (region_model::maybe_update_for_edge):
6777 Add rejected_constraint ** param.
6778 (region_model::add_constraint): New overload adding a
6779 rejected_constraint ** param.
6780 (region_model::apply_constraints_for_gcond): Add
6781 rejected_constraint ** param.
6782 (region_model::apply_constraints_for_gswitch): Likewise.
6783 (region_model::apply_constraints_for_exception): Likewise.
6784 (struct rejected_constraint): New.
6785
6786 2020-09-23 David Malcolm <dmalcolm@redhat.com>
6787
6788 PR analyzer/97178
6789 * engine.cc (impl_run_checkers): Update for change to ext_state
6790 ctor.
6791 * program-state.cc (selftest::test_sm_state_map): Pass an engine
6792 instance to ext_state ctor.
6793 (selftest::test_program_state_1): Likewise.
6794 (selftest::test_program_state_2): Likewise.
6795 (selftest::test_program_state_merging): Likewise.
6796 (selftest::test_program_state_merging_2): Likewise.
6797 * program-state.h (extrinsic_state::extrinsic_state): Remove NULL
6798 default value for "eng" param.
6799
6800 2020-09-23 Tobias Burnus <tobias@codesourcery.com>
6801
6802 * analyzer-logging.cc: Guard '#pragma ... ignored "-Wformat-diag"'
6803 by '#if __GNUC__ >= 10'
6804 * analyzer.h: Likewise.
6805 * call-string.cc: Likewise.
6806
6807 2020-09-23 David Malcolm <dmalcolm@redhat.com>
6808
6809 * engine.cc (exploded_node::on_stmt): Replace sequence of dyn_cast
6810 with switch.
6811
6812 2020-09-22 David Malcolm <dmalcolm@redhat.com>
6813
6814 * analysis-plan.cc: Include "json.h".
6815 * analyzer.opt (fdump-analyzer-json): New.
6816 * call-string.cc: Include "json.h".
6817 (call_string::to_json): New.
6818 * call-string.h (call_string::to_json): New decl.
6819 * checker-path.cc: Include "json.h".
6820 * constraint-manager.cc: Include "json.h".
6821 (equiv_class::to_json): New.
6822 (constraint::to_json): New.
6823 (constraint_manager::to_json): New.
6824 * constraint-manager.h (equiv_class::to_json): New decl.
6825 (constraint::to_json): New decl.
6826 (constraint_manager::to_json): New decl.
6827 * diagnostic-manager.cc: Include "json.h".
6828 (saved_diagnostic::to_json): New.
6829 (diagnostic_manager::to_json): New.
6830 * diagnostic-manager.h (saved_diagnostic::to_json): New decl.
6831 (diagnostic_manager::to_json): New decl.
6832 * engine.cc: Include "json.h", <zlib.h>.
6833 (exploded_node::status_to_str): New.
6834 (exploded_node::to_json): New.
6835 (exploded_edge::to_json): New.
6836 (exploded_graph::to_json): New.
6837 (dump_analyzer_json): New.
6838 (impl_run_checkers): Call it.
6839 * exploded-graph.h (exploded_node::status_to_str): New decl.
6840 (exploded_node::to_json): New.
6841 (exploded_edge::to_json): New.
6842 (exploded_graph::to_json): New.
6843 * pending-diagnostic.cc: Include "json.h".
6844 * program-point.cc: Include "json.h".
6845 (program_point::to_json): New.
6846 * program-point.h (program_point::to_json): New decl.
6847 * program-state.cc: Include "json.h".
6848 (extrinsic_state::to_json): New.
6849 (sm_state_map::to_json): New.
6850 (program_state::to_json): New.
6851 * program-state.h (extrinsic_state::to_json): New decl.
6852 (sm_state_map::to_json): New decl.
6853 (program_state::to_json): New decl.
6854 * region-model-impl-calls.cc: Include "json.h".
6855 * region-model-manager.cc: Include "json.h".
6856 * region-model-reachability.cc: Include "json.h".
6857 * region-model.cc: Include "json.h".
6858 * region-model.h (svalue::to_json): New decl.
6859 (region::to_json): New decl.
6860 * region.cc: Include "json.h".
6861 (region::to_json: New.
6862 * sm-file.cc: Include "json.h".
6863 * sm-malloc.cc: Include "json.h".
6864 * sm-pattern-test.cc: Include "json.h".
6865 * sm-sensitive.cc: Include "json.h".
6866 * sm-signal.cc: Include "json.h".
6867 (signal_delivery_edge_info_t::to_json): New.
6868 * sm-taint.cc: Include "json.h".
6869 * sm.cc: Include "diagnostic.h", "tree-diagnostic.h", and
6870 "json.h".
6871 (state_machine::state::to_json): New.
6872 (state_machine::to_json): New.
6873 * sm.h (state_machine::state::to_json): New.
6874 (state_machine::to_json): New.
6875 * state-purge.cc: Include "json.h".
6876 * store.cc: Include "json.h".
6877 (binding_key::get_desc): New.
6878 (binding_map::to_json): New.
6879 (binding_cluster::to_json): New.
6880 (store::to_json): New.
6881 * store.h (binding_key::get_desc): New decl.
6882 (binding_map::to_json): New decl.
6883 (binding_cluster::to_json): New decl.
6884 (store::to_json): New decl.
6885 * supergraph.cc: Include "json.h".
6886 (supergraph::to_json): New.
6887 (supernode::to_json): New.
6888 (superedge::to_json): New.
6889 * supergraph.h (supergraph::to_json): New decl.
6890 (supernode::to_json): New decl.
6891 (superedge::to_json): New decl.
6892 * svalue.cc: Include "json.h".
6893 (svalue::to_json): New.
6894
6895 2020-09-21 David Malcolm <dmalcolm@redhat.com>
6896
6897 PR analyzer/97130
6898 * region-model-impl-calls.cc (call_details::get_arg_type): New.
6899 * region-model.cc (region_model::on_call_pre): Check that the
6900 initial arg is a pointer before calling impl_call_memset and
6901 impl_call_strlen.
6902 * region-model.h (call_details::get_arg_type): New decl.
6903
6904 2020-09-21 David Malcolm <dmalcolm@redhat.com>
6905
6906 PR analyzer/93355
6907 * sm-malloc.cc (malloc_state_machine::get_default_state): Look at
6908 the base region when considering pointers. Treat pointers to
6909 decls as being non-heap.
6910
6911 2020-09-18 David Malcolm <dmalcolm@redhat.com>
6912
6913 * checker-path.cc (warning_event::get_desc): Handle global state
6914 changes.
6915
6916 2020-09-18 David Malcolm <dmalcolm@redhat.com>
6917
6918 * sm-malloc.cc (malloc_state_machine::on_stmt): Handle strdup and
6919 strndup as being malloc-like allocators.
6920
6921 2020-09-16 David Malcolm <dmalcolm@redhat.com>
6922
6923 * engine.cc (strongly_connected_components::strong_connect): Only
6924 consider intraprocedural edges when creating SCCs.
6925 (worklist::key_t::cmp): Add comment. Treat call_string
6926 differences as more important than differences of program_point
6927 within a supernode.
6928
6929 2020-09-16 David Malcolm <dmalcolm@redhat.com>
6930
6931 * engine.cc (supernode_cluster::dump_dot): Show the SCC id
6932 in the per-supernode clusters in FILENAME.eg.dot output.
6933 (exploded_graph_annotator::add_node_annotations):
6934 Show the SCC of the supernode in FILENAME.supernode.eg.dot output.
6935 * exploded-graph.h (worklist::scc_id): New.
6936 (exploded_graph::get_scc_id): New.
6937
6938 2020-09-16 David Malcolm <dmalcolm@redhat.com>
6939
6940 * engine.cc (exploded_node::dump_dot): Show STATUS_BULK_MERGED.
6941 (exploded_graph::process_worklist): Call
6942 maybe_process_run_of_before_supernode_enodes.
6943 (exploded_graph::maybe_process_run_of_before_supernode_enodes):
6944 New.
6945 (exploded_graph_annotator::print_enode): Show STATUS_BULK_MERGED.
6946 * exploded-graph.h (enum exploded_node::status): Add
6947 STATUS_BULK_MERGED.
6948
6949 2020-09-16 David Malcolm <dmalcolm@redhat.com>
6950
6951 * engine.cc
6952 (exploded_graph::process_node) <case PK_BEFORE_SUPERNODE>:
6953 Simplify by using program_point::get_next.
6954 * program-point.cc (program_point::get_next): New.
6955 * program-point.h (program_point::get_next): New decl.
6956
6957 2020-09-16 David Malcolm <dmalcolm@redhat.com>
6958
6959 * engine.cc (exploded_graph::get_or_create_node): Show the
6960 program point when issuing -Wanalyzer-too-complex due to hitting
6961 the per-program-point limit.
6962
6963 2020-09-16 David Malcolm <dmalcolm@redhat.com>
6964
6965 * region-model.cc (region_model::on_call_pre): Treat getchar as
6966 having no side-effects.
6967
6968 2020-09-15 David Malcolm <dmalcolm@redhat.com>
6969
6970 PR analyzer/96650
6971 * constraint-manager.cc (merger_fact_visitor::on_fact): Replace
6972 assertion that add_constraint succeeded with an assertion that
6973 if it fails, -fanalyzer-transitivity is off.
6974
6975 2020-09-14 David Malcolm <dmalcolm@redhat.com>
6976
6977 * analyzer.opt (-param=analyzer-max-constraints=): New param.
6978 * constraint-manager.cc
6979 (constraint_manager::add_constraint_internal): Silently reject
6980 attempts to add constraints when the above limit is reached.
6981
6982 2020-09-14 David Malcolm <dmalcolm@redhat.com>
6983
6984 PR analyzer/96653
6985 * constraint-manager.cc
6986 (constraint_manager::get_or_add_equiv_class): Don't accumulate
6987 transitive closure of all constraints on constants.
6988
6989 2020-09-14 David Malcolm <dmalcolm@redhat.com>
6990
6991 PR analyzer/97029
6992 * analyzer.cc (is_setjmp_call_p): Require the initial arg to be a
6993 pointer.
6994 * region-model.cc (region_model::deref_rvalue): Assert that the
6995 svalue is of pointer type.
6996
6997 2020-09-11 David Malcolm <dmalcolm@redhat.com>
6998
6999 PR analyzer/96798
7000 * region-model-impl-calls.cc (region_model::impl_call_memcpy):
7001 New.
7002 (region_model::impl_call_strcpy): New.
7003 * region-model.cc (region_model::on_call_pre): Flag unhandled
7004 builtins that are non-pure as having unknown side-effects.
7005 Implement BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK, BUILT_IN_STRCPY,
7006 BUILT_IN_STRCPY_CHK, BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED,
7007 BUILT_IN_PUTC, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_FPUTC,
7008 BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
7009 BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
7010 BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTCHAR,
7011 BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTS, BUILT_IN_PUTS_UNLOCKED,
7012 BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF.
7013 * region-model.h (region_model::impl_call_memcpy): New decl.
7014 (region_model::impl_call_strcpy): New decl.
7015
7016 2020-09-09 David Malcolm <dmalcolm@redhat.com>
7017
7018 PR analyzer/94355
7019 * analyzer.opt (Wanalyzer-mismatching-deallocation): New warning.
7020 * region-model-impl-calls.cc
7021 (region_model::impl_call_operator_new): New.
7022 (region_model::impl_call_operator_delete): New.
7023 * region-model.cc (region_model::on_call_pre): Detect operator new
7024 and operator delete.
7025 (region_model::on_call_post): Likewise.
7026 (region_model::maybe_update_for_edge): Detect EH edges and call...
7027 (region_model::apply_constraints_for_exception): New function.
7028 * region-model.h (region_model::impl_call_operator_new): New decl.
7029 (region_model::impl_call_operator_delete): New decl.
7030 (region_model::apply_constraints_for_exception): New decl.
7031 * sm-malloc.cc (enum resource_state): New.
7032 (struct allocation_state): New state subclass.
7033 (enum wording): New.
7034 (struct api): New.
7035 (malloc_state_machine::custom_data_t): New typedef.
7036 (malloc_state_machine::add_state): New decl.
7037 (malloc_state_machine::m_unchecked)
7038 (malloc_state_machine::m_nonnull)
7039 (malloc_state_machine::m_freed): Delete these states in favor
7040 of...
7041 (malloc_state_machine::m_malloc)
7042 (malloc_state_machine::m_scalar_new)
7043 (malloc_state_machine::m_vector_new): ...this new api instances,
7044 which own their own versions of these states.
7045 (malloc_state_machine::on_allocator_call): New decl.
7046 (malloc_state_machine::on_deallocator_call): New decl.
7047 (api::api): New ctor.
7048 (dyn_cast_allocation_state): New.
7049 (as_a_allocation_state): New.
7050 (get_rs): New.
7051 (unchecked_p): New.
7052 (nonnull_p): New.
7053 (freed_p): New.
7054 (malloc_diagnostic::describe_state_change): Use unchecked_p and
7055 nonnull_p.
7056 (class mismatching_deallocation): New.
7057 (double_free::double_free): Add funcname param for initializing
7058 m_funcname.
7059 (double_free::emit): Use m_funcname in warning message rather
7060 than hardcoding "free".
7061 (double_free::describe_state_change): Likewise. Use freed_p.
7062 (double_free::describe_call_with_state): Use freed_p.
7063 (double_free::describe_final_event): Use m_funcname in message
7064 rather than hardcoding "free".
7065 (double_free::m_funcname): New field.
7066 (possible_null::describe_state_change): Use unchecked_p.
7067 (possible_null::describe_return_of_state): Likewise.
7068 (use_after_free::use_after_free): Add param for initializing m_api.
7069 (use_after_free::emit): Use m_api->m_dealloc_funcname in message
7070 rather than hardcoding "free".
7071 (use_after_free::describe_state_change): Use freed_p. Change the
7072 wording of the message based on the API.
7073 (use_after_free::describe_final_event): Use
7074 m_api->m_dealloc_funcname in message rather than hardcoding
7075 "free". Change the wording of the message based on the API.
7076 (use_after_free::m_api): New field.
7077 (malloc_leak::describe_state_change): Use unchecked_p. Update
7078 for renaming of m_malloc_event to m_alloc_event.
7079 (malloc_leak::describe_final_event): Update for renaming of
7080 m_malloc_event to m_alloc_event.
7081 (malloc_leak::m_malloc_event): Rename...
7082 (malloc_leak::m_alloc_event): ...to this.
7083 (free_of_non_heap::free_of_non_heap): Add param for initializing
7084 m_funcname.
7085 (free_of_non_heap::emit): Use m_funcname in message rather than
7086 hardcoding "free".
7087 (free_of_non_heap::describe_final_event): Likewise.
7088 (free_of_non_heap::m_funcname): New field.
7089 (allocation_state::dump_to_pp): New.
7090 (allocation_state::get_nonnull): New.
7091 (malloc_state_machine::malloc_state_machine): Update for changes
7092 to state fields and new api fields.
7093 (malloc_state_machine::add_state): New.
7094 (malloc_state_machine::on_stmt): Move malloc/calloc handling to
7095 on_allocator_call and call it, passing in the API pointer.
7096 Likewise for free, moving it to on_deallocator_call. Handle calls
7097 to operator new and delete in an analogous way. Use unchecked_p
7098 when testing for possibly-null-arg and possibly-null-deref, and
7099 transition to the non-null for the correct API. Remove redundant
7100 node param from call to on_zero_assignment. Use freed_p for
7101 use-after-free check, and pass in API.
7102 (malloc_state_machine::on_allocator_call): New, based on code in
7103 on_stmt.
7104 (malloc_state_machine::on_deallocator_call): Likewise.
7105 (malloc_state_machine::on_phi): Mark node param with
7106 ATTRIBUTE_UNUSED; don't pass it to on_zero_assignment.
7107 (malloc_state_machine::on_condition): Mark node param with
7108 ATTRIBUTE_UNUSED. Replace on_transition calls with get_state and
7109 set_next_state pairs, transitioning to the non-null state for the
7110 appropriate API.
7111 (malloc_state_machine::can_purge_p): Port to new state approach.
7112 (malloc_state_machine::on_zero_assignment): Replace on_transition
7113 calls with get_state and set_next_state pairs. Drop redundant
7114 node param.
7115 * sm.h (state_machine::add_custom_state): New.
7116
7117 2020-09-09 David Malcolm <dmalcolm@redhat.com>
7118
7119 * diagnostic-manager.cc
7120 (null_assignment_sm_context::warn_for_state): Replace with...
7121 (null_assignment_sm_context::warn): ...this.
7122 * engine.cc (impl_sm_context::warn_for_state): Replace with...
7123 (impl_sm_context::warn): ...this.
7124 * sm-file.cc (fileptr_state_machine::on_stmt): Replace
7125 warn_for_state and on_transition calls with a get_state
7126 test guarding warn and set_next_state calls.
7127 * sm-malloc.cc (malloc_state_machine::on_stmt): Likewise.
7128 * sm-pattern-test.cc (pattern_test_state_machine::on_condition):
7129 Replace warn_for_state call with warn call.
7130 * sm-sensitive.cc
7131 (sensitive_state_machine::warn_for_any_exposure): Replace
7132 warn_for_state call with a get_state test guarding a warn call.
7133 * sm-signal.cc (signal_state_machine::on_stmt): Likewise.
7134 * sm-taint.cc (taint_state_machine::on_stmt): Replace
7135 warn_for_state and on_transition calls with a get_state
7136 test guarding warn and set_next_state calls.
7137 * sm.h (sm_context::warn_for_state): Replace with...
7138 (sm_context::warn): ...this.
7139
7140 2020-09-09 David Malcolm <dmalcolm@redhat.com>
7141
7142 * diagnostic-manager.cc
7143 (null_assignment_sm_context::null_assignment_sm_context): Add old_state
7144 and ext_state params, initializing m_old_state and m_ext_state.
7145 (null_assignment_sm_context::on_transition): Split into...
7146 (null_assignment_sm_context::get_state): ...this new vfunc
7147 implementation and...
7148 (null_assignment_sm_context::set_next_state): ...this new vfunc
7149 implementation.
7150 (null_assignment_sm_context::m_old_state): New field.
7151 (null_assignment_sm_context::m_ext_state): New field.
7152 (diagnostic_manager::add_events_for_eedge): Pass in old state and
7153 ext_state when creating sm_ctxt.
7154 * engine.cc (impl_sm_context::on_transition): Split into...
7155 (impl_sm_context::get_state): ...this new vfunc
7156 implementation and...
7157 (impl_sm_context::set_next_state): ...this new vfunc
7158 implementation.
7159 * sm.h (sm_context::get_state): New pure virtual function.
7160 (sm_context::set_next_state): Likewise.
7161 (sm_context::on_transition): Convert from a pure virtual function
7162 to a regular function implemented in terms of get_state and
7163 set_next_state.
7164
7165 2020-09-09 David Malcolm <dmalcolm@redhat.com>
7166
7167 * checker-path.cc (state_change_event::get_desc): Update
7168 state_machine::get_state_name calls to state::get_name.
7169 (warning_event::get_desc): Likewise.
7170 * diagnostic-manager.cc
7171 (null_assignment_sm_context::on_transition): Update comparison
7172 against 0 with comparison with m_sm.get_start_state.
7173 (diagnostic_manager::prune_for_sm_diagnostic): Update
7174 state_machine::get_state_name calls to state::get_name.
7175 * engine.cc (impl_sm_context::on_transition): Likewise.
7176 (exploded_node::get_dot_fillcolor): Use get_id when summing
7177 the sm states.
7178 * program-state.cc (sm_state_map::sm_state_map): Don't hardcode
7179 0 as the start state when initializing m_global_state.
7180 (sm_state_map::print): Use dump_to_pp rather than get_state_name
7181 when dumping states.
7182 (sm_state_map::is_empty_p): Don't hardcode 0 as the start state
7183 when examining m_global_state.
7184 (sm_state_map::hash): Use get_id when hashing states.
7185 (selftest::test_sm_state_map): Use state objects rather than
7186 arbitrary hardcoded integers.
7187 (selftest::test_program_state_merging): Likewise.
7188 (selftest::test_program_state_merging_2): Likewise.
7189 * sm-file.cc (fileptr_state_machine::m_start): Move to base class.
7190 (file_diagnostic::describe_state_change): Use get_start_state.
7191 (fileptr_state_machine::fileptr_state_machine): Drop m_start
7192 initialization.
7193 * sm-malloc.cc (malloc_state_machine::m_start): Move to base
7194 class.
7195 (malloc_diagnostic::describe_state_change): Use get_start_state.
7196 (possible_null::describe_state_change): Likewise.
7197 (malloc_state_machine::malloc_state_machine): Drop m_start
7198 initialization.
7199 * sm-pattern-test.cc (pattern_test_state_machine::m_start): Move
7200 to base class.
7201 (pattern_test_state_machine::pattern_test_state_machine): Drop
7202 m_start initialization.
7203 * sm-sensitive.cc (sensitive_state_machine::m_start): Move to base
7204 class.
7205 (sensitive_state_machine::sensitive_state_machine): Drop m_start
7206 initialization.
7207 * sm-signal.cc (signal_state_machine::m_start): Move to base
7208 class.
7209 (signal_state_machine::signal_state_machine): Drop m_start
7210 initialization.
7211 * sm-taint.cc (taint_state_machine::m_start): Move to base class.
7212 (taint_state_machine::taint_state_machine): Drop m_start
7213 initialization.
7214 * sm.cc (state_machine::state::dump_to_pp): New.
7215 (state_machine::state_machine): Move here from sm.h. Initialize
7216 m_next_state_id and m_start.
7217 (state_machine::add_state): Reimplement in terms of state objects.
7218 (state_machine::get_state_name): Delete.
7219 (state_machine::get_state_by_name): Reimplement in terms of state
7220 objects. Make const.
7221 (state_machine::validate): Delete.
7222 (state_machine::dump_to_pp): Reimplement in terms of state
7223 objects.
7224 * sm.h (state_machine::state): New class.
7225 (state_machine::state_t): Convert typedef from "unsigned" to
7226 "const state_machine::state *".
7227 (state_machine::state_machine): Move to sm.cc.
7228 (state_machine::get_default_state): Use m_start rather than
7229 hardcoding 0.
7230 (state_machine::get_state_name): Delete.
7231 (state_machine::get_state_by_name): Make const.
7232 (state_machine::get_start_state): New accessor.
7233 (state_machine::alloc_state_id): New.
7234 (state_machine::m_state_names): Drop in favor of...
7235 (state_machine::m_states): New field
7236 (state_machine::m_start): New field
7237 (start_start_p): Delete.
7238
7239 2020-09-08 David Malcolm <dmalcolm@redhat.com>
7240
7241 PR analyzer/96949
7242 * store.cc (binding_map::apply_ctor_val_to_range): Add
7243 error-handling for the cases where we have symbolic offsets.
7244
7245 2020-09-08 David Malcolm <dmalcolm@redhat.com>
7246
7247 PR analyzer/96950
7248 * store.cc (binding_map::apply_ctor_to_region): Handle RANGE_EXPR
7249 where min_index == max_index.
7250 (binding_map::apply_ctor_val_to_range): Replace assertion that we
7251 don't have a CONSTRUCTOR value with error-handling.
7252
7253 2020-09-08 David Malcolm <dmalcolm@redhat.com>
7254
7255 PR analyzer/96962
7256 * region-model.cc (region_model::on_call_pre): Fix guard on switch
7257 on built-ins to only consider BUILT_IN_NORMAL, rather than other
7258 kinds of build-ins.
7259
7260 2020-09-01 David Malcolm <dmalcolm@redhat.com>
7261
7262 PR analyzer/96792
7263 * region-model.cc (region_model::deref_rvalue): Add the constraint
7264 that PTR_SVAL is non-NULL.
7265
7266 2020-08-31 David Malcolm <dmalcolm@redhat.com>
7267
7268 PR analyzer/96798
7269 * region-model.cc (region_model::on_call_pre): Handle
7270 BUILT_IN_MEMSET_CHK.
7271
7272 2020-08-31 David Malcolm <dmalcolm@redhat.com>
7273
7274 * region-model.cc (region_model::on_call_pre): Gather handling of
7275 builtins and of internal fns into switch statements. Handle
7276 "alloca" and BUILT_IN_ALLOCA_WITH_ALIGN.
7277
7278 2020-08-31 David Malcolm <dmalcolm@redhat.com>
7279
7280 PR analyzer/96860
7281 * region.cc (decl_region::get_svalue_for_constructor): Support
7282 apply_ctor_to_region failing.
7283 * store.cc (binding_map::apply_ctor_to_region): Add failure
7284 handling.
7285 (binding_map::apply_ctor_val_to_range): Likewise.
7286 (binding_map::apply_ctor_pair_to_child_region): Likewise. Replace
7287 assertion that child_base_offset is not symbolic with error
7288 handling.
7289 * store.h (binding_map::apply_ctor_to_region): Convert return type
7290 from void to bool.
7291 (binding_map::apply_ctor_val_to_range): Likewise.
7292 (binding_map::apply_ctor_pair_to_child_region): Likewise.
7293
7294 2020-08-31 David Malcolm <dmalcolm@redhat.com>
7295
7296 PR analyzer/96763
7297 * store.cc (binding_map::apply_ctor_to_region): Handle RANGE_EXPR
7298 by calling a new binding_map::apply_ctor_val_to_range subroutine.
7299 Split out the existing non-CONSTRUCTOR-handling code to a new
7300 apply_ctor_pair_to_child_region subroutine.
7301 (binding_map::apply_ctor_val_to_range): New.
7302 (binding_map::apply_ctor_pair_to_child_region): New, split out
7303 from binding_map::apply_ctor_to_region as noted above.
7304 * store.h (binding_map::apply_ctor_val_to_range): New decl.
7305 (binding_map::apply_ctor_pair_to_child_region): New decl.
7306
7307 2020-08-31 David Malcolm <dmalcolm@redhat.com>
7308
7309 PR analyzer/96764
7310 * region-model-manager.cc
7311 (region_model_manager::maybe_fold_unaryop): Handle VIEW_CONVERT_EXPR.
7312 (region_model_manager::get_or_create_cast): Move logic for
7313 real->integer casting to...
7314 (get_code_for_cast): ...this new function, and add logic for
7315 real->non-integer casts.
7316 (region_model_manager::maybe_fold_sub_svalue): Handle
7317 VIEW_CONVERT_EXPR.
7318 * region-model.cc
7319 (region_model::add_any_constraints_from_gassign): Likewise.
7320 * svalue.cc (svalue::maybe_undo_cast): Likewise.
7321 (unaryop_svalue::dump_to_pp): Likewise.
7322
7323 2020-08-26 David Malcolm <dmalcolm@redhat.com>
7324
7325 PR analyzer/94858
7326 * region-model-manager.cc
7327 (region_model_manager::get_or_create_widening_svalue): Assert that
7328 neither of the inputs are themselves widenings.
7329 * store.cc (store::eval_alias_1): The initial value of a pointer
7330 can't point to a region that was allocated on the heap after the
7331 beginning of the path. A widened pointer value can't alias anything
7332 that the initial pointer value can't alias.
7333 * svalue.cc (svalue::can_merge_p): Merge BINOP (X, OP, CST) with X
7334 to a widening svalue. Merge
7335 BINOP(WIDENING(BASE, BINOP(BASE, X)), X) and BINOP(BASE, X) to
7336 to the LHS of the first BINOP.
7337
7338 2020-08-26 David Malcolm <dmalcolm@redhat.com>
7339
7340 PR analyzer/96777
7341 * region-model.h (class compound_svalue): Document that all keys
7342 must be concrete.
7343 (compound_svalue::compound_svalue): Move definition to svalue.cc.
7344 * store.cc (binding_map::apply_ctor_to_region): Handle
7345 initializers for trailing arrays with incomplete size.
7346 * svalue.cc (compound_svalue::compound_svalue): Move definition
7347 here from region-model.h. Add assertion that all keys are
7348 concrete.
7349
7350 2020-08-22 David Malcolm <dmalcolm@redhat.com>
7351
7352 PR analyzer/94851
7353 * region-model-manager.cc
7354 (region_model_manager::maybe_fold_binop): Fold bitwise "& 0" to 0.
7355
7356 2020-08-22 David Malcolm <dmalcolm@redhat.com>
7357
7358 * store.cc (store::eval_alias): Make const. Split out 2nd half
7359 into store::eval_alias_1 and call it twice for symmetry, avoiding
7360 test duplication.
7361 (store::eval_alias_1): New function, split out from the above.
7362 * store.h (store::eval_alias): Make const.
7363 (store::eval_alias_1): New decl.
7364
7365 2020-08-22 David Malcolm <dmalcolm@redhat.com>
7366
7367 * region-model.cc (region_model::push_frame): Bind the default
7368 SSA name for each parm if it exists, falling back to the parm
7369 itself otherwise, rather than doing both.
7370
7371 2020-08-20 David Malcolm <dmalcolm@redhat.com>
7372
7373 PR analyzer/96723
7374 * region-model-manager.cc
7375 (region_model_manager::get_field_region): Assert that field is a
7376 FIELD_DECL.
7377 * region.cc (region::get_subregions_for_binding): In
7378 union-handling, filter the TYPE_FIELDS traversal to just FIELD_DECLs.
7379
7380 2020-08-20 David Malcolm <dmalcolm@redhat.com>
7381
7382 PR analyzer/96713
7383 * region-model.cc (region_model::get_gassign_result): For
7384 comparisons, only use eval_condition when the lhs has boolean
7385 type, and use get_or_create_constant_svalue on the boolean
7386 constants directly rather than via get_rvalue.
7387
7388 2020-08-19 David Malcolm <dmalcolm@redhat.com>
7389
7390 PR analyzer/96643
7391 * region-model.cc (region_model::deref_rvalue): Rather than
7392 attempting to handle all svalue kinds in the switch, only cover
7393 the special cases, and move symbolic-region handling to after
7394 the switch, thus implicitly handling the missing case SK_COMPOUND.
7395
7396 2020-08-19 David Malcolm <dmalcolm@redhat.com>
7397
7398 PR analyzer/96705
7399 * region-model-manager.cc
7400 (region_model_manager::maybe_fold_binop): Check that we have an
7401 integral type before calling build_int_cst.
7402
7403 2020-08-19 David Malcolm <dmalcolm@redhat.com>
7404
7405 PR analyzer/96699
7406 * region-model-manager.cc
7407 (region_model_manager::get_or_create_cast): Use FIX_TRUNC_EXPR for
7408 casting from REAL_TYPE to INTEGER_TYPE.
7409
7410 2020-08-19 David Malcolm <dmalcolm@redhat.com>
7411
7412 PR analyzer/96651
7413 * region-model.cc (region_model::called_from_main_p): New.
7414 (region_model::get_store_value): Move handling for globals into...
7415 (region_model::get_initial_value_for_global): ...this new
7416 function, and add logic for extracting values from decl
7417 initializers.
7418 * region-model.h (decl_region::get_svalue_for_constructor): New
7419 decl.
7420 (decl_region::get_svalue_for_initializer): New decl.
7421 (region_model::called_from_main_p): New decl.
7422 (region_model::get_initial_value_for_global): New.
7423 * region.cc (decl_region::maybe_get_constant_value): Move logic
7424 for getting an svalue from a CONSTRUCTOR node to...
7425 (decl_region::get_svalue_for_constructor): ...this new function.
7426 (decl_region::get_svalue_for_initializer): New.
7427 * store.cc (get_svalue_for_ctor_val): Rewrite in terms of
7428 region_model::get_rvalue.
7429 * store.h (binding_cluster::get_map): New accessor.
7430
7431 2020-08-19 David Malcolm <dmalcolm@redhat.com>
7432
7433 PR analyzer/96648
7434 * region.cc (get_field_at_bit_offset): Gracefully handle negative
7435 values for bit_offset.
7436
7437 2020-08-18 David Malcolm <dmalcolm@redhat.com>
7438
7439 * region-model.cc (region_model::get_rvalue_1): Fix name of local.
7440
7441 2020-08-18 David Malcolm <dmalcolm@redhat.com>
7442
7443 PR analyzer/96641
7444 * region-model.cc (region_model::get_rvalue_1): Handle
7445 unrecognized tree codes by returning "UNKNOWN.
7446
7447 2020-08-18 David Malcolm <dmalcolm@redhat.com>
7448
7449 PR analyzer/96640
7450 * region-model.cc (region_model::get_gassign_result): Handle various
7451 VEC_* tree codes by returning UNKNOWN.
7452 (region_model::on_assignment): Handle unrecognized tree codes by
7453 setting lhs to an unknown value, rather than issuing a "sorry" and
7454 asserting.
7455
7456 2020-08-17 David Malcolm <dmalcolm@redhat.com>
7457
7458 PR analyzer/96644
7459 * region-model-manager.cc (get_region_for_unexpected_tree_code):
7460 Handle ctxt being NULL.
7461
7462 2020-08-17 David Malcolm <dmalcolm@redhat.com>
7463
7464 PR analyzer/96639
7465 * region.cc (region::get_subregions_for_binding): Check for "type"
7466 being NULL.
7467
7468 2020-08-17 David Malcolm <dmalcolm@redhat.com>
7469
7470 PR analyzer/96642
7471 * store.cc (get_svalue_for_ctor_val): New.
7472 (binding_map::apply_ctor_to_region): Call it.
7473
7474 2020-08-14 David Malcolm <dmalcolm@redhat.com>
7475
7476 PR testsuite/96609
7477 PR analyzer/96616
7478 * region-model.cc (region_model::get_store_value): Call
7479 maybe_get_constant_value on decl_regions first.
7480 * region-model.h (decl_region::maybe_get_constant_value): New decl.
7481 * region.cc (decl_region::get_stack_depth): Likewise.
7482 (decl_region::maybe_get_constant_value): New.
7483 * store.cc (get_subregion_within_ctor): New.
7484 (binding_map::apply_ctor_to_region): New.
7485 * store.h (binding_map::apply_ctor_to_region): New decl.
7486
7487 2020-08-14 David Malcolm <dmalcolm@redhat.com>
7488
7489 PR analyzer/96611
7490 * store.cc (store::mark_as_escaped): Reject attempts to
7491 get a cluster for an unknown pointer.
7492
7493 2020-08-13 David Malcolm <dmalcolm@redhat.com>
7494
7495 PR analyzer/93032
7496 PR analyzer/93938
7497 PR analyzer/94011
7498 PR analyzer/94099
7499 PR analyzer/94399
7500 PR analyzer/94458
7501 PR analyzer/94503
7502 PR analyzer/94640
7503 PR analyzer/94688
7504 PR analyzer/94689
7505 PR analyzer/94839
7506 PR analyzer/95026
7507 PR analyzer/95042
7508 PR analyzer/95240
7509 * analyzer-logging.cc: Ignore "-Wformat-diag".
7510 (logger::enter_scope): Use inc_indent in both overloads.
7511 (logger::exit_scope): Use dec_indent.
7512 * analyzer-logging.h (logger::inc_indent): New.
7513 (logger::dec_indent): New.
7514 * analyzer-selftests.cc (run_analyzer_selftests): Call
7515 analyzer_store_cc_tests.
7516 * analyzer-selftests.h (analyzer_store_cc_tests): New decl.
7517 * analyzer.cc (get_stmt_location): New function.
7518 * analyzer.h (class initial_svalue): New forward decl.
7519 (class unaryop_svalue): New forward decl.
7520 (class binop_svalue): New forward decl.
7521 (class sub_svalue): New forward decl.
7522 (class unmergeable_svalue): New forward decl.
7523 (class placeholder_svalue): New forward decl.
7524 (class widening_svalue): New forward decl.
7525 (class compound_svalue): New forward decl.
7526 (class conjured_svalue): New forward decl.
7527 (svalue_set): New typedef.
7528 (class map_region): Delete.
7529 (class array_region): Delete.
7530 (class frame_region): New forward decl.
7531 (class function_region): New forward decl.
7532 (class label_region): New forward decl.
7533 (class decl_region): New forward decl.
7534 (class element_region): New forward decl.
7535 (class offset_region): New forward decl.
7536 (class cast_region): New forward decl.
7537 (class field_region): New forward decl.
7538 (class string_region): New forward decl.
7539 (class region_model_manager): New forward decl.
7540 (class store_manager): New forward decl.
7541 (class store): New forward decl.
7542 (class call_details): New forward decl.
7543 (struct svalue_id_merger_mapping): Delete.
7544 (struct canonicalization): Delete.
7545 (class function_point): New forward decl.
7546 (class engine): New forward decl.
7547 (dump_tree): New function decl.
7548 (print_quoted_type): New function decl.
7549 (readability_comparator): New function decl.
7550 (tree_cmp): New function decl.
7551 (class path_var): Move here from region-model.h
7552 (bit_offset_t, bit_size_t, byte_size_t): New typedefs.
7553 (class region_offset): New class.
7554 (get_stmt_location): New decl.
7555 (struct member_function_hash_traits): New struct.
7556 (class consolidation_map): New class.
7557 Ignore "-Wformat-diag".
7558 * analyzer.opt (-param=analyzer-max-svalue-depth=): New param.
7559 (-param=analyzer-max-enodes-for-full-dump=): New param.
7560 * call-string.cc: Ignore -Wformat-diag.
7561 * checker-path.cc: Move includes of "analyzer/call-string.h" and
7562 "analyzer/program-point.h" to before "analyzer/region-model.h",
7563 and also include "analyzer/store.h" before it.
7564 (state_change_event::state_change_event): Replace "tree var" param
7565 with "const svalue *sval". Convert "origin" param from tree to
7566 "const svalue *".
7567 (state_change_event::get_desc): Call get_representative_tree to
7568 convert the var and origin from const svalue * to tree. Use
7569 svalue::get_desc rather than %qE when describing state changes.
7570 (checker_path::add_final_event): Use get_stmt_location.
7571 * checker-path.h (state_change_event::state_change_event): Port
7572 from tree to const svalue *.
7573 (state_change_event::get_lvalue): Delete.
7574 (state_change_event::get_dest_function): New.
7575 (state_change_event::m_var): Replace with...
7576 (state_change_event::m_sval): ...this.
7577 (state_change_event::m_origin): Convert from tree to
7578 const svalue *.
7579 * constraint-manager.cc: Include "analyzer/call-string.h",
7580 "analyzer/program-point.h", and "analyzer/store.h" before
7581 "analyzer/region-model.h".
7582 (struct bound, struct range): Move to constraint-manager.h.
7583 (compare_constants): New function.
7584 (range::dump): Rename to...
7585 (range::dump_to_pp): ...this. Support NULL constants.
7586 (range::dump): Reintroduce for dumping to stderr.
7587 (range::constrained_to_single_element): Return result, rather than
7588 writing to *OUT.
7589 (range::eval_condition): New.
7590 (range::below_lower_bound): New.
7591 (range::above_upper_bound): New.
7592 (equiv_class::equiv_class): Port from svalue_id to const svalue *.
7593 (equiv_class::print): Likewise.
7594 (equiv_class::hash): Likewise.
7595 (equiv_class::operator==): Port from svalue_id to const svalue *.
7596 (equiv_class::add): Port from svalue_id to const svalue *. Drop
7597 "cm" param.
7598 (equiv_class::del): Port from svalue_id to const svalue *.
7599 (equiv_class::get_representative): Likewise.
7600 (equiv_class::remap_svalue_ids): Delete.
7601 (svalue_id_cmp_by_id): Rename to...
7602 (svalue_cmp_by_ptr): ...this, porting from svalue_id to
7603 const svalue *.
7604 (equiv_class::canonicalize): Update qsort comparator.
7605 (constraint::implied_by): New.
7606 (constraint_manager::constraint_manager): Copy m_mgr in copy ctor.
7607 (constraint_manager::dump_to_pp): Add "multiline" param
7608 (constraint_manager::dump): Pass "true" for "multiline".
7609 (constraint_manager::add_constraint): Port from svalue_id to
7610 const svalue *. Split out second part into...
7611 (constraint_manager::add_unknown_constraint): ...this new
7612 function. Remove self-constraints when merging equivalence
7613 classes.
7614 (constraint_manager::add_constraint_internal): Remove constraints
7615 that would be implied by the new constraint. Port from svalue_id
7616 to const svalue *.
7617 (constraint_manager::get_equiv_class_by_sid): Rename to...
7618 (constraint_manager::get_equiv_class_by_svalue): ...this, porting
7619 from svalue_id to const svalue *.
7620 (constraint_manager::get_or_add_equiv_class): Port from svalue_id
7621 to const svalue *.
7622 (constraint_manager::eval_condition): Make const. Call
7623 compare_constants and return early if it provides a known result.
7624 (constraint_manager::get_ec_bounds): New.
7625 (constraint_manager::eval_condition): New overloads. Make
7626 existing one const, and use compare_constants.
7627 (constraint_manager::purge): Convert "p" param to a template
7628 rather that an abstract base class. Port from svalue_id to
7629 const svalue *.
7630 (class dead_svalue_purger): New class.
7631 (constraint_manager::remap_svalue_ids): Delete.
7632 (constraint_manager::on_liveness_change): New.
7633 (equiv_class_cmp): Port from svalue_id to const svalue *.
7634 (constraint_manager::canonicalize): Likewise. Combine with
7635 purging of redundant equivalence classes and constraints.
7636 (class cleaned_constraint_manager): Delete.
7637 (class merger_fact_visitor): Make "m_cm_b" const. Add "m_merger"
7638 field.
7639 (merger_fact_visitor::fact): Port from svalue_id to const svalue *.
7640 Add special case for widening.
7641 (constraint_manager::merge): Port from svalue_id to const svalue *.
7642 (constraint_manager::clean_merger_input): Delete.
7643 (constraint_manager::for_each_fact): Port from svalue_id to
7644 const svalue *.
7645 (constraint_manager::validate): Likewise.
7646 (selftest::test_constraint_conditions): Provide a
7647 region_model_manager when creating region_model instances.
7648 Add test for self-equality not creating equivalence classes.
7649 (selftest::test_transitivity): Provide a region_model_manager when
7650 creating region_model instances. Verify that EC-merging happens
7651 when constraints are implied.
7652 (selftest::test_constant_comparisons): Provide a
7653 region_model_manager when creating region_model instances.
7654 (selftest::test_constraint_impl): Likewise. Remove over-specified
7655 assertions.
7656 (selftest::test_equality): Provide a region_model_manager when
7657 creating region_model instances.
7658 (selftest::test_many_constants): Likewise. Provide a
7659 program_point when testing merging.
7660 (selftest::run_constraint_manager_tests): Move call to
7661 test_constant_comparisons to outside the transitivity guard.
7662 * constraint-manager.h (struct bound): Move here from
7663 constraint-manager.cc.
7664 (struct range): Likewise.
7665 (struct::eval_condition): New decl.
7666 (struct::below_lower_bound): New decl.
7667 (struct::above_upper_bound): New decl.
7668 (equiv_class::add): Port from svalue_id to const svalue *.
7669 (equiv_class::del): Likewise.
7670 (equiv_class::get_representative): Likewise.
7671 (equiv_class::remap_svalue_ids): Drop.
7672 (equiv_class::m_cst_sid): Convert to..
7673 (equiv_class::m_cst_sval): ...this.
7674 (equiv_class::m_vars): Port from svalue_id to const svalue *.
7675 (constraint::bool implied_by): New decl.
7676 (fact_visitor::on_fact): Port from svalue_id to const svalue *.
7677 (constraint_manager::constraint_manager): Add mgr param.
7678 (constraint_manager::clone): Delete.
7679 (constraint_manager::maybe_get_constant): Delete.
7680 (constraint_manager::get_sid_for_constant): Delete.
7681 (constraint_manager::get_num_svalues): Delete.
7682 (constraint_manager::dump_to_pp): Add "multiline" param.
7683 (constraint_manager::get_equiv_class): Port from svalue_id to
7684 const svalue *.
7685 (constraint_manager::add_constraint): Likewise.
7686 (constraint_manager::get_equiv_class_by_sid): Rename to...
7687 (constraint_manager::get_equiv_class_by_svalue): ...this, porting
7688 from svalue_id to const svalue *.
7689 (constraint_manager::add_unknown_constraint): New decl.
7690 (constraint_manager::get_or_add_equiv_class): Port from svalue_id
7691 to const svalue *.
7692 (constraint_manager::eval_condition): Likewise. Add overloads.
7693 (constraint_manager::get_ec_bounds): New decl.
7694 (constraint_manager::purge): Convert to template.
7695 (constraint_manager::remap_svalue_ids): Delete.
7696 (constraint_manager::on_liveness_change): New decl.
7697 (constraint_manager::canonicalize): Drop param.
7698 (constraint_manager::clean_merger_input): Delete.
7699 (constraint_manager::m_mgr): New field.
7700 * diagnostic-manager.cc: Move includes of
7701 "analyzer/call-string.h" and "analyzer/program-point.h" to before
7702 "analyzer/region-model.h", and also include "analyzer/store.h"
7703 before it.
7704 (saved_diagnostic::saved_diagnostic): Add "sval" param.
7705 (diagnostic_manager::diagnostic_manager): Add engine param.
7706 (diagnostic_manager::add_diagnostic): Add "sval" param, passing it
7707 to saved_diagnostic ctor. Update overload to pass NULL for it.
7708 (dedupe_winners::dedupe_winners): Add engine param.
7709 (dedupe_winners::add): Add "eg" param. Pass m_engine to
7710 feasible_p.
7711 (dedupe_winner::m_engine): New field.
7712 (diagnostic_manager::emit_saved_diagnostics): Pass engine to
7713 dedupe_winners. Pass &eg when adding candidates. Pass svalue
7714 rather than tree to prune_path. Use get_stmt_location to get
7715 primary location of diagnostic.
7716 (diagnostic_manager::emit_saved_diagnostic): Likewise.
7717 (get_any_origin): Drop.
7718 (state_change_event_creator::on_global_state_change): Pass NULL
7719 const svalue * rather than NULL_TREE trees to state_change_event
7720 ctor.
7721 (state_change_event_creator::on_state_change): Port from tree and
7722 svalue_id to const svalue *.
7723 (for_each_state_change): Port from svalue_id to const svalue *.
7724 (struct null_assignment_sm_context): New.
7725 (diagnostic_manager::add_events_for_eedge): Add state change
7726 events for assignment to NULL.
7727 (diagnostic_manager::prune_path): Update param from tree to
7728 const svalue *.
7729 (diagnostic_manager::prune_for_sm_diagnostic): Port from tracking
7730 by tree to by const svalue *.
7731 * diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Add sval
7732 param.
7733 (saved_diagnostic::m_sval): New field.
7734 (diagnostic_manager::diagnostic_manager): Add engine param.
7735 (diagnostic_manager::get_engine): New.
7736 (diagnostic_manager::add_diagnostic): Add "sval" param.
7737 (diagnostic_manager::prune_path): Likewise.
7738 (diagnostic_manager::prune_for_sm_diagnostic): New overload.
7739 (diagnostic_manager::m_eng): New field.
7740 * engine.cc: Move includes of "analyzer/call-string.h" and
7741 "analyzer/program-point.h" to before "analyzer/region-model.h",
7742 and also include "analyzer/store.h" before it.
7743 (impl_region_model_context::impl_region_model_context): Update for
7744 removal of m_change field.
7745 (impl_region_model_context::remap_svalue_ids): Delete.
7746 (impl_region_model_context::on_svalue_leak): New.
7747 (impl_region_model_context::on_svalue_purge): Delete.
7748 (impl_region_model_context::on_liveness_change): New.
7749 (impl_region_model_context::on_unknown_change): Update param
7750 from svalue_id to const svalue *. Add is_mutable param.
7751 (setjmp_svalue::compare_fields): Delete.
7752 (setjmp_svalue::accept): New.
7753 (setjmp_svalue::add_to_hash): Delete.
7754 (setjmp_svalue::dump_to_pp): New.
7755 (setjmp_svalue::print_details): Delete.
7756 (impl_sm_context::impl_sm_context): Drop "change" param.
7757 (impl_sm_context::get_fndecl_for_call): Drop "m_change".
7758 (impl_sm_context::on_transition): Drop ATTRIBUTE_UNUSED from
7759 "stmt" param. Drop m_change. Port from svalue_id to
7760 const svalue *.
7761 (impl_sm_context::warn_for_state): Drop m_change. Port from
7762 svalue_id to const svalue *.
7763 (impl_sm_context::get_readable_tree): Rename to...
7764 (impl_sm_context::get_diagnostic_tree): ...this. Port from
7765 svalue_id to const svalue *.
7766 (impl_sm_context::is_zero_assignment): New.
7767 (impl_sm_context::m_change): Delete field.
7768 (leak_stmt_finder::find_stmt): Handle m_var being NULL.
7769 (readability): Increase penalty for MEM_REF. For SSA_NAMEs,
7770 slightly favor the underlying var over the SSA name. Heavily
7771 penalize temporaries. Handle RESULT_DECL.
7772 (readability_comparator): Make non-static. Consider stack depths.
7773 (impl_region_model_context::on_state_leak): Convert from svalue_id
7774 to const svalue *, updating for region_model changes. Use
7775 id_equal.
7776 (impl_region_model_context::on_inherited_svalue): Delete.
7777 (impl_region_model_context::on_cast): Delete.
7778 (impl_region_model_context::on_condition): Drop m_change.
7779 (impl_region_model_context::on_phi): Likewise.
7780 (impl_region_model_context::on_unexpected_tree_code): Handle t
7781 being NULL.
7782 (point_and_state::validate): Update stack checking for
7783 region_model changes.
7784 (eg_traits::dump_args_t::show_enode_details_p): New.
7785 (exploded_node::exploded_node): Initialize m_num_processed_stmts.
7786 (exploded_node::get_processed_stmt): New function.
7787 (exploded_node::get_dot_fillcolor): Add more colors.
7788 (exploded_node::dump_dot): Guard the printing of the point and
7789 state with show_enode_details_p. Print the processed stmts for
7790 this enode after the initial state.
7791 (exploded_node::dump_to_pp): Pass true for new multiline param
7792 of program_state::dump_to_pp.
7793 (exploded_node::on_stmt): Drop "change" param. Log the stmt.
7794 Set input_location. Implement __analyzer_describe. Update
7795 implementation of __analyzer_dump and __analyzer_eval.
7796 Remove purging of sm-state for unknown fncalls from here.
7797 (exploded_node::on_edge): Drop "change" param.
7798 (exploded_node::on_longjmp): Port from region_id/svalue_id to
7799 const region */const svalue *. Call program_state::detect_leaks.
7800 Drop state_change.
7801 (exploded_node::detect_leaks): Update for changes to region_model.
7802 Call program_state::detect_leaks.
7803 (exploded_edge::exploded_edge): Drop ext_state and change params.
7804 (exploded_edge::dump_dot): "args" is no longer used. Drop dumping
7805 of m_change.
7806 (exploded_graph::exploded_graph): Pass engine to
7807 m_diagnostic_manager ctor. Use program_point::origin.
7808 (exploded_graph::add_function_entry): Drop ctxt. Use
7809 program_state::push_frame. Drop state_change.
7810 (exploded_graph::get_or_create_node): Drop "change" param. Add
7811 "enode_for_diag" param. Update dumping calls for API changes.
7812 Pass point to can_merge_with_p. Show enode indices
7813 within -Wanalyzer-too-complex diagnostic for hitting the per-point
7814 limit.
7815 (exploded_graph::add_edge): Drop "change" param. Log which nodes
7816 are being connected. Update for changes to exploded_edge ctor.
7817 (exploded_graph::get_per_program_point_data): New.
7818 (exploded_graph::process_worklist): Pass point to
7819 can_merge_with_p. Drop state_change. Update dumping call for API
7820 change.
7821 (exploded_graph::process_node): Drop state_change. Split the
7822 node in-place if an sm-state-change occurs. Update
7823 m_num_processed_stmts. Update dumping calls for API change.
7824 (exploded_graph::log_stats): Call engine::log_stats.
7825 (exploded_graph::dump_states_for_supernode): Update dumping
7826 call.
7827 (exploded_path::feasible_p): Add "eng" and "eg" params.
7828 Rename "i" to "end_idx". Pass the manager to the region_model
7829 ctor. Update for every processed stmt in the enode, not just the
7830 first. Keep track of which snodes have been visited, and call
7831 loop_replay_fixup when revisiting one.
7832 (enode_label::get_text): Update dump call for new param.
7833 (exploded_graph::dump_exploded_nodes): Likewise.
7834 (exploded_graph::get_node_by_index): New.
7835 (impl_run_checkers): Create engine instance and pass its address
7836 to extrinsic_state ctor.
7837 * exploded-graph.h
7838 (impl_region_model_context::impl_region_model_context): Drop
7839 "change" params.
7840 (impl_region_model_context::void remap_svalue_ids): Delete.
7841 (impl_region_model_context::on_svalue_purge): Delete.
7842 (impl_region_model_context::on_svalue_leak): New.
7843 (impl_region_model_context::on_liveness_change): New.
7844 (impl_region_model_context::on_state_leak): Update signature.
7845 (impl_region_model_context::on_inherited_svalue): Delete.
7846 (impl_region_model_context::on_cast): Delete.
7847 (impl_region_model_context::on_unknown_change): Update signature.
7848 (impl_region_model_context::m_change): Delete.
7849 (eg_traits::dump_args_t::show_enode_details_p): New.
7850 (exploded_node::on_stmt): Drop "change" param.
7851 (exploded_node::on_edge): Likewise.
7852 (exploded_node::get_processed_stmt): New decl.
7853 (exploded_node::m_num_processed_stmts): New field.
7854 (exploded_edge::exploded_edge): Drop ext_state and change params.
7855 (exploded_edge::m_change): Delete.
7856 (exploded_graph::get_engine): New accessor.
7857 (exploded_graph::get_or_create_node): Drop "change" param. Add
7858 "enode_for_diag" param.
7859 (exploded_graph::add_edge): Drop "change" param.
7860 (exploded_graph::get_per_program_point_data): New decl.
7861 (exploded_graph::get_node_by_index): New decl.
7862 (exploded_path::feasible_p): Add "eng" and "eg" params.
7863 * program-point.cc: Include "analyzer/store.h" before including
7864 "analyzer/region-model.h".
7865 (function_point::function_point): Move here from
7866 program-point.h.
7867 (function_point::get_function): Likewise.
7868 (function_point::from_function_entry): Likewise.
7869 (function_point::before_supernode): Likewise.
7870 (function_point::next_stmt): New function.
7871 * program-point.h (function_point::function_point): Move
7872 implementation from here to program-point.cc.
7873 (function_point::get_function): Likewise.
7874 (function_point::from_function_entry): Likewise.
7875 (function_point::before_supernode): Likewise.
7876 (function_point::next_stmt): New decl.
7877 (program_point::operator!=): New.
7878 (program_point::origin): New.
7879 (program_point::next_stmt): New.
7880 (program_point::m_function_point): Make non-const.
7881 * program-state.cc: Move includes of "analyzer/call-string.h" and
7882 "analyzer/program-point.h" to before "analyzer/region-model.h",
7883 and also include "analyzer/store.h" before it.
7884 (extrinsic_state::get_model_manager): New.
7885 (sm_state_map::sm_state_map): Pass in sm and sm_idx to ctor,
7886 rather than pass the around.
7887 (sm_state_map::clone_with_remapping): Delete.
7888 (sm_state_map::print): Remove "sm" param in favor of "m_sm". Add
7889 "simple" and "multiline" params and support multiline vs single
7890 line dumping.
7891 (sm_state_map::dump): Remove "sm" param in favor of "m_sm". Add
7892 "simple" param.
7893 (sm_state_map::hash): Port from svalue_id to const svalue *.
7894 (sm_state_map::operator==): Likewise.
7895 (sm_state_map::get_state): Likewise. Call canonicalize_svalue on
7896 input. Handle inheritance of sm-state. Call get_default_state.
7897 (sm_state_map::get_origin): Port from svalue_id to const svalue *.
7898 (sm_state_map::set_state): Likewise. Pass in ext_state. Reject
7899 attempts to set state on UNKNOWN.
7900 (sm_state_map::impl_set_state): Port from svalue_id to
7901 const svalue *. Pass in ext_state. Call canonicalize_svalue on
7902 input.
7903 (sm_state_map::purge_for_unknown_fncall): Delete.
7904 (sm_state_map::on_svalue_leak): New.
7905 (sm_state_map::remap_svalue_ids): Delete.
7906 (sm_state_map::on_liveness_change): New.
7907 (sm_state_map::on_unknown_change): Reimplement.
7908 (sm_state_map::on_svalue_purge): Delete.
7909 (sm_state_map::on_inherited_svalue): Delete.
7910 (sm_state_map::on_cast): Delete.
7911 (sm_state_map::validate): Delete.
7912 (sm_state_map::canonicalize_svalue): New.
7913 (program_state::program_state): Update to pass manager to
7914 region_model's ctor. Constify num_states and pass state machine
7915 and index to sm_state_map ctor.
7916 (program_state::print): Update for changes to dump API.
7917 (program_state::dump_to_pp): Ignore the summarize param. Add
7918 "multiline" param.
7919 (program_state::dump_to_file): Add "multiline" param.
7920 (program_state::dump): Pass "true" for new "multiline" param.
7921 (program_state::push_frame): New.
7922 (program_state::on_edge): Drop "change" param. Call
7923 program_state::detect_leaks.
7924 (program_state::prune_for_point): Add enode_for_diag param.
7925 Reimplement based on store class. Call detect_leaks
7926 (program_state::remap_svalue_ids): Delete.
7927 (program_state::get_representative_tree): Port from svalue_id to
7928 const svalue *.
7929 (program_state::can_merge_with_p): Add "point" param. Add early
7930 reject for sm-differences. Drop id remapping.
7931 (program_state::validate): Drop region model and sm_state_map
7932 validation.
7933 (state_change::sm_change::dump): Delete.
7934 (state_change::sm_change::remap_svalue_ids): Delete.
7935 (state_change::sm_change::on_svalue_purge): Delete.
7936 (log_set_of_svalues): New.
7937 (state_change::sm_change::validate): Delete.
7938 (state_change::state_change): Delete.
7939 (state_change::add_sm_change): Delete.
7940 (state_change::affects_p): Delete.
7941 (state_change::dump): Delete.
7942 (state_change::remap_svalue_ids): Delete.
7943 (state_change::on_svalue_purge): Delete.
7944 (state_change::validate): Delete.
7945 (selftest::assert_dump_eq): Delete.
7946 (ASSERT_DUMP_EQ): Delete.
7947 (selftest::test_sm_state_map): Update for changes to region_model
7948 and sm_state_map, porting from svalue_id to const svalue *.
7949 (selftest::test_program_state_dumping): Likewise. Drop test of
7950 dumping, renaming to...
7951 (selftest::test_program_state_1): ...this.
7952 (selftest::test_program_state_dumping_2): Likewise, renaming to...
7953 (selftest::test_program_state_2): ...this.
7954 (selftest::test_program_state_merging): Update for changes to
7955 region_model.
7956 (selftest::test_program_state_merging_2): Likewise.
7957 (selftest::analyzer_program_state_cc_tests): Update for renamed
7958 tests.
7959 * program-state.h (extrinsic_state::extrinsic_state): Add logger
7960 and engine params.
7961 (extrinsic_state::get_logger): New accessor.
7962 (extrinsic_state::get_engine): New accessor.
7963 (extrinsic_state::get_model_manager): New accessor.
7964 (extrinsic_state::m_logger): New field.
7965 (extrinsic_state::m_engine): New field.
7966 (struct default_hash_traits<svalue_id>): Delete.
7967 (pod_hash_traits<svalue_id>::hash): Delete.
7968 (pod_hash_traits<svalue_id>::equal): Delete.
7969 (pod_hash_traits<svalue_id>::mark_deleted): Delete.
7970 (pod_hash_traits<svalue_id>::mark_empty): Delete.
7971 (pod_hash_traits<svalue_id>::is_deleted): Delete.
7972 (pod_hash_traits<svalue_id>::is_empty): Delete.
7973 (sm_state_map::entry_t::entry_t): Port from svalue_id to
7974 const svalue *.
7975 (sm_state_map::entry_t::m_origin): Likewise.
7976 (sm_state_map::map_t): Likewise.
7977 (sm_state_map::sm_state_map): Add state_machine and index params.
7978 (sm_state_map::clone_with_remapping): Delete.
7979 (sm_state_map::print): Drop sm param; add simple and multiline
7980 params.
7981 (sm_state_map::dump): Drop sm param; add simple param.
7982 (sm_state_map::get_state): Port from svalue_id to const svalue *.
7983 Add ext_state param.
7984 (sm_state_map::get_origin): Likewise.
7985 (sm_state_map::set_state): Likewise.
7986 (sm_state_map::impl_set_state): Likewise.
7987 (sm_state_map::purge_for_unknown_fncall): Delete.
7988 (sm_state_map::remap_svalue_ids): Delete.
7989 (sm_state_map::on_svalue_purge): Delete.
7990 (sm_state_map::on_svalue_leak): New.
7991 (sm_state_map::on_liveness_change): New.
7992 (sm_state_map::on_inherited_svalue): Delete.
7993 (sm_state_map::on_cast): Delete.
7994 (sm_state_map::validate): Delete.
7995 (sm_state_map::on_unknown_change): Port from svalue_id to
7996 const svalue *. Add is_mutable and ext_state params.
7997 (sm_state_map::canonicalize_svalue): New.
7998 (sm_state_map::m_sm): New field.
7999 (sm_state_map::m_sm_idx): New field.
8000 (program_state::operator=): Delete.
8001 (program_state::dump_to_pp): Drop "summarize" param, adding
8002 "simple" and "multiline".
8003 (program_state::dump_to_file): Likewise.
8004 (program_state::dump): Rename "summarize" to "simple".
8005 (program_state::push_frame): New.
8006 (program_state::get_current_function): New.
8007 (program_state::on_edge): Drop "change" param.
8008 (program_state::prune_for_point): Likewise. Add enode_for_diag
8009 param.
8010 (program_state::remap_svalue_ids): Delete.
8011 (program_state::get_representative_tree): Port from svalue_id to
8012 const svalue *.
8013 (program_state::can_purge_p): Likewise. Pass ext_state to get_state.
8014 (program_state::can_merge_with_p): Add point param.
8015 (program_state::detect_leaks): New.
8016 (state_change_visitor::on_state_change): Port from tree and
8017 svalue_id to a pair of const svalue *.
8018 (class state_change): Delete.
8019 * region.cc: New file.
8020 * region-model-impl-calls.cc: New file.
8021 * region-model-manager.cc: New file.
8022 * region-model-reachability.cc: New file.
8023 * region-model-reachability.h: New file.
8024 * region-model.cc: Include "analyzer/call-string.h",
8025 "analyzer/program-point.h", and "analyzer/store.h" before
8026 "analyzer/region-model.h". Include
8027 "analyzer/region-model-reachability.h".
8028 (dump_tree): Make non-static.
8029 (dump_quoted_tree): Make non-static.
8030 (print_quoted_type): Make non-static.
8031 (path_var::dump): Delete.
8032 (dump_separator): Delete.
8033 (class impl_constraint_manager): Delete.
8034 (svalue_id::print): Delete.
8035 (svalue_id::dump_node_name_to_pp): Delete.
8036 (svalue_id::validate): Delete.
8037 (region_id::print): Delete.
8038 (region_id::dump_node_name_to_pp): Delete.
8039 (region_id::validate): Delete.
8040 (region_id_set::region_id_set): Delete.
8041 (svalue_id_set::svalue_id_set): Delete.
8042 (svalue::operator==): Delete.
8043 (svalue::hash): Delete.
8044 (svalue::print): Delete.
8045 (svalue::dump_dot_to_pp): Delete.
8046 (svalue::remap_region_ids): Delete.
8047 (svalue::walk_for_canonicalization): Delete.
8048 (svalue::get_child_sid): Delete.
8049 (svalue::maybe_get_constant): Delete.
8050 (region_svalue::compare_fields): Delete.
8051 (region_svalue::add_to_hash): Delete.
8052 (region_svalue::print_details): Delete.
8053 (region_svalue::dump_dot_to_pp): Delete.
8054 (region_svalue::remap_region_ids): Delete.
8055 (region_svalue::merge_values): Delete.
8056 (region_svalue::walk_for_canonicalization): Delete.
8057 (region_svalue::eval_condition): Delete.
8058 (constant_svalue::compare_fields): Delete.
8059 (constant_svalue::add_to_hash): Delete.
8060 (constant_svalue::merge_values): Delete.
8061 (constant_svalue::eval_condition): Move to svalue.cc.
8062 (constant_svalue::print_details): Delete.
8063 (constant_svalue::get_child_sid): Delete.
8064 (unknown_svalue::compare_fields): Delete.
8065 (unknown_svalue::add_to_hash): Delete.
8066 (unknown_svalue::print_details): Delete.
8067 (poison_kind_to_str): Move to svalue.cc.
8068 (poisoned_svalue::compare_fields): Delete.
8069 (poisoned_svalue::add_to_hash): Delete.
8070 (poisoned_svalue::print_details): Delete.
8071 (region_kind_to_str): Move to region.cc and reimplement.
8072 (region::operator==): Delete.
8073 (region::get_parent_region): Delete.
8074 (region::set_value): Delete.
8075 (region::become_active_view): Delete.
8076 (region::deactivate_any_active_view): Delete.
8077 (region::deactivate_view): Delete.
8078 (region::get_value): Delete.
8079 (region::get_inherited_child_sid): Delete.
8080 (region_model::copy_region): Delete.
8081 (region_model::copy_struct_region): Delete.
8082 (region_model::copy_union_region): Delete.
8083 (region_model::copy_array_region): Delete.
8084 (region::hash): Delete.
8085 (region::print): Delete.
8086 (region::dump_dot_to_pp): Delete.
8087 (region::dump_to_pp): Delete.
8088 (region::dump_child_label): Delete.
8089 (region::validate): Delete.
8090 (region::remap_svalue_ids): Delete.
8091 (region::remap_region_ids): Delete.
8092 (region::add_view): Delete.
8093 (region::get_view): Delete.
8094 (region::region): Move to region.cc.
8095 (region::add_to_hash): Delete.
8096 (region::print_fields): Delete.
8097 (region::non_null_p): Delete.
8098 (primitive_region::clone): Delete.
8099 (primitive_region::walk_for_canonicalization): Delete.
8100 (map_region::map_region): Delete.
8101 (map_region::compare_fields): Delete.
8102 (map_region::print_fields): Delete.
8103 (map_region::validate): Delete.
8104 (map_region::dump_dot_to_pp): Delete.
8105 (map_region::dump_child_label): Delete.
8106 (map_region::get_or_create): Delete.
8107 (map_region::get): Delete.
8108 (map_region::add_to_hash): Delete.
8109 (map_region::remap_region_ids): Delete.
8110 (map_region::unbind): Delete.
8111 (map_region::get_tree_for_child_region): Delete.
8112 (map_region::get_tree_for_child_region): Delete.
8113 (tree_cmp): Move to region.cc.
8114 (map_region::can_merge_p): Delete.
8115 (map_region::walk_for_canonicalization): Delete.
8116 (map_region::get_value_by_name): Delete.
8117 (struct_or_union_region::valid_key_p): Delete.
8118 (struct_or_union_region::compare_fields): Delete.
8119 (struct_region::clone): Delete.
8120 (struct_region::compare_fields): Delete.
8121 (union_region::clone): Delete.
8122 (union_region::compare_fields): Delete.
8123 (frame_region::compare_fields): Delete.
8124 (frame_region::clone): Delete.
8125 (frame_region::valid_key_p): Delete.
8126 (frame_region::print_fields): Delete.
8127 (frame_region::add_to_hash): Delete.
8128 (globals_region::compare_fields): Delete.
8129 (globals_region::clone): Delete.
8130 (globals_region::valid_key_p): Delete.
8131 (code_region::compare_fields): Delete.
8132 (code_region::clone): Delete.
8133 (code_region::valid_key_p): Delete.
8134 (array_region::array_region): Delete.
8135 (array_region::get_element): Delete.
8136 (array_region::clone): Delete.
8137 (array_region::compare_fields): Delete.
8138 (array_region::print_fields): Delete.
8139 (array_region::validate): Delete.
8140 (array_region::dump_dot_to_pp): Delete.
8141 (array_region::dump_child_label): Delete.
8142 (array_region::get_or_create): Delete.
8143 (array_region::get): Delete.
8144 (array_region::add_to_hash): Delete.
8145 (array_region::remap_region_ids): Delete.
8146 (array_region::get_key_for_child_region): Delete.
8147 (array_region::key_cmp): Delete.
8148 (array_region::walk_for_canonicalization): Delete.
8149 (array_region::key_from_constant): Delete.
8150 (array_region::constant_from_key): Delete.
8151 (function_region::compare_fields): Delete.
8152 (function_region::clone): Delete.
8153 (function_region::valid_key_p): Delete.
8154 (stack_region::stack_region): Delete.
8155 (stack_region::compare_fields): Delete.
8156 (stack_region::clone): Delete.
8157 (stack_region::print_fields): Delete.
8158 (stack_region::dump_child_label): Delete.
8159 (stack_region::validate): Delete.
8160 (stack_region::push_frame): Delete.
8161 (stack_region::get_current_frame_id): Delete.
8162 (stack_region::pop_frame): Delete.
8163 (stack_region::add_to_hash): Delete.
8164 (stack_region::remap_region_ids): Delete.
8165 (stack_region::can_merge_p): Delete.
8166 (stack_region::walk_for_canonicalization): Delete.
8167 (stack_region::get_value_by_name): Delete.
8168 (heap_region::heap_region): Delete.
8169 (heap_region::compare_fields): Delete.
8170 (heap_region::clone): Delete.
8171 (heap_region::walk_for_canonicalization): Delete.
8172 (root_region::root_region): Delete.
8173 (root_region::compare_fields): Delete.
8174 (root_region::clone): Delete.
8175 (root_region::print_fields): Delete.
8176 (root_region::validate): Delete.
8177 (root_region::dump_child_label): Delete.
8178 (root_region::push_frame): Delete.
8179 (root_region::get_current_frame_id): Delete.
8180 (root_region::pop_frame): Delete.
8181 (root_region::ensure_stack_region): Delete.
8182 (root_region::get_stack_region): Delete.
8183 (root_region::ensure_globals_region): Delete.
8184 (root_region::get_code_region): Delete.
8185 (root_region::ensure_code_region): Delete.
8186 (root_region::get_globals_region): Delete.
8187 (root_region::ensure_heap_region): Delete.
8188 (root_region::get_heap_region): Delete.
8189 (root_region::remap_region_ids): Delete.
8190 (root_region::can_merge_p): Delete.
8191 (root_region::add_to_hash): Delete.
8192 (root_region::walk_for_canonicalization): Delete.
8193 (root_region::get_value_by_name): Delete.
8194 (symbolic_region::symbolic_region): Delete.
8195 (symbolic_region::compare_fields): Delete.
8196 (symbolic_region::clone): Delete.
8197 (symbolic_region::walk_for_canonicalization): Delete.
8198 (symbolic_region::print_fields): Delete.
8199 (region_model::region_model): Add region_model_manager * param.
8200 Reimplement in terms of store, dropping impl_constraint_manager
8201 subclass.
8202 (region_model::operator=): Reimplement in terms of store
8203 (region_model::operator==): Likewise.
8204 (region_model::hash): Likewise.
8205 (region_model::print): Delete.
8206 (region_model::print_svalue): Delete.
8207 (region_model::dump_dot_to_pp): Delete.
8208 (region_model::dump_dot_to_file): Delete.
8209 (region_model::dump_dot): Delete.
8210 (region_model::dump_to_pp): Replace "summarize" param with
8211 "simple" and "multiline". Port to store-based implementation.
8212 (region_model::dump): Replace "summarize" param with "simple" and
8213 "multiline".
8214 (dump_vec_of_tree): Delete.
8215 (region_model::dump_summary_of_rep_path_vars): Delete.
8216 (region_model::validate): Delete.
8217 (svalue_id_cmp_by_constant_svalue_model): Delete.
8218 (svalue_id_cmp_by_constant_svalue): Delete.
8219 (region_model::canonicalize): Drop "ctxt" param. Reimplement in
8220 terms of store and constraints.
8221 (region_model::canonicalized_p): Remove NULL arg to canonicalize.
8222 (region_model::loop_replay_fixup): New.
8223 (poisoned_value_diagnostic::emit): Tweak wording of warnings.
8224 (region_model::check_for_poison): Delete.
8225 (region_model::get_gassign_result): New.
8226 (region_model::on_assignment): Port to store-based implementation.
8227 (region_model::on_call_pre): Delete calls to check_for_poison.
8228 Move implementations to region-model-impl-calls.c and port to
8229 store-based implementation.
8230 (region_model::on_call_post): Likewise.
8231 (class reachable_regions): Move to region-model-reachability.h/cc
8232 and port to store-based implementation.
8233 (region_model::handle_unrecognized_call): Port to store-based
8234 implementation.
8235 (region_model::get_reachable_svalues): New.
8236 (region_model::on_setjmp): Port to store-based implementation.
8237 (region_model::on_longjmp): Likewise.
8238 (region_model::handle_phi): Drop is_back_edge param and the logic
8239 using it.
8240 (region_model::get_lvalue_1): Port from region_id to const region *.
8241 (region_model::make_region_for_unexpected_tree_code): Delete.
8242 (assert_compat_types): If the check fails, use internal_error to
8243 show the types.
8244 (region_model::get_lvalue): Port from region_id to const region *.
8245 (region_model::get_rvalue_1): Port from svalue_id to const svalue *.
8246 (region_model::get_rvalue): Likewise.
8247 (region_model::get_or_create_ptr_svalue): Delete.
8248 (region_model::get_or_create_constant_svalue): Delete.
8249 (region_model::get_svalue_for_fndecl): Delete.
8250 (region_model::get_region_for_fndecl): Delete.
8251 (region_model::get_svalue_for_label): Delete.
8252 (region_model::get_region_for_label): Delete.
8253 (build_cast): Delete.
8254 (region_model::maybe_cast_1): Delete.
8255 (region_model::maybe_cast): Delete.
8256 (region_model::get_field_region): Delete.
8257 (region_model::get_store_value): New.
8258 (region_model::region_exists_p): New.
8259 (region_model::deref_rvalue): Port from svalue_id to const svalue *.
8260 (region_model::set_value): Likewise.
8261 (region_model::clobber_region): New.
8262 (region_model::purge_region): New.
8263 (region_model::zero_fill_region): New.
8264 (region_model::mark_region_as_unknown): New.
8265 (region_model::eval_condition): Port from svalue_id to
8266 const svalue *.
8267 (region_model::eval_condition_without_cm): Likewise.
8268 (region_model::compare_initial_and_pointer): New.
8269 (region_model::add_constraint): Port from svalue_id to
8270 const svalue *.
8271 (region_model::maybe_get_constant): Delete.
8272 (region_model::get_representative_path_var): New.
8273 (region_model::add_new_malloc_region): Delete.
8274 (region_model::get_representative_tree): Port to const svalue *.
8275 (region_model::get_representative_path_var): Port to
8276 const region *.
8277 (region_model::get_path_vars_for_svalue): Delete.
8278 (region_model::set_to_new_unknown_value): Delete.
8279 (region_model::update_for_phis): Don't pass is_back_edge to handle_phi.
8280 (region_model::update_for_call_superedge): Port from svalue_id to
8281 const svalue *.
8282 (region_model::update_for_return_superedge): Port to store-based
8283 implementation.
8284 (region_model::update_for_call_summary): Replace
8285 set_to_new_unknown_value with mark_region_as_unknown.
8286 (region_model::get_root_region): Delete.
8287 (region_model::get_stack_region_id): Delete.
8288 (region_model::push_frame): Delete.
8289 (region_model::get_current_frame_id): Delete.
8290 (region_model::get_current_function): Delete.
8291 (region_model::pop_frame): Delete.
8292 (region_model::on_top_level_param): New.
8293 (region_model::get_stack_depth): Delete.
8294 (region_model::get_function_at_depth): Delete.
8295 (region_model::get_globals_region_id): Delete.
8296 (region_model::add_svalue): Delete.
8297 (region_model::replace_svalue): Delete.
8298 (region_model::add_region): Delete.
8299 (region_model::get_svalue): Delete.
8300 (region_model::get_region): Delete.
8301 (make_region_for_type): Delete.
8302 (region_model::add_region_for_type): Delete.
8303 (region_model::on_top_level_param): New.
8304 (class restrict_to_used_svalues): Delete.
8305 (region_model::purge_unused_svalues): Delete.
8306 (region_model::push_frame): New.
8307 (region_model::remap_svalue_ids): Delete.
8308 (region_model::remap_region_ids): Delete.
8309 (region_model::purge_regions): Delete.
8310 (region_model::get_descendents): Delete.
8311 (region_model::delete_region_and_descendents): Delete.
8312 (region_model::poison_any_pointers_to_bad_regions): Delete.
8313 (region_model::can_merge_with_p): Delete.
8314 (region_model::get_current_function): New.
8315 (region_model::get_value_by_name): Delete.
8316 (region_model::convert_byte_offset_to_array_index): Delete.
8317 (region_model::pop_frame): New.
8318 (region_model::get_or_create_mem_ref): Delete.
8319 (region_model::get_stack_depth): New.
8320 (region_model::get_frame_at_index): New.
8321 (region_model::unbind_region_and_descendents): New.
8322 (struct bad_pointer_finder): New.
8323 (region_model::get_or_create_pointer_plus_expr): Delete.
8324 (region_model::poison_any_pointers_to_descendents): New.
8325 (region_model::get_or_create_view): Delete.
8326 (region_model::can_merge_with_p): New.
8327 (region_model::get_fndecl_for_call): Port from svalue_id to
8328 const svalue *.
8329 (struct append_ssa_names_cb_data): New.
8330 (get_ssa_name_regions_for_current_frame): New.
8331 (region_model::append_ssa_names_cb): New.
8332 (model_merger::dump_to_pp): Add "simple" param. Drop dumping of
8333 remappings.
8334 (model_merger::dump): Add "simple" param to both overloads.
8335 (model_merger::can_merge_values_p): Delete.
8336 (model_merger::record_regions): Delete.
8337 (model_merger::record_svalues): Delete.
8338 (svalue_id_merger_mapping::svalue_id_merger_mapping): Delete.
8339 (svalue_id_merger_mapping::dump_to_pp): Delete.
8340 (svalue_id_merger_mapping::dump): Delete.
8341 (region_model::create_region_for_heap_alloc): New.
8342 (region_model::create_region_for_alloca): New.
8343 (region_model::record_dynamic_extents): New.
8344 (canonicalization::canonicalization): Delete.
8345 (canonicalization::walk_rid): Delete.
8346 (canonicalization::walk_sid): Delete.
8347 (canonicalization::dump_to_pp): Delete.
8348 (canonicalization::dump): Delete.
8349 (inchash::add): Delete overloads for svalue_id and region_id.
8350 (engine::log_stats): New.
8351 (assert_condition): Add overload comparing svalues.
8352 (assert_dump_eq): Pass "true" for multiline.
8353 (selftest::test_dump): Update for rewrite of region_model.
8354 (selftest::test_dump_2): Rename to...
8355 (selftest::test_struct): ...this. Provide a region_model_manager
8356 when creating region_model instance. Remove dump test. Add
8357 checks for get_offset.
8358 (selftest::test_dump_3): Rename to...
8359 (selftest::test_array_1): ...this. Provide a region_model_manager
8360 when creating region_model instance. Remove dump test.
8361 (selftest::test_get_representative_tree): Port from svalue_id to
8362 new API. Add test coverage for various expressions.
8363 (selftest::test_unique_constants): Provide a region_model_manager
8364 for the region_model. Add test coverage for comparing const vs
8365 non-const.
8366 (selftest::test_svalue_equality): Delete.
8367 (selftest::test_region_equality): Delete.
8368 (selftest::test_unique_unknowns): New.
8369 (class purge_all_svalue_ids): Delete.
8370 (class purge_one_svalue_id): Delete.
8371 (selftest::test_purging_by_criteria): Delete.
8372 (selftest::test_initial_svalue_folding): New.
8373 (selftest::test_unaryop_svalue_folding): New.
8374 (selftest::test_binop_svalue_folding): New.
8375 (selftest::test_sub_svalue_folding): New.
8376 (selftest::test_purge_unused_svalues): Delete.
8377 (selftest::test_descendent_of_p): New.
8378 (selftest::test_assignment): Provide a region_model_manager for
8379 the region_model. Drop the dump test.
8380 (selftest::test_compound_assignment): Likewise.
8381 (selftest::test_stack_frames): Port to new implementation.
8382 (selftest::test_get_representative_path_var): Likewise.
8383 (selftest::test_canonicalization_1): Rename to...
8384 (selftest::test_equality_1): ...this. Port to new API, and add
8385 (selftest::test_canonicalization_2): Provide a
8386 region_model_manager when creating region_model instances.
8387 Remove redundant canicalization.
8388 (selftest::test_canonicalization_3): Provide a
8389 region_model_manager when creating region_model instances.
8390 Remove param from calls to region_model::canonicalize.
8391 (selftest::test_canonicalization_4): Likewise.
8392 (selftest::assert_region_models_merge): Constify
8393 out_merged_svalue. Port to new API.
8394 (selftest::test_state_merging): Provide a
8395 region_model_manager when creating region_model instances.
8396 Provide a program_point point when merging them. Replace
8397 set_to_new_unknown_value with usage of placeholder_svalues.
8398 Drop get_value_by_name. Port from svalue_id to const svalue *.
8399 Add test of heap allocation.
8400 (selftest::test_constraint_merging): Provide a
8401 region_model_manager when creating region_model instances.
8402 Provide a program_point point when merging them. Eliminate use
8403 of set_to_new_unknown_value.
8404 (selftest::test_widening_constraints): New.
8405 (selftest::test_iteration_1): New.
8406 (selftest::test_malloc_constraints): Port to store-based
8407 implementation.
8408 (selftest::test_var): New test.
8409 (selftest::test_array_2): New test.
8410 (selftest::test_mem_ref): New test.
8411 (selftest::test_POINTER_PLUS_EXPR_then_MEM_REF): New.
8412 (selftest::test_malloc): New.
8413 (selftest::test_alloca): New.
8414 (selftest::analyzer_region_model_cc_tests): Update for renamings.
8415 Call new functions.
8416 * region-model.h (class path_var): Move to analyzer.h.
8417 (class svalue_id): Delete.
8418 (class region_id): Delete.
8419 (class id_map): Delete.
8420 (svalue_id_map): Delete.
8421 (region_id_map): Delete.
8422 (id_map<T>::id_map): Delete.
8423 (id_map<T>::put): Delete.
8424 (id_map<T>::get_dst_for_src): Delete.
8425 (id_map<T>::get_src_for_dst): Delete.
8426 (id_map<T>::dump_to_pp): Delete.
8427 (id_map<T>::dump): Delete.
8428 (id_map<T>::update): Delete.
8429 (one_way_svalue_id_map): Delete.
8430 (one_way_region_id_map): Delete.
8431 (class region_id_set): Delete.
8432 (class svalue_id_set): Delete.
8433 (struct complexity): New.
8434 (class visitor): New.
8435 (enum svalue_kind): Add SK_SETJMP, SK_INITIAL, SK_UNARYOP,
8436 SK_BINOP, SK_SUB,SK_UNMERGEABLE, SK_PLACEHOLDER, SK_WIDENING,
8437 SK_COMPOUND, and SK_CONJURED.
8438 (svalue::operator==): Delete.
8439 (svalue::operator!=): Delete.
8440 (svalue::clone): Delete.
8441 (svalue::hash): Delete.
8442 (svalue::dump_dot_to_pp): Delete.
8443 (svalue::dump_to_pp): New.
8444 (svalue::dump): New.
8445 (svalue::get_desc): New.
8446 (svalue::dyn_cast_initial_svalue): New.
8447 (svalue::dyn_cast_unaryop_svalue): New.
8448 (svalue::dyn_cast_binop_svalue): New.
8449 (svalue::dyn_cast_sub_svalue): New.
8450 (svalue::dyn_cast_unmergeable_svalue): New.
8451 (svalue::dyn_cast_widening_svalue): New.
8452 (svalue::dyn_cast_compound_svalue): New.
8453 (svalue::dyn_cast_conjured_svalue): New.
8454 (svalue::maybe_undo_cast): New.
8455 (svalue::unwrap_any_unmergeable): New.
8456 (svalue::remap_region_ids): Delete
8457 (svalue::can_merge_p): New.
8458 (svalue::walk_for_canonicalization): Delete
8459 (svalue::get_complexity): New.
8460 (svalue::get_child_sid): Delete
8461 (svalue::accept): New.
8462 (svalue::live_p): New.
8463 (svalue::implicitly_live_p): New.
8464 (svalue::svalue): Add complexity param.
8465 (svalue::add_to_hash): Delete
8466 (svalue::print_details): Delete
8467 (svalue::m_complexity): New field.
8468 (region_svalue::key_t): New struct.
8469 (region_svalue::region_svalue): Port from region_id to
8470 const region_id *. Add complexity.
8471 (region_svalue::compare_fields): Delete.
8472 (region_svalue::clone): Delete.
8473 (region_svalue::dump_dot_to_pp): Delete.
8474 (region_svalue::get_pointee): Port from region_id to
8475 const region_id *.
8476 (region_svalue::remap_region_ids): Delete.
8477 (region_svalue::merge_values): Delete.
8478 (region_svalue::dump_to_pp): New.
8479 (region_svalue::accept): New.
8480 (region_svalue::walk_for_canonicalization): Delete.
8481 (region_svalue::eval_condition): Make params const.
8482 (region_svalue::add_to_hash): Delete.
8483 (region_svalue::print_details): Delete.
8484 (region_svalue::m_rid): Replace with...
8485 (region_svalue::m_reg): ...this.
8486 (is_a_helper <region_svalue *>::test): Convert to...
8487 (is_a_helper <const region_svalue *>::test): ...this.
8488 (template <> struct default_hash_traits<region_svalue::key_t>):
8489 New.
8490 (constant_svalue::constant_svalue): Add complexity.
8491 (constant_svalue::compare_fields): Delete.
8492 (constant_svalue::clone): Delete.
8493 (constant_svalue::add_to_hash): Delete.
8494 (constant_svalue::dump_to_pp): New.
8495 (constant_svalue::accept): New.
8496 (constant_svalue::implicitly_live_p): New.
8497 (constant_svalue::merge_values): Delete.
8498 (constant_svalue::eval_condition): Make params const.
8499 (constant_svalue::get_child_sid): Delete.
8500 (constant_svalue::print_details): Delete.
8501 (is_a_helper <constant_svalue *>::test): Convert to...
8502 (is_a_helper <const constant_svalue *>::test): ...this.
8503 (class unknown_svalue): Update leading comment.
8504 (unknown_svalue::unknown_svalue): Add complexity.
8505 (unknown_svalue::compare_fields): Delete.
8506 (unknown_svalue::add_to_hash): Delete.
8507 (unknown_svalue::dyn_cast_unknown_svalue): Delete.
8508 (unknown_svalue::print_details): Delete.
8509 (unknown_svalue::dump_to_pp): New.
8510 (unknown_svalue::accept): New.
8511 (poisoned_svalue::key_t): New struct.
8512 (poisoned_svalue::poisoned_svalue): Add complexity.
8513 (poisoned_svalue::compare_fields): Delete.
8514 (poisoned_svalue::clone): Delete.
8515 (poisoned_svalue::add_to_hash): Delete.
8516 (poisoned_svalue::dump_to_pp): New.
8517 (poisoned_svalue::accept): New.
8518 (poisoned_svalue::print_details): Delete.
8519 (is_a_helper <poisoned_svalue *>::test): Convert to...
8520 (is_a_helper <const poisoned_svalue *>::test): ...this.
8521 (template <> struct default_hash_traits<poisoned_svalue::key_t>):
8522 New.
8523 (setjmp_record::add_to_hash): New.
8524 (setjmp_svalue::key_t): New struct.
8525 (setjmp_svalue::compare_fields): Delete.
8526 (setjmp_svalue::clone): Delete.
8527 (setjmp_svalue::add_to_hash): Delete.
8528 (setjmp_svalue::setjmp_svalue): Add complexity.
8529 (setjmp_svalue::dump_to_pp): New.
8530 (setjmp_svalue::accept): New.
8531 (setjmp_svalue::void print_details): Delete.
8532 (is_a_helper <const setjmp_svalue *>::test): New.
8533 (template <> struct default_hash_traits<setjmp_svalue::key_t>): New.
8534 (class initial_svalue : public svalue): New.
8535 (is_a_helper <const initial_svalue *>::test): New.
8536 (class unaryop_svalue): New.
8537 (is_a_helper <const unaryop_svalue *>::test): New.
8538 (template <> struct default_hash_traits<unaryop_svalue::key_t>): New.
8539 (class binop_svalue): New.
8540 (is_a_helper <const binop_svalue *>::test): New.
8541 (template <> struct default_hash_traits<binop_svalue::key_t>): New.
8542 (class sub_svalue): New.
8543 (is_a_helper <const sub_svalue *>::test): New.
8544 (template <> struct default_hash_traits<sub_svalue::key_t>): New.
8545 (class unmergeable_svalue): New.
8546 (is_a_helper <const unmergeable_svalue *>::test): New.
8547 (class placeholder_svalue): New.
8548 (is_a_helper <placeholder_svalue *>::test): New.
8549 (class widening_svalue): New.
8550 (is_a_helper <widening_svalue *>::test): New.
8551 (template <> struct default_hash_traits<widening_svalue::key_t>): New.
8552 (class compound_svalue): New.
8553 (is_a_helper <compound_svalue *>::test): New.
8554 (template <> struct default_hash_traits<compound_svalue::key_t>): New.
8555 (class conjured_svalue): New.
8556 (is_a_helper <conjured_svalue *>::test): New.
8557 (template <> struct default_hash_traits<conjured_svalue::key_t>): New.
8558 (enum region_kind): Delete RK_PRIMITIVE, RK_STRUCT, RK_UNION, and
8559 RK_ARRAY. Add RK_LABEL, RK_DECL, RK_FIELD, RK_ELEMENT, RK_OFFSET,
8560 RK_CAST, RK_HEAP_ALLOCATED, RK_ALLOCA, RK_STRING, and RK_UNKNOWN.
8561 (region_kind_to_str): Delete.
8562 (region::~region): Move implementation to region.cc.
8563 (region::operator==): Delete.
8564 (region::operator!=): Delete.
8565 (region::clone): Delete.
8566 (region::get_id): New.
8567 (region::cmp_ids): New.
8568 (region::dyn_cast_map_region): Delete.
8569 (region::dyn_cast_array_region): Delete.
8570 (region::region_id get_parent): Delete.
8571 (region::get_parent_region): Convert to a simple accessor.
8572 (region::void set_value): Delete.
8573 (region::svalue_id get_value): Delete.
8574 (region::svalue_id get_value_direct): Delete.
8575 (region::svalue_id get_inherited_child_sid): Delete.
8576 (region::dyn_cast_frame_region): New.
8577 (region::dyn_cast_function_region): New.
8578 (region::dyn_cast_decl_region): New.
8579 (region::dyn_cast_field_region): New.
8580 (region::dyn_cast_element_region): New.
8581 (region::dyn_cast_offset_region): New.
8582 (region::dyn_cast_cast_region): New.
8583 (region::dyn_cast_string_region): New.
8584 (region::accept): New.
8585 (region::get_base_region): New.
8586 (region::base_region_p): New.
8587 (region::descendent_of_p): New.
8588 (region::maybe_get_frame_region): New.
8589 (region::maybe_get_decl): New.
8590 (region::hash): Delete.
8591 (region::rint): Delete.
8592 (region::dump_dot_to_pp): Delete.
8593 (region::get_desc): New.
8594 (region::dump_to_pp): Convert to vfunc, changing signature.
8595 (region::dump_child_label): Delete.
8596 (region::remap_svalue_ids): Delete.
8597 (region::remap_region_ids): Delete.
8598 (region::dump): New.
8599 (region::walk_for_canonicalization): Delete.
8600 (region::non_null_p): Drop region_model param.
8601 (region::add_view): Delete.
8602 (region::get_view): Delete.
8603 (region::get_active_view): Delete.
8604 (region::is_view_p): Delete.
8605 (region::cmp_ptrs): New.
8606 (region::validate): Delete.
8607 (region::get_offset): New.
8608 (region::get_byte_size): New.
8609 (region::get_bit_size): New.
8610 (region::get_subregions_for_binding): New.
8611 (region::region): Add complexity param. Convert parent from
8612 region_id to const region *. Drop svalue_id. Drop copy ctor.
8613 (region::symbolic_for_unknown_ptr_p): New.
8614 (region::add_to_hash): Delete.
8615 (region::print_fields): Delete.
8616 (region::get_complexity): New accessor.
8617 (region::become_active_view): Delete.
8618 (region::deactivate_any_active_view): Delete.
8619 (region::deactivate_view): Delete.
8620 (region::calc_offset): New.
8621 (region::m_parent_rid): Delete.
8622 (region::m_sval_id): Delete.
8623 (region::m_complexity): New.
8624 (region::m_id): New.
8625 (region::m_parent): New.
8626 (region::m_view_rids): Delete.
8627 (region::m_is_view): Delete.
8628 (region::m_active_view_rid): Delete.
8629 (region::m_cached_offset): New.
8630 (is_a_helper <region *>::test): Convert to...
8631 (is_a_helper <const region *>::test): ... this.
8632 (class primitive_region): Delete.
8633 (class space_region): New.
8634 (class map_region): Delete.
8635 (is_a_helper <map_region *>::test): Delete.
8636 (class frame_region): Reimplement.
8637 (template <> struct default_hash_traits<frame_region::key_t>):
8638 New.
8639 (class globals_region): Reimplement.
8640 (is_a_helper <globals_region *>::test): Convert to...
8641 (is_a_helper <const globals_region *>::test): ...this.
8642 (class struct_or_union_region): Delete.
8643 (is_a_helper <struct_or_union_region *>::test): Delete.
8644 (class code_region): Reimplement.
8645 (is_a_helper <const code_region *>::test): New.
8646 (class struct_region): Delete.
8647 (is_a_helper <struct_region *>::test): Delete.
8648 (class function_region): Reimplement.
8649 (is_a_helper <function_region *>::test): Convert to...
8650 (is_a_helper <const function_region *>::test): ...this.
8651 (class union_region): Delete.
8652 (is_a_helper <union_region *>::test): Delete.
8653 (class label_region): New.
8654 (is_a_helper <const label_region *>::test): New.
8655 (class scope_region): Delete.
8656 (class stack_region): Reimplement.
8657 (is_a_helper <stack_region *>::test): Convert to...
8658 (is_a_helper <const stack_region *>::test): ...this.
8659 (class heap_region): Reimplement.
8660 (is_a_helper <heap_region *>::test): Convert to...
8661 (is_a_helper <const heap_region *>::test): ...this.
8662 (class root_region): Reimplement.
8663 (is_a_helper <root_region *>::test): Convert to...
8664 (is_a_helper <const root_region *>::test): ...this.
8665 (class symbolic_region): Reimplement.
8666 (is_a_helper <const symbolic_region *>::test): New.
8667 (template <> struct default_hash_traits<symbolic_region::key_t>):
8668 New.
8669 (class decl_region): New.
8670 (is_a_helper <const decl_region *>::test): New.
8671 (class field_region): New.
8672 (template <> struct default_hash_traits<field_region::key_t>): New.
8673 (class array_region): Delete.
8674 (class element_region): New.
8675 (is_a_helper <array_region *>::test): Delete.
8676 (is_a_helper <const element_region *>::test): New.
8677 (template <> struct default_hash_traits<element_region::key_t>):
8678 New.
8679 (class offset_region): New.
8680 (is_a_helper <const offset_region *>::test): New.
8681 (template <> struct default_hash_traits<offset_region::key_t>):
8682 New.
8683 (class cast_region): New.
8684 (is_a_helper <const cast_region *>::test): New.
8685 (template <> struct default_hash_traits<cast_region::key_t>): New.
8686 (class heap_allocated_region): New.
8687 (class alloca_region): New.
8688 (class string_region): New.
8689 (is_a_helper <const string_region *>::test): New.
8690 (class unknown_region): New.
8691 (class region_model_manager): New.
8692 (struct append_ssa_names_cb_data): New.
8693 (class call_details): New.
8694 (region_model::region_model): Add region_model_manager param.
8695 (region_model::print_svalue): Delete.
8696 (region_model::dump_dot_to_pp): Delete.
8697 (region_model::dump_dot_to_file): Delete.
8698 (region_model::dump_dot): Delete.
8699 (region_model::dump_to_pp): Drop summarize param in favor of
8700 simple and multiline.
8701 (region_model::dump): Likewise.
8702 (region_model::summarize_to_pp): Delete.
8703 (region_model::summarize): Delete.
8704 (region_model::void canonicalize): Drop ctxt param.
8705 (region_model::void check_for_poison): Delete.
8706 (region_model::get_gassign_result): New.
8707 (region_model::impl_call_alloca): New.
8708 (region_model::impl_call_analyzer_describe): New.
8709 (region_model::impl_call_analyzer_eval): New.
8710 (region_model::impl_call_builtin_expect): New.
8711 (region_model::impl_call_calloc): New.
8712 (region_model::impl_call_free): New.
8713 (region_model::impl_call_malloc): New.
8714 (region_model::impl_call_memset): New.
8715 (region_model::impl_call_strlen): New.
8716 (region_model::get_reachable_svalues): New.
8717 (region_model::handle_phi): Drop is_back_edge param.
8718 (region_model::region_id get_root_rid): Delete.
8719 (region_model::root_region *get_root_region): Delete.
8720 (region_model::region_id get_stack_region_id): Delete.
8721 (region_model::push_frame): Convert from region_id and svalue_id
8722 to const region * and const svalue *.
8723 (region_model::get_current_frame_id): Replace with...
8724 (region_model::get_current_frame): ...this.
8725 (region_model::pop_frame): Convert from region_id to
8726 const region *. Drop purge and stats param. Add out_result.
8727 (region_model::function *get_function_at_depth): Delete.
8728 (region_model::get_globals_region_id): Delete.
8729 (region_model::add_svalue): Delete.
8730 (region_model::replace_svalue): Delete.
8731 (region_model::add_region): Delete.
8732 (region_model::add_region_for_type): Delete.
8733 (region_model::get_svalue): Delete.
8734 (region_model::get_region): Delete.
8735 (region_model::get_lvalue): Convert from region_id to
8736 const region *.
8737 (region_model::get_rvalue): Convert from svalue_id to
8738 const svalue *.
8739 (region_model::get_or_create_ptr_svalue): Delete.
8740 (region_model::get_or_create_constant_svalue): Delete.
8741 (region_model::get_svalue_for_fndecl): Delete.
8742 (region_model::get_svalue_for_label): Delete.
8743 (region_model::get_region_for_fndecl): Delete.
8744 (region_model::get_region_for_label): Delete.
8745 (region_model::get_frame_at_index (int index) const;): New.
8746 (region_model::maybe_cast): Delete.
8747 (region_model::maybe_cast_1): Delete.
8748 (region_model::get_field_region): Delete.
8749 (region_model::id deref_rvalue): Convert from region_id and
8750 svalue_id to const region * and const svalue *. Drop overload,
8751 passing in both a tree and an svalue.
8752 (region_model::set_value): Convert from region_id and svalue_id to
8753 const region * and const svalue *.
8754 (region_model::set_to_new_unknown_value): Delete.
8755 (region_model::clobber_region (const region *reg);): New.
8756 (region_model::purge_region (const region *reg);): New.
8757 (region_model::zero_fill_region (const region *reg);): New.
8758 (region_model::mark_region_as_unknown (const region *reg);): New.
8759 (region_model::copy_region): Convert from region_id to
8760 const region *.
8761 (region_model::eval_condition): Convert from svalue_id to
8762 const svalue *.
8763 (region_model::eval_condition_without_cm): Likewise.
8764 (region_model::compare_initial_and_pointer): New.
8765 (region_model:maybe_get_constant): Delete.
8766 (region_model::add_new_malloc_region): Delete.
8767 (region_model::get_representative_tree): Convert from svalue_id to
8768 const svalue *.
8769 (region_model::get_representative_path_var): Delete decl taking a
8770 region_id in favor of two decls, for svalue vs region, with an
8771 svalue_set to ensure termination.
8772 (region_model::get_path_vars_for_svalue): Delete.
8773 (region_model::create_region_for_heap_alloc): New.
8774 (region_model::create_region_for_alloca): New.
8775 (region_model::purge_unused_svalues): Delete.
8776 (region_model::remap_svalue_ids): Delete.
8777 (region_model::remap_region_ids): Delete.
8778 (region_model::purge_regions): Delete.
8779 (region_model::get_num_svalues): Delete.
8780 (region_model::get_num_regions): Delete.
8781 (region_model::get_descendents): Delete.
8782 (region_model::get_store): New.
8783 (region_model::delete_region_and_descendents): Delete.
8784 (region_model::get_manager): New.
8785 (region_model::unbind_region_and_descendents): New.
8786 (region_model::can_merge_with_p): Add point param. Drop
8787 svalue_id_merger_mapping.
8788 (region_model::get_value_by_name): Delete.
8789 (region_model::convert_byte_offset_to_array_index): Delete.
8790 (region_model::get_or_create_mem_ref): Delete.
8791 (region_model::get_or_create_pointer_plus_expr): Delete.
8792 (region_model::get_or_create_view): Delete.
8793 (region_model::get_lvalue_1): Convert from region_id to
8794 const region *.
8795 (region_model::get_rvalue_1): Convert from svalue_id to
8796 const svalue *.
8797 (region_model::get_ssa_name_regions_for_current_frame): New.
8798 (region_model::append_ssa_names_cb): New.
8799 (region_model::get_store_value): New.
8800 (region_model::copy_struct_region): Delete.
8801 (region_model::copy_union_region): Delete.
8802 (region_model::copy_array_region): Delete.
8803 (region_model::region_exists_p): New.
8804 (region_model::make_region_for_unexpected_tree_code): Delete.
8805 (region_model::loop_replay_fixup): New.
8806 (region_model::poison_any_pointers_to_bad_regions): Delete.
8807 (region_model::poison_any_pointers_to_descendents): New.
8808 (region_model::dump_summary_of_rep_path_vars): Delete.
8809 (region_model::on_top_level_param): New.
8810 (region_model::record_dynamic_extents): New.
8811 (region_model::m_mgr;): New.
8812 (region_model::m_store;): New.
8813 (region_model::m_svalues;): Delete.
8814 (region_model::m_regions;): Delete.
8815 (region_model::m_root_rid;): Delete.
8816 (region_model::m_current_frame;): New.
8817 (region_model_context::remap_svalue_ids): Delete.
8818 (region_model_context::can_purge_p): Delete.
8819 (region_model_context::on_svalue_leak): New.
8820 (region_model_context::on_svalue_purge): Delete.
8821 (region_model_context::on_liveness_change): New.
8822 (region_model_context::on_inherited_svalue): Delete.
8823 (region_model_context::on_cast): Delete.
8824 (region_model_context::on_unknown_change): Convert from svalue_id to
8825 const svalue * and add is_mutable.
8826 (class noop_region_model_context): Update for region_model_context
8827 changes.
8828 (model_merger::model_merger): Add program_point. Drop
8829 svalue_id_merger_mapping.
8830 (model_merger::dump_to_pp): Add "simple" param.
8831 (model_merger::dump): Likewise.
8832 (model_merger::get_region_a): Delete.
8833 (model_merger::get_region_b): Delete.
8834 (model_merger::can_merge_values_p): Delete.
8835 (model_merger::record_regions): Delete.
8836 (model_merger::record_svalues): Delete.
8837 (model_merger::m_point): New field.
8838 (model_merger::m_map_regions_from_a_to_m): Delete.
8839 (model_merger::m_map_regions_from_b_to_m): Delete.
8840 (model_merger::m_sid_mapping): Delete.
8841 (struct svalue_id_merger_mapping): Delete.
8842 (class engine): New.
8843 (struct canonicalization): Delete.
8844 (inchash::add): Delete decls for hashing svalue_id and region_id.
8845 (test_region_model_context::on_unexpected_tree_code): Require t to
8846 be non-NULL.
8847 (selftest::assert_condition): Add overload comparing a pair of
8848 const svalue *.
8849 * sm-file.cc: Include "tristate.h", "selftest.h",
8850 "analyzer/call-string.h", "analyzer/program-point.h",
8851 "analyzer/store.h", and "analyzer/region-model.h".
8852 (fileptr_state_machine::get_default_state): New.
8853 (fileptr_state_machine::on_stmt): Remove calls to
8854 get_readable_tree in favor of get_diagnostic_tree.
8855 * sm-malloc.cc: Include "tristate.h", "selftest.h",
8856 "analyzer/call-string.h", "analyzer/program-point.h",
8857 "analyzer/store.h", and "analyzer/region-model.h".
8858 (malloc_state_machine::get_default_state): New.
8859 (malloc_state_machine::reset_when_passed_to_unknown_fn_p): New.
8860 (malloc_diagnostic::describe_state_change): Handle change.m_expr
8861 being NULL.
8862 (null_arg::emit): Avoid printing "NULL '0'".
8863 (null_arg::describe_final_event): Avoid printing "(0) NULL".
8864 (malloc_leak::emit): Handle m_arg being NULL.
8865 (malloc_leak::describe_final_event): Handle ev.m_expr being NULL.
8866 (malloc_state_machine::on_stmt): Don't call get_readable_tree.
8867 Call get_diagnostic_tree when creating pending diagnostics.
8868 Update for is_zero_assignment becoming a member function of
8869 sm_ctxt.
8870 Don't transition to m_non_heap for ADDR_EXPR(MEM_REF()).
8871 (malloc_state_machine::reset_when_passed_to_unknown_fn_p): New
8872 vfunc implementation.
8873 * sm-sensitive.cc (sensitive_state_machine::warn_for_any_exposure): Call
8874 get_diagnostic_tree and pass the result to warn_for_state.
8875 * sm-signal.cc: Move includes of "analyzer/call-string.h" and
8876 "analyzer/program-point.h" to before "analyzer/region-model.h",
8877 and also include "analyzer/store.h" before it.
8878 (signal_unsafe_call::describe_state_change): Use
8879 get_dest_function to get handler.
8880 (update_model_for_signal_handler): Pass manager to region_model
8881 ctor.
8882 (register_signal_handler::impl_transition): Update for changes to
8883 get_or_create_node and add_edge.
8884 * sm-taint.cc (taint_state_machine::on_stmt): Remove calls to
8885 get_readable_tree, replacing them when calling warn_for_state with
8886 calls to get_diagnostic_tree.
8887 * sm.cc (is_zero_assignment): Delete.
8888 (any_pointer_p): Move to within namespace ana.
8889 * sm.h (is_zero_assignment): Remove decl.
8890 (any_pointer_p): Move decl to within namespace ana.
8891 (state_machine::get_default_state): New vfunc.
8892 (state_machine::reset_when_passed_to_unknown_fn_p): New vfunc.
8893 (sm_context::get_readable_tree): Rename to...
8894 (sm_context::get_diagnostic_tree): ...this.
8895 (sm_context::is_zero_assignment): New vfunc.
8896 * store.cc: New file.
8897 * store.h: New file.
8898 * svalue.cc: New file.
8899
8900 2020-05-22 Mark Wielaard <mark@klomp.org>
8901
8902 * sm-signal.cc(signal_unsafe_call::emit): Possibly add
8903 gcc_rich_location note for replacement.
8904 (signal_unsafe_call::get_replacement_fn): New private function.
8905 (get_async_signal_unsafe_fns): Add "exit".
8906
8907 2020-04-28 David Malcolm <dmalcolm@redhat.com>
8908
8909 PR analyzer/94816
8910 * engine.cc (impl_region_model_context::on_unexpected_tree_code):
8911 Handle NULL tree.
8912 * region-model.cc (region_model::add_region_for_type): Handle
8913 NULL type.
8914 * region-model.h
8915 (test_region_model_context::on_unexpected_tree_code): Handle NULL
8916 tree.
8917
8918 2020-04-28 David Malcolm <dmalcolm@redhat.com>
8919
8920 PR analyzer/94447
8921 PR analyzer/94639
8922 PR analyzer/94732
8923 PR analyzer/94754
8924 * analyzer.opt (Wanalyzer-use-of-uninitialized-value): Delete.
8925 * program-state.cc (selftest::test_program_state_dumping): Update
8926 expected dump result for removal of "uninit".
8927 * region-model.cc (poison_kind_to_str): Delete POISON_KIND_UNINIT
8928 case.
8929 (root_region::ensure_stack_region): Initialize stack with null
8930 svalue_id rather than with a typeless POISON_KIND_UNINIT value.
8931 (root_region::ensure_heap_region): Likewise for the heap.
8932 (region_model::dump_summary_of_rep_path_vars): Remove
8933 summarization of uninit values.
8934 (region_model::validate): Remove check that the stack has a
8935 POISON_KIND_UNINIT value.
8936 (poisoned_value_diagnostic::emit): Remove POISON_KIND_UNINIT
8937 case.
8938 (poisoned_value_diagnostic::describe_final_event): Likewise.
8939 (selftest::test_dump): Update expected dump result for removal of
8940 "uninit".
8941 (selftest::test_svalue_equality): Remove "uninit" and "freed".
8942 * region-model.h (enum poison_kind): Remove POISON_KIND_UNINIT.
8943
8944 2020-04-01 David Malcolm <dmalcolm@redhat.com>
8945
8946 PR analyzer/94378
8947 * checker-path.cc: Include "bitmap.h".
8948 * constraint-manager.cc: Likewise.
8949 * diagnostic-manager.cc: Likewise.
8950 * engine.cc: Likewise.
8951 (exploded_node::detect_leaks): Pass null region_id to pop_frame.
8952 * program-point.cc: Include "bitmap.h".
8953 * program-state.cc: Likewise.
8954 * region-model.cc (id_set<region_id>::id_set): Convert to...
8955 (region_id_set::region_id_set): ...this.
8956 (svalue_id_set::svalue_id_set): New ctor.
8957 (region_model::copy_region): New function.
8958 (region_model::copy_struct_region): New function.
8959 (region_model::copy_union_region): New function.
8960 (region_model::copy_array_region): New function.
8961 (stack_region::pop_frame): Drop return value. Add
8962 "result_dst_rid" param; if it is non-null, use copy_region to copy
8963 the result to it. Rather than capture and pass a single "known
8964 used" return value to be used by purge_unused_values, instead
8965 gather and pass a set of known used return values.
8966 (root_region::pop_frame): Drop return value. Add "result_dst_rid"
8967 param.
8968 (region_model::on_assignment): Use copy_region.
8969 (region_model::on_return): Likewise for the result.
8970 (region_model::on_longjmp): Pass null for pop_frame's
8971 result_dst_rid.
8972 (region_model::update_for_return_superedge): Pass the region for the
8973 return value of the call, if any, to pop_frame, rather than setting
8974 the lvalue for the lhs of the result.
8975 (region_model::pop_frame): Drop return value. Add
8976 "result_dst_rid" param.
8977 (region_model::purge_unused_svalues): Convert third param from an
8978 svalue_id * to an svalue_id_set *, updating the initial populating
8979 of the "used" bitmap accordingly. Don't remap it when done.
8980 (struct selftest::coord_test): New selftest fixture, extracted from...
8981 (selftest::test_dump_2): ...here.
8982 (selftest::test_compound_assignment): New selftest.
8983 (selftest::test_stack_frames): Pass null to new param of pop_frame.
8984 (selftest::analyzer_region_model_cc_tests): Call the new selftest.
8985 * region-model.h (class id_set): Delete template.
8986 (class region_id_set): Reimplement, using old id_set implementation.
8987 (class svalue_id_set): Likewise. Convert from auto_sbitmap to
8988 auto_bitmap.
8989 (region::get_active_view): New accessor.
8990 (stack_region::pop_frame): Drop return value. Add
8991 "result_dst_rid" param.
8992 (root_region::pop_frame): Likewise.
8993 (region_model::pop_frame): Likewise.
8994 (region_model::copy_region): New decl.
8995 (region_model::purge_unused_svalues): Convert third param from an
8996 svalue_id * to an svalue_id_set *.
8997 (region_model::copy_struct_region): New decl.
8998 (region_model::copy_union_region): New decl.
8999 (region_model::copy_array_region): New decl.
9000
9001 2020-03-27 David Malcolm <dmalcolm@redhat.com>
9002
9003 * program-state.cc (selftest::test_program_state_dumping): Update
9004 expected dump to include symbolic_region's possibly_null field.
9005 * region-model.cc (symbolic_region::print_fields): New vfunc
9006 implementation.
9007 (region_model::add_constraint): Clear m_possibly_null from
9008 symbolic_regions now known to be non-NULL.
9009 (selftest::test_malloc_constraints): New selftest.
9010 (selftest::analyzer_region_model_cc_tests): Call it.
9011 * region-model.h (region::dyn_cast_symbolic_region): Add non-const
9012 overload.
9013 (symbolic_region::dyn_cast_symbolic_region): Implement it.
9014 (symbolic_region::print_fields): New vfunc override decl.
9015
9016 2020-03-27 David Malcolm <dmalcolm@redhat.com>
9017
9018 * analyzer.h (class feasibility_problem): New forward decl.
9019 * diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
9020 Initialize new fields m_status, m_epath_length, and m_problem.
9021 (saved_diagnostic::~saved_diagnostic): Delete m_problem.
9022 (dedupe_candidate::dedupe_candidate): Convert "sd" param from a
9023 const ref to a mutable ptr.
9024 (dedupe_winners::add): Convert "sd" param from a const ref to a
9025 mutable ptr. Record the length of the exploded_path. Record the
9026 feasibility/infeasibility of sd into sd, capturing a
9027 feasibility_problem when feasible_p fails, and storing it in sd.
9028 (diagnostic_manager::emit_saved_diagnostics): Update for pass by
9029 ptr rather than by const ref.
9030 * diagnostic-manager.h (class saved_diagnostic): Add new enum
9031 status. Add fields m_status, m_epath_length and m_problem.
9032 (saved_diagnostic::set_feasible): New member function.
9033 (saved_diagnostic::set_infeasible): New member function.
9034 (saved_diagnostic::get_feasibility_problem): New accessor.
9035 (saved_diagnostic::get_status): New accessor.
9036 (saved_diagnostic::set_epath_length): New member function.
9037 (saved_diagnostic::get_epath_length): New accessor.
9038 * engine.cc: Include "gimple-pretty-print.h".
9039 (exploded_path::feasible_p): Add OUT param and, if non-NULL, write
9040 a new feasibility_problem to it on failure.
9041 (viz_callgraph_node::dump_dot): Convert begin_tr calls to
9042 begin_trtd. Convert end_tr calls to end_tdtr.
9043 (class exploded_graph_annotator): New subclass of dot_annotator.
9044 (impl_run_checkers): Add a second -fdump-analyzer-supergraph dump
9045 after the analysis runs, using exploded_graph_annotator. dumping
9046 to DUMP_BASE_NAME.supergraph-eg.dot.
9047 * exploded-graph.h (exploded_node::get_dot_fillcolor): Make
9048 public.
9049 (exploded_path::feasible_p): Add OUT param.
9050 (class feasibility_problem): New class.
9051 * state-purge.cc (state_purge_annotator::add_node_annotations):
9052 Return a bool, add a "within_table" param.
9053 (print_vec_of_names): Convert begin_tr calls to begin_trtd.
9054 Convert end_tr calls to end_tdtr.
9055 (state_purge_annotator::add_stmt_annotations): Add "within_row"
9056 param.
9057 * state-purge.h ((state_purge_annotator::add_node_annotations):
9058 Return a bool, add a "within_table" param.
9059 (state_purge_annotator::add_stmt_annotations): Add "within_row"
9060 param.
9061 * supergraph.cc (supernode::dump_dot): Call add_node_annotations
9062 twice: as before, passing false for "within_table", then again
9063 with true when within the TABLE element. Convert some begin_tr
9064 calls to begin_trtd, and some end_tr calls to end_tdtr.
9065 Repeat each add_stmt_annotations call, distinguishing between
9066 calls that add TRs and those that add TDs to an existing TR.
9067 Add a call to add_after_node_annotations.
9068 * supergraph.h (dot_annotator::add_node_annotations): Add a
9069 "within_table" param.
9070 (dot_annotator::add_stmt_annotations): Add a "within_row" param.
9071 (dot_annotator::add_after_node_annotations): New vfunc.
9072
9073 2020-03-27 David Malcolm <dmalcolm@redhat.com>
9074
9075 * diagnostic-manager.cc (dedupe_winners::add): Show the
9076 exploded_node index in the log messages.
9077 (diagnostic_manager::emit_saved_diagnostics): Log a summary of
9078 m_saved_diagnostics at entry.
9079
9080 2020-03-27 David Malcolm <dmalcolm@redhat.com>
9081
9082 * supergraph.cc (superedge::dump): Add space before description;
9083 move newline to non-pretty_printer overload.
9084
9085 2020-03-18 David Malcolm <dmalcolm@redhat.com>
9086
9087 * region-model.cc: Include "stor-layout.h".
9088 (region_model::dump_to_pp): Rather than calling
9089 dump_summary_of_map on each of the current frame and the globals,
9090 instead get a vec of representative path_vars for all regions,
9091 and then dump a summary of all of them.
9092 (region_model::dump_summary_of_map): Delete, rewriting into...
9093 (region_model::dump_summary_of_rep_path_vars): ...this new
9094 function, working on a vec of path_vars.
9095 (region_model::set_value): New overload.
9096 (region_model::get_representative_path_var): Rename
9097 "parent_region" local to "parent_reg" and consolidate with other
9098 local. Guard test for grandparent being stack on parent_reg being
9099 non-NULL. Move handling for parent being an array_region to
9100 within guard for parent_reg being non-NULL.
9101 (selftest::make_test_compound_type): New function.
9102 (selftest::test_dump_2): New selftest.
9103 (selftest::test_dump_3): New selftest.
9104 (selftest::test_stack_frames): Update expected output from
9105 simplified dump to show "a" and "b" from parent frame and "y" in
9106 child frame.
9107 (selftest::analyzer_region_model_cc_tests): Call test_dump_2 and
9108 test_dump_3.
9109 * region-model.h (region_model::set_value): New overload decl.
9110 (region_model::dump_summary_of_map): Delete.
9111 (region_model::dump_summary_of_rep_path_vars): New.
9112
9113 2020-03-18 David Malcolm <dmalcolm@redhat.com>
9114
9115 * region-model.h (class noop_region_model_context): New subclass
9116 of region_model_context.
9117 (class tentative_region_model_context): Inherit from
9118 noop_region_model_context rather than from region_model_context;
9119 drop redundant vfunc implementations.
9120 (class test_region_model_context): Likewise.
9121
9122 2020-03-18 David Malcolm <dmalcolm@redhat.com>
9123
9124 * engine.cc (exploded_node::exploded_node): Move implementation
9125 here from header; accept point_and_state by const reference rather
9126 than by value.
9127 * exploded-graph.h (exploded_node::exploded_node): Pass
9128 point_and_state by const reference rather than by value. Move
9129 body to engine.cc.
9130
9131 2020-03-18 Jakub Jelinek <jakub@redhat.com>
9132
9133 * sm-malloc.cc (malloc_state_machine::on_stmt): Fix up duplicated word
9134 issue in a comment.
9135 * region-model.cc (region_model::make_region_for_unexpected_tree_code,
9136 region_model::delete_region_and_descendents): Likewise.
9137 * engine.cc (class exploded_cluster): Likewise.
9138 * diagnostic-manager.cc (class path_builder): Likewise.
9139
9140 2020-03-13 David Malcolm <dmalcolm@redhat.com>
9141
9142 PR analyzer/94099
9143 PR analyzer/94105
9144 * diagnostic-manager.cc (for_each_state_change): Bulletproof
9145 against errors in get_rvalue by passing a
9146 tentative_region_model_context and rejecting if there's an error.
9147 * region-model.cc (region_model::get_lvalue_1): When handling
9148 ARRAY_REF, handle results of error-handling. Handle NOP_EXPR.
9149
9150 2020-03-06 David Malcolm <dmalcolm@redhat.com>
9151
9152 * analyzer.h (class array_region): New forward decl.
9153 * program-state.cc (selftest::test_program_state_dumping_2): New.
9154 (selftest::analyzer_program_state_cc_tests): Call it.
9155 * region-model.cc (array_region::constant_from_key): New.
9156 (region_model::get_representative_tree): Handle region_svalue by
9157 generating an ADDR_EXPR.
9158 (region_model::get_representative_path_var): In view handling,
9159 remove erroneous TREE_TYPE when determining the type of the tree.
9160 Handle array regions and STRING_CST.
9161 (selftest::assert_dump_tree_eq): New.
9162 (ASSERT_DUMP_TREE_EQ): New macro.
9163 (selftest::test_get_representative_tree): New selftest.
9164 (selftest::analyzer_region_model_cc_tests): Call it.
9165 * region-model.h (region::dyn_cast_array_region): New vfunc.
9166 (array_region::dyn_cast_array_region): New vfunc implementation.
9167 (array_region::constant_from_key): New decl.
9168
9169 2020-03-06 David Malcolm <dmalcolm@redhat.com>
9170
9171 * analyzer.h (dump_quoted_tree): New decl.
9172 * engine.cc (exploded_node::dump_dot): Pass region model to
9173 sm_state_map::print.
9174 * program-state.cc: Include diagnostic-core.h.
9175 (sm_state_map::print): Add "model" param and use it to print
9176 representative trees. Only print origin information if non-null.
9177 (sm_state_map::dump): Pass NULL for model to print call.
9178 (program_state::print): Pass region model to sm_state_map::print.
9179 (program_state::dump_to_pp): Use spaces rather than newlines when
9180 summarizing. Pass region_model to sm_state_map::print.
9181 (ana::selftest::assert_dump_eq): New function.
9182 (ASSERT_DUMP_EQ): New macro.
9183 (ana::selftest::test_program_state_dumping): New function.
9184 (ana::selftest::analyzer_program_state_cc_tests): Call it.
9185 * program-state.h (program_state::print): Add model param.
9186 * region-model.cc (dump_quoted_tree): New function.
9187 (map_region::print_fields): Use dump_quoted_tree rather than
9188 %qE to avoid lang-dependent output.
9189 (map_region::dump_child_label): Likewise.
9190 (region_model::dump_summary_of_map): For SK_REGION, when
9191 get_representative_path_var fails, print the region id rather than
9192 erroneously printing NULL.
9193 * sm.cc (state_machine::get_state_by_name): New function.
9194 * sm.h (state_machine::get_state_by_name): New decl.
9195
9196 2020-03-04 David Malcolm <dmalcolm@redhat.com>
9197
9198 * region-model.cc (region::validate): Convert model param from ptr
9199 to reference. Update comment to reflect that it's now a vfunc.
9200 (map_region::validate): New vfunc implementation.
9201 (array_region::validate): New vfunc implementation.
9202 (stack_region::validate): New vfunc implementation.
9203 (root_region::validate): New vfunc implementation.
9204 (region_model::validate): Pass a reference rather than a pointer
9205 to the region::validate vfunc.
9206 * region-model.h (region::validate): Make virtual. Convert model
9207 param from ptr to reference.
9208 (map_region::validate): New vfunc decl.
9209 (array_region::validate): New vfunc decl.
9210 (stack_region::validate): New vfunc decl.
9211 (root_region::validate): New vfunc decl.
9212
9213 2020-03-04 David Malcolm <dmalcolm@redhat.com>
9214
9215 PR analyzer/93993
9216 * region-model.cc (region_model::on_call_pre): Handle
9217 BUILT_IN_EXPECT and its variants.
9218 (region_model::add_any_constraints_from_ssa_def_stmt): Split out
9219 gassign handling into add_any_constraints_from_gassign; add gcall
9220 handling.
9221 (region_model::add_any_constraints_from_gassign): New function,
9222 based on the above. Add handling for NOP_EXPR.
9223 (region_model::add_any_constraints_from_gcall): New function.
9224 (region_model::get_representative_path_var): Handle views.
9225 * region-model.h
9226 (region_model::add_any_constraints_from_ssa_def_stmt): New decl.
9227 (region_model::add_any_constraints_from_gassign): New decl.
9228
9229 2020-03-04 David Malcolm <dmalcolm@redhat.com>
9230
9231 PR analyzer/93993
9232 * checker-path.h (state_change_event::get_lvalue): Add ctxt param
9233 and pass it to region_model::get_value call.
9234 * diagnostic-manager.cc (get_any_origin): Pass a
9235 tentative_region_model_context to the calls to get_lvalue and reject
9236 the comparison if errors occur.
9237 (can_be_expr_of_interest_p): New function.
9238 (diagnostic_manager::prune_for_sm_diagnostic): Replace checks for
9239 CONSTANT_CLASS_P with calls to update_for_unsuitable_sm_exprs.
9240 Pass a tentative_region_model_context to the calls to
9241 state_change_event::get_lvalue and reject the comparison if errors
9242 occur.
9243 (diagnostic_manager::update_for_unsuitable_sm_exprs): New.
9244 * diagnostic-manager.h
9245 (diagnostic_manager::update_for_unsuitable_sm_exprs): New decl.
9246 * region-model.h (class tentative_region_model_context): New class.
9247
9248 2020-03-04 David Malcolm <dmalcolm@redhat.com>
9249
9250 * engine.cc (worklist::worklist): Remove unused field m_eg.
9251 (class viz_callgraph_edge): Remove unused field m_call_sedge.
9252 (class viz_callgraph): Remove unused field m_sg.
9253 * exploded-graph.h (worklist::::m_eg): Remove unused field.
9254
9255 2020-03-02 David Malcolm <dmalcolm@redhat.com>
9256
9257 * analyzer.opt (fanalyzer-show-duplicate-count): New option.
9258 * diagnostic-manager.cc
9259 (diagnostic_manager::emit_saved_diagnostic): Use the above to
9260 guard the printing of the duplicate count.
9261
9262 2020-03-02 David Malcolm <dmalcolm@redhat.com>
9263
9264 PR analyzer/93959
9265 * analyzer.cc (is_std_function_p): New function.
9266 (is_std_named_call_p): New functions.
9267 * analyzer.h (is_std_named_call_p): New decl.
9268 * sm-malloc.cc (malloc_state_machine::on_stmt): Check for "std::"
9269 variants when checking for malloc, calloc and free.
9270
9271 2020-02-26 David Malcolm <dmalcolm@redhat.com>
9272
9273 PR analyzer/93950
9274 * diagnostic-manager.cc
9275 (diagnostic_manager::prune_for_sm_diagnostic): Assert that var is
9276 either NULL or not a constant. When updating var, bulletproof
9277 against constant values.
9278
9279 2020-02-26 David Malcolm <dmalcolm@redhat.com>
9280
9281 PR analyzer/93947
9282 * region-model.cc (region_model::get_fndecl_for_call): Gracefully
9283 fail for fn_decls that don't have a cgraph_node.
9284
9285 2020-02-26 David Malcolm <dmalcolm@redhat.com>
9286
9287 * bar-chart.cc: New file.
9288 * bar-chart.h: New file.
9289 * engine.cc: Include "analyzer/bar-chart.h".
9290 (stats::log): Only log the m_num_nodes kinds that are non-zero.
9291 (stats::dump): Likewise when dumping.
9292 (stats::get_total_enodes): New.
9293 (exploded_graph::get_or_create_node): Increment the per-point-data
9294 m_excess_enodes when hitting the per-program-point limit on
9295 enodes.
9296 (exploded_graph::print_bar_charts): New.
9297 (exploded_graph::log_stats): Log the number of unprocessed enodes
9298 in the worklist. Call print_bar_charts.
9299 (exploded_graph::dump_stats): Print the number of unprocessed
9300 enodes in the worklist.
9301 * exploded-graph.h (stats::get_total_enodes): New decl.
9302 (struct per_program_point_data): Add field m_excess_enodes.
9303 (exploded_graph::print_bar_charts): New decl.
9304 * supergraph.cc (superedge::dump): New.
9305 (superedge::dump): New.
9306 * supergraph.h (supernode::get_function): New.
9307 (superedge::dump): New decl.
9308 (superedge::dump): New decl.
9309
9310 2020-02-24 David Malcolm <dmalcolm@redhat.com>
9311
9312 * engine.cc (exploded_graph::get_or_create_node): Dump the
9313 program_state to the pp, rather than to stderr.
9314
9315 2020-02-24 David Malcolm <dmalcolm@redhat.com>
9316
9317 PR analyzer/93032
9318 * sm.cc (make_checkers): Require the "taint" checker to be
9319 explicitly enabled.
9320
9321 2020-02-24 David Malcolm <dmalcolm@redhat.com>
9322
9323 PR analyzer/93899
9324 * engine.cc
9325 (impl_region_model_context::impl_region_model_context): Add logger
9326 param.
9327 * engine.cc (exploded_graph::add_function_entry): Create an
9328 impl_region_model_context and pass it to the push_frame call.
9329 Bail if the resulting state is invalid.
9330 (exploded_graph::build_initial_worklist): Likewise.
9331 (exploded_graph::build_initial_worklist): Handle the case where
9332 add_function_entry fails.
9333 * exploded-graph.h
9334 (impl_region_model_context::impl_region_model_context): Add logger
9335 param.
9336 * region-model.cc (map_region::get_or_create): Add ctxt param and
9337 pass it to add_region_for_type.
9338 (map_region::can_merge_p): Pass NULL as a ctxt to call to
9339 get_or_create.
9340 (array_region::get_element): Pass ctxt to call to get_or_create.
9341 (array_region::get_or_create): Add ctxt param and pass it to
9342 add_region_for_type.
9343 (root_region::push_frame): Pass ctxt to get_or_create calls.
9344 (region_model::get_lvalue_1): Likewise.
9345 (region_model::make_region_for_unexpected_tree_code): Assert that
9346 ctxt is non-NULL.
9347 (region_model::get_rvalue_1): Pass ctxt to get_svalue_for_fndecl
9348 and get_svalue_for_label calls.
9349 (region_model::get_svalue_for_fndecl): Add ctxt param and pass it
9350 to get_region_for_fndecl.
9351 (region_model::get_region_for_fndecl): Add ctxt param and pass it
9352 to get_or_create.
9353 (region_model::get_svalue_for_label): Add ctxt param and pass it
9354 to get_region_for_label.
9355 (region_model::get_region_for_label): Add ctxt param and pass it
9356 to get_region_for_fndecl and get_or_create.
9357 (region_model::get_field_region): Add ctxt param and pass it to
9358 get_or_create_view and get_or_create.
9359 (make_region_for_type): Replace gcc_unreachable with return NULL.
9360 (region_model::add_region_for_type): Add ctxt param. Handle a
9361 return of NULL from make_region_for_type by calling
9362 make_region_for_unexpected_tree_code.
9363 (region_model::get_or_create_mem_ref): Pass ctxt to calls to
9364 get_or_create_view.
9365 (region_model::get_or_create_view): Add ctxt param and pass it to
9366 add_region_for_type.
9367 (selftest::test_state_merging): Pass ctxt to get_or_create_view.
9368 * region-model.h (region_model::get_or_create): Add ctxt param.
9369 (region_model::add_region_for_type): Likewise.
9370 (region_model::get_svalue_for_fndecl): Likewise.
9371 (region_model::get_svalue_for_label): Likewise.
9372 (region_model::get_region_for_fndecl): Likewise.
9373 (region_model::get_region_for_label): Likewise.
9374 (region_model::get_field_region): Likewise.
9375 (region_model::get_or_create_view): Likewise.
9376
9377 2020-02-24 David Malcolm <dmalcolm@redhat.com>
9378
9379 * checker-path.cc (superedge_event::should_filter_p): Update
9380 filter for empty descriptions to cover verbosity level 3 as well
9381 as 2.
9382 * diagnostic-manager.cc: Include "analyzer/reachability.h".
9383 (class path_builder): New class.
9384 (diagnostic_manager::emit_saved_diagnostic): Create a path_builder
9385 and pass it to build_emission_path, rather passing eg; similarly
9386 for add_events_for_eedge and ext_state.
9387 (diagnostic_manager::build_emission_path): Replace "eg" param
9388 with a path_builder, pass it to add_events_for_eedge.
9389 (diagnostic_manager::add_events_for_eedge): Replace ext_state
9390 param with path_builder; pass it to add_events_for_superedge.
9391 (diagnostic_manager::significant_edge_p): New.
9392 (diagnostic_manager::add_events_for_superedge): Add path_builder
9393 param. Reject insignificant edges at verbosity levels below 3.
9394 (diagnostic_manager::prune_for_sm_diagnostic): Update highest
9395 verbosity level to 4.
9396 * diagnostic-manager.h (class path_builder): New forward decl.
9397 (diagnostic_manager::build_emission_path): Replace "eg" param
9398 with a path_builder.
9399 (diagnostic_manager::add_events_for_eedge): Replace ext_state
9400 param with path_builder.
9401 (diagnostic_manager::significant_edge_p): New.
9402 (diagnostic_manager::add_events_for_superedge): Add path_builder
9403 param.
9404 * reachability.h: New file.
9405
9406 2020-02-18 David Malcolm <dmalcolm@redhat.com>
9407
9408 PR analyzer/93692
9409 * analyzer.opt (fdump-analyzer-callgraph): Rewrite description.
9410
9411 2020-02-18 David Malcolm <dmalcolm@redhat.com>
9412
9413 PR analyzer/93777
9414 * region-model.cc (region_model::maybe_cast_1): Replace assertion
9415 that build_cast returns non-NULL with a conditional, falling
9416 through to the logic which returns a new unknown value of the
9417 desired type if it fails.
9418
9419 2020-02-18 David Malcolm <dmalcolm@redhat.com>
9420
9421 PR analyzer/93778
9422 * engine.cc (impl_region_model_context::on_unknown_tree_code):
9423 Rename to...
9424 (impl_region_model_context::on_unexpected_tree_code): ...this and
9425 convert first argument from path_var to tree.
9426 (exploded_node::on_stmt): Pass ctxt to purge_for_unknown_fncall.
9427 * exploded-graph.h (region_model_context::on_unknown_tree_code):
9428 Rename to...
9429 (region_model_context::on_unexpected_tree_code): ...this and
9430 convert first argument from path_var to tree.
9431 * program-state.cc (sm_state_map::purge_for_unknown_fncall): Add
9432 ctxt param and pass on to calls to get_rvalue.
9433 * program-state.h (sm_state_map::purge_for_unknown_fncall): Add
9434 ctxt param.
9435 * region-model.cc (region_model::handle_unrecognized_call): Pass
9436 ctxt on to call to get_rvalue.
9437 (region_model::get_lvalue_1): Move body of default case to
9438 region_model::make_region_for_unexpected_tree_code and call it.
9439 Within COMPONENT_REF case, reject attempts to handle types other
9440 than RECORD_TYPE and UNION_TYPE.
9441 (region_model::make_region_for_unexpected_tree_code): New
9442 function, based on default case of region_model::get_lvalue_1.
9443 * region-model.h
9444 (region_model::make_region_for_unexpected_tree_code): New decl.
9445 (region_model::on_unknown_tree_code): Rename to...
9446 (region_model::on_unexpected_tree_code): ...this and convert first
9447 argument from path_var to tree.
9448 (class test_region_model_context): Update vfunc implementation for
9449 above change.
9450
9451 2020-02-18 David Malcolm <dmalcolm@redhat.com>
9452
9453 PR analyzer/93774
9454 * region-model.cc
9455 (region_model::convert_byte_offset_to_array_index): Use
9456 int_size_in_bytes before calling size_in_bytes, to gracefully fail
9457 on incomplete types.
9458
9459 2020-02-17 David Malcolm <dmalcolm@redhat.com>
9460
9461 PR analyzer/93775
9462 * region-model.cc (region_model::get_fndecl_for_call): Handle the
9463 case where the code_region's get_tree_for_child_region returns
9464 NULL.
9465
9466 2020-02-17 David Malcolm <dmalcolm@redhat.com>
9467
9468 PR analyzer/93388
9469 * engine.cc (impl_region_model_context::on_unknown_tree_code):
9470 New.
9471 (exploded_graph::get_or_create_node): Reject invalid states.
9472 * exploded-graph.h
9473 (impl_region_model_context::on_unknown_tree_code): New decl.
9474 (point_and_state::point_and_state): Assert that the state is
9475 valid.
9476 * program-state.cc (program_state::program_state): Initialize
9477 m_valid to true.
9478 (program_state::operator=): Copy m_valid.
9479 (program_state::program_state): Likewise for move constructor.
9480 (program_state::print): Print m_valid.
9481 (program_state::dump_to_pp): Likewise.
9482 * program-state.h (program_state::m_valid): New field.
9483 * region-model.cc (region_model::get_lvalue_1): Implement the
9484 default case by returning a new symbolic region and calling
9485 the context's on_unknown_tree_code, rather than issuing an
9486 internal_error. Implement VIEW_CONVERT_EXPR.
9487 * region-model.h (region_model_context::on_unknown_tree_code): New
9488 vfunc.
9489 (test_region_model_context::on_unknown_tree_code): New.
9490
9491 2020-02-17 David Malcolm <dmalcolm@redhat.com>
9492
9493 * sm-malloc.cc (malloc_diagnostic::describe_state_change): For
9494 transition to the "null" state, only say "assuming" when
9495 transitioning from the "unchecked" state.
9496
9497 2020-02-17 David Malcolm <dmalcolm@redhat.com>
9498
9499 * diagnostic-manager.h (diagnostic_manager::get_saved_diagnostic):
9500 Add const overload.
9501 * engine.cc (exploded_node::dump_dot): Dump saved_diagnostics.
9502 * exploded-graph.h (exploded_graph::get_diagnostic_manager): Add
9503 const overload.
9504
9505 2020-02-11 David Malcolm <dmalcolm@redhat.com>
9506
9507 PR analyzer/93288
9508 * analysis-plan.cc (analysis_plan::use_summary_p): Look through
9509 the ultimate_alias_target when getting the called function.
9510 * engine.cc (exploded_node::on_stmt): Rename second "ctxt" to
9511 "sm_ctxt". Use the region_model's get_fndecl_for_call rather than
9512 gimple_call_fndecl.
9513 * region-model.cc (region_model::get_fndecl_for_call): Use
9514 ultimate_alias_target on fndecl.
9515 * supergraph.cc (get_ultimate_function_for_cgraph_edge): New
9516 function.
9517 (supergraph_call_edge): Use it when rejecting edges without
9518 functions.
9519 (supergraph::supergraph): Use it to get the function for the
9520 cgraph_edge when building interprocedural superedges.
9521 (callgraph_superedge::get_callee_function): Use it.
9522 * supergraph.h (supergraph::get_num_snodes): Make param const.
9523 (supergraph::function_to_num_snodes_t): Make first type param
9524 const.
9525
9526 2020-02-11 David Malcolm <dmalcolm@redhat.com>
9527
9528 PR analyzer/93374
9529 * engine.cc (exploded_edge::exploded_edge): Add ext_state param
9530 and pass it to change.validate.
9531 (exploded_graph::get_or_create_node): Move purging of change
9532 svalues to also cover the case of reusing an existing enode.
9533 (exploded_graph::add_edge): Pass m_ext_state to exploded_edge's
9534 ctor.
9535 * exploded-graph.h (exploded_edge::exploded_edge): Add ext_state
9536 param.
9537 * program-state.cc (state_change::sm_change::validate): Likewise.
9538 Assert that m_sm_idx is sane. Use ext_state to validate
9539 m_old_state and m_new_state.
9540 (state_change::validate): Add ext_state param and pass it to
9541 the sm_change validate calls.
9542 * program-state.h (state_change::sm_change::validate): Add
9543 ext_state param.
9544 (state_change::validate): Likewise.
9545
9546 2020-02-11 David Malcolm <dmalcolm@redhat.com>
9547
9548 PR analyzer/93669
9549 * engine.cc (exploded_graph::dump_exploded_nodes): Handle missing
9550 case of STATUS_WORKLIST in implementation of
9551 "__analyzer_dump_exploded_nodes".
9552
9553 2020-02-11 David Malcolm <dmalcolm@redhat.com>
9554
9555 PR analyzer/93649
9556 * constraint-manager.cc (constraint_manager::add_constraint): When
9557 merging equivalence classes and updating m_constant, also update
9558 m_cst_sid.
9559 (constraint_manager::validate): If m_constant is non-NULL assert
9560 that m_cst_sid is non-null and is valid.
9561
9562 2020-02-11 David Malcolm <dmalcolm@redhat.com>
9563
9564 PR analyzer/93657
9565 * analyzer.opt (fdump-analyzer): Reword description.
9566 (fdump-analyzer-stderr): Likewise.
9567
9568 2020-02-11 David Malcolm <dmalcolm@redhat.com>
9569
9570 * region-model.cc (print_quoted_type): New function.
9571 (svalue::print): Use it to replace %qT.
9572 (region::dump_to_pp): Likewise.
9573 (region::dump_child_label): Likewise.
9574 (region::print_fields): Likewise.
9575
9576 2020-02-10 David Malcolm <dmalcolm@redhat.com>
9577
9578 PR analyzer/93659
9579 * analyzer.opt (-param=analyzer-max-recursion-depth=): Fix "tha"
9580 -> "that" typo.
9581 (Wanalyzer-use-of-uninitialized-value): Fix "initialized" ->
9582 "uninitialized" typo.
9583
9584 2020-02-10 David Malcolm <dmalcolm@redhat.com>
9585
9586 PR analyzer/93350
9587 * region-model.cc (region_model::get_lvalue_1):
9588 Handle BIT_FIELD_REF.
9589 (make_region_for_type): Handle VECTOR_TYPE.
9590
9591 2020-02-10 David Malcolm <dmalcolm@redhat.com>
9592
9593 PR analyzer/93647
9594 * diagnostic-manager.cc
9595 (diagnostic_manager::prune_for_sm_diagnostic): Bulletproof against
9596 VAR being constant.
9597 * region-model.cc (region_model::get_lvalue_1): Provide a better
9598 error message when encountering an unhandled tree code.
9599
9600 2020-02-10 David Malcolm <dmalcolm@redhat.com>
9601
9602 PR analyzer/93405
9603 * region-model.cc (region_model::get_lvalue_1): Implement
9604 CONST_DECL.
9605
9606 2020-02-06 David Malcolm <dmalcolm@redhat.com>
9607
9608 * region-model.cc (region_model::maybe_cast_1): Attempt to provide
9609 a region_svalue if either type is a pointer, rather than if both
9610 types are pointers.
9611
9612 2020-02-05 David Malcolm <dmalcolm@redhat.com>
9613
9614 * engine.cc (exploded_node::dump_dot): Show merger enodes.
9615 (worklist::add_node): Assert that the node's m_status is
9616 STATUS_WORKLIST.
9617 (exploded_graph::process_worklist): Likewise for nodes from the
9618 worklist. Set status of merged nodes to STATUS_MERGER.
9619 (exploded_graph::process_node): Set status of node to
9620 STATUS_PROCESSED.
9621 (exploded_graph::dump_exploded_nodes): Rework handling of
9622 "__analyzer_dump_exploded_nodes", splitting enodes by status into
9623 "processed" and "merger", showing the count of just the processed
9624 enodes at the call, rather than the count of all enodes.
9625 * exploded-graph.h (exploded_node::status): New enum.
9626 (exploded_node::exploded_node): Initialize m_status to
9627 STATUS_WORKLIST.
9628 (exploded_node::get_status): New getter.
9629 (exploded_node::set_status): New setter.
9630
9631 2020-02-04 David Malcolm <dmalcolm@redhat.com>
9632
9633 PR analyzer/93543
9634 * engine.cc (pod_hash_traits<function_call_string>::mark_empty):
9635 Eliminate reinterpret_cast.
9636 (pod_hash_traits<function_call_string>::is_empty): Likewise.
9637
9638 2020-02-03 David Malcolm <dmalcolm@redhat.com>
9639
9640 * constraint-manager.cc (range::constrained_to_single_element):
9641 Replace fold_build2 with fold_binary. Remove unnecessary newline.
9642 (constraint_manager::get_or_add_equiv_class): Replace fold_build2
9643 with fold_binary in two places, and remove out-of-date comment.
9644 (constraint_manager::eval_condition): Replace fold_build2 with
9645 fold_binary.
9646 * region-model.cc (constant_svalue::eval_condition): Likewise.
9647 (region_model::on_assignment): Likewise.
9648
9649 2020-02-03 David Malcolm <dmalcolm@redhat.com>
9650
9651 PR analyzer/93544
9652 * diagnostic-manager.cc
9653 (diagnostic_manager::prune_for_sm_diagnostic): Bulletproof
9654 against bad choices due to bad paths.
9655 * engine.cc (impl_region_model_context::on_phi): New.
9656 * exploded-graph.h (impl_region_model_context::on_phi): New decl.
9657 * region-model.cc (region_model::on_longjmp): Likewise.
9658 (region_model::handle_phi): Add phi param. Call the ctxt's on_phi
9659 vfunc.
9660 (region_model::update_for_phis): Pass phi to handle_phi.
9661 * region-model.h (region_model::handle_phi): Add phi param.
9662 (region_model_context::on_phi): New vfunc.
9663 (test_region_model_context::on_phi): New.
9664 * sm-malloc.cc (malloc_state_machine::on_phi): New.
9665 (malloc_state_machine::on_zero_assignment): New.
9666 * sm.h (state_machine::on_phi): New vfunc.
9667
9668 2020-02-03 David Malcolm <dmalcolm@redhat.com>
9669
9670 * engine.cc (supernode_cluster::dump_dot): Show BB index as
9671 well as SN index.
9672 * supergraph.cc (supernode::dump_dot): Likewise.
9673
9674 2020-02-03 David Malcolm <dmalcolm@redhat.com>
9675
9676 PR analyzer/93546
9677 * region-model.cc (region_model::on_call_pre): Update for new
9678 param of symbolic_region ctor.
9679 (region_model::deref_rvalue): Likewise.
9680 (region_model::add_new_malloc_region): Likewise.
9681 (make_region_for_type): Likewise, preserving type.
9682 * region-model.h (symbolic_region::symbolic_region): Add "type"
9683 param and pass it to base class ctor.
9684
9685 2020-02-03 David Malcolm <dmalcolm@redhat.com>
9686
9687 PR analyzer/93547
9688 * constraint-manager.cc
9689 (constraint_manager::get_or_add_equiv_class): Ensure types are
9690 compatible before comparing constants.
9691
9692 2020-01-31 David Malcolm <dmalcolm@redhat.com>
9693
9694 PR analyzer/93457
9695 * region-model.cc (make_region_for_type): Use VOID_TYPE_P rather
9696 than checking against void_type_node.
9697
9698 2020-01-31 David Malcolm <dmalcolm@redhat.com>
9699
9700 PR analyzer/93373
9701 * region-model.cc (ASSERT_COMPAT_TYPES): Convert to...
9702 (assert_compat_types): ...this, and bail when either type is NULL,
9703 or when VOID_TYPE_P (dst_type).
9704 (region_model::get_lvalue): Update for above conversion.
9705 (region_model::get_rvalue): Likewise.
9706
9707 2020-01-31 David Malcolm <dmalcolm@redhat.com>
9708
9709 PR analyzer/93379
9710 * region-model.cc (region_model::update_for_return_superedge):
9711 Move check for null result so that it also guards setting the
9712 lhs.
9713
9714 2020-01-31 David Malcolm <dmalcolm@redhat.com>
9715
9716 PR analyzer/93438
9717 * region-model.cc (stack_region::can_merge_p): Split into a two
9718 pass approach, creating all stack regions first, then populating
9719 them.
9720 (selftest::test_state_merging): Add test coverage for (a) the case
9721 of self-merging a model in which a local in an older stack frame
9722 points to a local in a more recent stack frame (which previously
9723 would ICE), and (b) the case of self-merging a model in which a
9724 local points to a global (which previously worked OK).
9725
9726 2020-01-31 David Malcolm <dmalcolm@redhat.com>
9727
9728 * analyzer.cc (is_named_call_p): Replace tests for fndecl being
9729 extern at file scope and having a non-NULL DECL_NAME with a call
9730 to maybe_special_function_p.
9731 * function-set.cc (function_set::contains_decl_p): Add call to
9732 maybe_special_function_p.
9733
9734 2020-01-31 David Malcolm <dmalcolm@redhat.com>
9735
9736 PR analyzer/93450
9737 * constraint-manager.cc
9738 (constraint_manager::get_or_add_equiv_class): Only compare constants
9739 if their types are compatible.
9740 * region-model.cc (constant_svalue::eval_condition): Replace check
9741 for identical types with call to types_compatible_p.
9742
9743 2020-01-30 David Malcolm <dmalcolm@redhat.com>
9744
9745 * program-state.cc (extrinsic_state::dump_to_pp): New.
9746 (extrinsic_state::dump_to_file): New.
9747 (extrinsic_state::dump): New.
9748 * program-state.h (extrinsic_state::dump_to_pp): New decl.
9749 (extrinsic_state::dump_to_file): New decl.
9750 (extrinsic_state::dump): New decl.
9751 * sm.cc: Include "pretty-print.h".
9752 (state_machine::dump_to_pp): New.
9753 * sm.h (state_machine::dump_to_pp): New decl.
9754
9755 2020-01-30 David Malcolm <dmalcolm@redhat.com>
9756
9757 * diagnostic-manager.cc (for_each_state_change): Use
9758 extrinsic_state::get_num_checkers rather than accessing m_checkers
9759 directly.
9760 * program-state.cc (program_state::program_state): Likewise.
9761 * program-state.h (extrinsic_state::m_checkers): Make private.
9762
9763 2020-01-30 David Malcolm <dmalcolm@redhat.com>
9764
9765 PR analyzer/93356
9766 * region-model.cc (region_model::eval_condition): In both
9767 overloads, bail out immediately on floating-point types.
9768 (region_model::eval_condition_without_cm): Likewise.
9769 (region_model::add_constraint): Likewise.
9770
9771 2020-01-30 David Malcolm <dmalcolm@redhat.com>
9772
9773 PR analyzer/93450
9774 * program-state.cc (sm_state_map::set_state): For the overload
9775 taking an svalue_id, bail out if the set_state on the ec does
9776 nothing. Convert the latter's return type from void to bool,
9777 returning true if anything changed.
9778 (sm_state_map::impl_set_state): Convert the return type from void
9779 to bool, returning true if the state changed.
9780 * program-state.h (sm_state_map::set_state): Convert return type
9781 from void to bool.
9782 (sm_state_map::impl_set_state): Likewise.
9783 * region-model.cc (constant_svalue::eval_condition): Only call
9784 fold_build2 if the types are the same.
9785
9786 2020-01-29 Jakub Jelinek <jakub@redhat.com>
9787
9788 * analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Remove.
9789 * constraint-manager.cc: Include diagnostic-core.h before graphviz.h.
9790 (range::dump, equiv_class::print): Don't use PUSH_IGNORE_WFORMAT or
9791 POP_IGNORE_WFORMAT.
9792 * state-purge.cc: Include diagnostic-core.h before
9793 gimple-pretty-print.h.
9794 (state_purge_annotator::add_node_annotations, print_vec_of_names):
9795 Don't use PUSH_IGNORE_WFORMAT or POP_IGNORE_WFORMAT.
9796 * region-model.cc: Move diagnostic-core.h include before graphviz.h.
9797 (path_var::dump, svalue::print, constant_svalue::print_details,
9798 region::dump_to_pp, region::dump_child_label, region::print_fields,
9799 map_region::print_fields, map_region::dump_dot_to_pp,
9800 map_region::dump_child_label, array_region::print_fields,
9801 array_region::dump_dot_to_pp): Don't use PUSH_IGNORE_WFORMAT or
9802 POP_IGNORE_WFORMAT.
9803
9804 2020-01-28 David Malcolm <dmalcolm@redhat.com>
9805
9806 PR analyzer/93316
9807 * engine.cc (rewind_info_t::update_model): Get the longjmp call
9808 stmt via get_longjmp_call () rather than assuming it is the last
9809 stmt in the longjmp's supernode.
9810 (rewind_info_t::add_events_to_path): Get the location_t for the
9811 rewind_from_longjmp_event via get_longjmp_call () rather than from
9812 the supernode's get_end_location ().
9813
9814 2020-01-28 David Malcolm <dmalcolm@redhat.com>
9815
9816 * region-model.cc (poisoned_value_diagnostic::emit): Update for
9817 renaming of warning_at overload to warning_meta.
9818 * sm-file.cc (file_leak::emit): Likewise.
9819 * sm-malloc.cc (double_free::emit): Likewise.
9820 (possible_null_deref::emit): Likewise.
9821 (possible_null_arg::emit): Likewise.
9822 (null_deref::emit): Likewise.
9823 (null_arg::emit): Likewise.
9824 (use_after_free::emit): Likewise.
9825 (malloc_leak::emit): Likewise.
9826 (free_of_non_heap::emit): Likewise.
9827 * sm-sensitive.cc (exposure_through_output_file::emit): Likewise.
9828 * sm-signal.cc (signal_unsafe_call::emit): Likewise.
9829 * sm-taint.cc (tainted_array_index::emit): Likewise.
9830
9831 2020-01-27 David Malcolm <dmalcolm@redhat.com>
9832
9833 PR analyzer/93451
9834 * region-model.cc (tree_cmp): For the REAL_CST case, impose an
9835 arbitrary order on NaNs relative to other NaNs and to non-NaNs;
9836 const-correctness tweak.
9837 (ana::selftests::build_real_cst_from_string): New function.
9838 (ana::selftests::append_interesting_constants): New function.
9839 (ana::selftests::test_tree_cmp_on_constants): New test.
9840 (ana::selftests::test_canonicalization_4): New test.
9841 (ana::selftests::analyzer_region_model_cc_tests): Call the new
9842 tests.
9843
9844 2020-01-27 David Malcolm <dmalcolm@redhat.com>
9845
9846 PR analyzer/93349
9847 * engine.cc (run_checkers): Save and restore input_location.
9848
9849 2020-01-27 David Malcolm <dmalcolm@redhat.com>
9850
9851 * call-string.cc (call_string::cmp_1): Delete, moving body to...
9852 (call_string::cmp): ...here.
9853 * call-string.h (call_string::cmp_1): Delete decl.
9854 * engine.cc (worklist::key_t::cmp_1): Delete, moving body to...
9855 (worklist::key_t::cmp): ...here. Implement hash comparisons
9856 via comparison rather than subtraction to avoid overflow issues.
9857 * exploded-graph.h (worklist::key_t::cmp_1): Delete decl.
9858 * region-model.cc (tree_cmp): Eliminate buggy checking for
9859 symmetry.
9860
9861 2020-01-27 David Malcolm <dmalcolm@redhat.com>
9862
9863 * analyzer.cc (is_named_call_p): Check that fndecl is "extern"
9864 and at file scope. Potentially disregard prefix _ or __ in
9865 fndecl's name. Bail if the identifier is NULL.
9866 (is_setjmp_call_p): Expect a gcall rather than plain gimple.
9867 Remove special-case check for leading prefix, and also check for
9868 sigsetjmp.
9869 (is_longjmp_call_p): Also check for siglongjmp.
9870 (get_user_facing_name): New function.
9871 * analyzer.h (is_setjmp_call_p): Expect a gcall rather than plain
9872 gimple.
9873 (get_user_facing_name): New decl.
9874 * checker-path.cc (setjmp_event::get_desc): Use
9875 get_user_facing_name to avoid hardcoding the function name.
9876 (rewind_event::rewind_event): Add rewind_info param, using it to
9877 initialize new m_rewind_info field, and strengthen the assertion.
9878 (rewind_from_longjmp_event::get_desc): Use get_user_facing_name to
9879 avoid hardcoding the function name.
9880 (rewind_to_setjmp_event::get_desc): Likewise.
9881 * checker-path.h (setjmp_event::setjmp_event): Add setjmp_call
9882 param and use it to initialize...
9883 (setjmp_event::m_setjmp_call): New field.
9884 (rewind_event::rewind_event): Add rewind_info param.
9885 (rewind_event::m_rewind_info): New protected field.
9886 (rewind_from_longjmp_event::rewind_from_longjmp_event): Add
9887 rewind_info param.
9888 (class rewind_to_setjmp_event): Move rewind_info field to parent
9889 class.
9890 * diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
9891 Update setjmp-handling for is_setjmp_call_p requiring a gcall;
9892 pass the call to the new setjmp_event.
9893 * engine.cc (exploded_node::on_stmt): Update for is_setjmp_call_p
9894 requiring a gcall.
9895 (stale_jmp_buf::emit): Use get_user_facing_name to avoid
9896 hardcoding the function names.
9897 (exploded_node::on_longjmp): Pass the longjmp_call when
9898 constructing rewind_info.
9899 (rewind_info_t::add_events_to_path): Pass the rewind_info_t to the
9900 rewind_from_longjmp_event's ctor.
9901 * exploded-graph.h (rewind_info_t::rewind_info_t): Add
9902 longjmp_call param.
9903 (rewind_info_t::get_longjmp_call): New.
9904 (rewind_info_t::m_longjmp_call): New.
9905 * region-model.cc (region_model::on_setjmp): Update comment to
9906 indicate this is also for sigsetjmp.
9907 * region-model.h (struct setjmp_record): Likewise.
9908 (class setjmp_svalue): Likewise.
9909
9910 2020-01-27 David Malcolm <dmalcolm@redhat.com>
9911
9912 PR analyzer/93276
9913 * analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Guard these
9914 macros with GCC_VERSION >= 4006, making them no-op otherwise.
9915 * engine.cc (exploded_edge::exploded_edge): Specify template for
9916 base class initializer.
9917 (exploded_graph::add_edge): Specify template when chaining up to
9918 base class add_edge implementation.
9919 (viz_callgraph_node::dump_dot): Drop redundant "typename".
9920 (viz_callgraph_edge::viz_callgraph_edge): Specify template for
9921 base class initializer.
9922 * program-state.cc (sm_state_map::clone_with_remapping): Drop
9923 redundant "typename".
9924 (sm_state_map::print): Likewise.
9925 (sm_state_map::hash): Likewise.
9926 (sm_state_map::operator==): Likewise.
9927 (sm_state_map::remap_svalue_ids): Likewise.
9928 (sm_state_map::on_svalue_purge): Likewise.
9929 (sm_state_map::validate): Likewise.
9930 * program-state.h (sm_state_map::iterator_t): Likewise.
9931 * supergraph.h (superedge::superedge): Specify template for base
9932 class initializer.
9933
9934 2020-01-23 David Malcolm <dmalcolm@redhat.com>
9935
9936 PR analyzer/93375
9937 * supergraph.cc (callgraph_superedge::get_arg_for_parm): Fail
9938 gracefully is the number of parameters at the callee exceeds the
9939 number of arguments at the call stmt.
9940 (callgraph_superedge::get_parm_for_arg): Likewise.
9941
9942 2020-01-22 David Malcolm <dmalcolm@redhat.com>
9943
9944 PR analyzer/93382
9945 * program-state.cc (sm_state_map::on_svalue_purge): If the
9946 entry survives, but the origin is being purged, then reset the
9947 origin to null.
9948
9949 2020-01-22 David Malcolm <dmalcolm@redhat.com>
9950
9951 * sm-signal.cc: Fix nesting of CHECKING_P and namespace ana.
9952
9953 2020-01-22 David Malcolm <dmalcolm@redhat.com>
9954
9955 PR analyzer/93378
9956 * engine.cc (setjmp_svalue::compare_fields): Update for
9957 replacement of m_enode with m_setjmp_record.
9958 (setjmp_svalue::add_to_hash): Likewise.
9959 (setjmp_svalue::get_index): Rename...
9960 (setjmp_svalue::get_enode_index): ...to this.
9961 (setjmp_svalue::print_details): Update for replacement of m_enode
9962 with m_setjmp_record.
9963 (exploded_node::on_longjmp): Likewise.
9964 * exploded-graph.h (rewind_info_t::m_enode_origin): Replace...
9965 (rewind_info_t::m_setjmp_record): ...with this.
9966 (rewind_info_t::rewind_info_t): Update for replacement of m_enode
9967 with m_setjmp_record.
9968 (rewind_info_t::get_setjmp_point): Likewise.
9969 (rewind_info_t::get_setjmp_call): Likewise.
9970 * region-model.cc (region_model::dump_summary_of_map): Likewise.
9971 (region_model::on_setjmp): Likewise.
9972 * region-model.h (struct setjmp_record): New struct.
9973 (setjmp_svalue::m_enode): Replace...
9974 (setjmp_svalue::m_setjmp_record): ...with this.
9975 (setjmp_svalue::setjmp_svalue): Update for replacement of m_enode
9976 with m_setjmp_record.
9977 (setjmp_svalue::clone): Likewise.
9978 (setjmp_svalue::get_index): Rename...
9979 (setjmp_svalue::get_enode_index): ...to this.
9980 (setjmp_svalue::get_exploded_node): Replace...
9981 (setjmp_svalue::get_setjmp_record): ...with this.
9982
9983 2020-01-22 David Malcolm <dmalcolm@redhat.com>
9984
9985 PR analyzer/93316
9986 * analyzer.cc (is_setjmp_call_p): Check for "setjmp" as well as
9987 "_setjmp".
9988
9989 2020-01-22 David Malcolm <dmalcolm@redhat.com>
9990
9991 PR analyzer/93307
9992 * analysis-plan.h: Wrap everything namespace "ana".
9993 * analyzer-logging.cc: Likewise.
9994 * analyzer-logging.h: Likewise.
9995 * analyzer-pass.cc (pass_analyzer::execute): Update for "ana"
9996 namespace.
9997 * analyzer-selftests.cc: Wrap everything namespace "ana".
9998 * analyzer-selftests.h: Likewise.
9999 * analyzer.h: Likewise for forward decls of types.
10000 * call-string.h: Likewise.
10001 * checker-path.cc: Likewise.
10002 * checker-path.h: Likewise.
10003 * constraint-manager.cc: Likewise.
10004 * constraint-manager.h: Likewise.
10005 * diagnostic-manager.cc: Likewise.
10006 * diagnostic-manager.h: Likewise.
10007 * engine.cc: Likewise.
10008 * engine.h: Likewise.
10009 * exploded-graph.h: Likewise.
10010 * function-set.cc: Likewise.
10011 * function-set.h: Likewise.
10012 * pending-diagnostic.cc: Likewise.
10013 * pending-diagnostic.h: Likewise.
10014 * program-point.cc: Likewise.
10015 * program-point.h: Likewise.
10016 * program-state.cc: Likewise.
10017 * program-state.h: Likewise.
10018 * region-model.cc: Likewise.
10019 * region-model.h: Likewise.
10020 * sm-file.cc: Likewise.
10021 * sm-malloc.cc: Likewise.
10022 * sm-pattern-test.cc: Likewise.
10023 * sm-sensitive.cc: Likewise.
10024 * sm-signal.cc: Likewise.
10025 * sm-taint.cc: Likewise.
10026 * sm.cc: Likewise.
10027 * sm.h: Likewise.
10028 * state-purge.h: Likewise.
10029 * supergraph.cc: Likewise.
10030 * supergraph.h: Likewise.
10031
10032 2020-01-21 David Malcolm <dmalcolm@redhat.com>
10033
10034 PR analyzer/93352
10035 * region-model.cc (int_cmp): Rename to...
10036 (array_region::key_cmp): ...this, using key_t rather than int.
10037 Rewrite in terms of comparisons rather than subtraction to
10038 ensure qsort is anti-symmetric when handling extreme values.
10039 (array_region::walk_for_canonicalization): Update for above
10040 renaming.
10041 * region-model.h (array_region::key_cmp): New decl.
10042
10043 2020-01-17 David Malcolm <dmalcolm@redhat.com>
10044
10045 PR analyzer/93290
10046 * region-model.cc (region_model::eval_condition_without_cm): Avoid
10047 gcc_unreachable for unexpected operations for the case where
10048 we're comparing an svalue against itself.
10049
10050 2020-01-17 David Malcolm <dmalcolm@redhat.com>
10051
10052 PR analyzer/93281
10053 * region-model.cc
10054 (region_model::convert_byte_offset_to_array_index): Convert to
10055 ssizetype before dividing by byte_size. Use fold_binary rather
10056 than fold_build2 to avoid needlessly constructing a tree for the
10057 non-const case.
10058
10059 2020-01-15 David Malcolm <dmalcolm@redhat.com>
10060
10061 * engine.cc (class impl_region_model_context): Fix comment.
10062
10063 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10064
10065 PR analyzer/93212
10066 * region-model.cc (make_region_for_type): Use
10067 FUNC_OR_METHOD_TYPE_P rather than comparing against FUNCTION_TYPE.
10068 * region-model.h (function_region::function_region): Likewise.
10069
10070 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10071
10072 * program-state.cc (sm_state_map::clone_with_remapping): Copy
10073 m_global_state.
10074 (selftest::test_program_state_merging_2): New selftest.
10075 (selftest::analyzer_program_state_cc_tests): Call it.
10076
10077 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10078
10079 * checker-path.h (checker_path::get_checker_event): New function.
10080 (checker_path): Add DISABLE_COPY_AND_ASSIGN; make fields private.
10081 * diagnostic-manager.cc
10082 (diagnostic_manager::prune_for_sm_diagnostic): Replace direct
10083 access to checker_path::m_events with accessor functions. Fix
10084 overlong line.
10085 (diagnostic_manager::prune_interproc_events): Replace direct
10086 access to checker_path::m_events with accessor functions.
10087 (diagnostic_manager::finish_pruning): Likewise.
10088
10089 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10090
10091 * checker-path.h (checker_event::clone): Delete vfunc decl.
10092 (debug_event::clone): Delete vfunc impl.
10093 (custom_event::clone): Delete vfunc impl.
10094 (statement_event::clone): Delete vfunc impl.
10095 (function_entry_event::clone): Delete vfunc impl.
10096 (state_change_event::clone): Delete vfunc impl.
10097 (start_cfg_edge_event::clone): Delete vfunc impl.
10098 (end_cfg_edge_event::clone): Delete vfunc impl.
10099 (call_event::clone): Delete vfunc impl.
10100 (return_event::clone): Delete vfunc impl.
10101 (setjmp_event::clone): Delete vfunc impl.
10102 (rewind_from_longjmp_event::clone): Delete vfunc impl.
10103 (rewind_to_setjmp_event::clone): Delete vfunc impl.
10104 (warning_event::clone): Delete vfunc impl.
10105
10106 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10107
10108 * supergraph.cc (supernode::dump_dot): Ensure that the TABLE
10109 element has at least one TR.
10110
10111 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10112
10113 PR analyzer/58237
10114 * engine.cc (leak_stmt_finder::find_stmt): Use get_pure_location
10115 when comparing against UNKNOWN_LOCATION.
10116 (stmt_requires_new_enode_p): Likewise.
10117 (exploded_graph::dump_exploded_nodes): Likewise.
10118 * supergraph.cc (supernode::get_start_location): Likewise.
10119 (supernode::get_end_location): Likewise.
10120
10121 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10122
10123 PR analyzer/58237
10124 * analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
10125 selftest::analyzer_sm_file_cc_tests.
10126 * analyzer-selftests.h (selftest::analyzer_sm_file_cc_tests): New
10127 decl.
10128 * sm-file.cc: Include "analyzer/function-set.h" and
10129 "analyzer/analyzer-selftests.h".
10130 (get_file_using_fns): New function.
10131 (is_file_using_fn_p): New function.
10132 (fileptr_state_machine::on_stmt): Return true for known functions.
10133 (selftest::analyzer_sm_file_cc_tests): New function.
10134
10135 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10136
10137 * analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
10138 selftest::analyzer_sm_signal_cc_tests.
10139 * analyzer-selftests.h (selftest::analyzer_sm_signal_cc_tests):
10140 New decl.
10141 * sm-signal.cc: Include "analyzer/function-set.h" and
10142 "analyzer/analyzer-selftests.h".
10143 (get_async_signal_unsafe_fns): New function.
10144 (signal_unsafe_p): Reimplement in terms of the above.
10145 (selftest::analyzer_sm_signal_cc_tests): New function.
10146
10147 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10148
10149 * analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
10150 selftest::analyzer_function_set_cc_tests.
10151 * analyzer-selftests.h (selftest::analyzer_function_set_cc_tests):
10152 New decl.
10153 * function-set.cc: New file.
10154 * function-set.h: New file.
10155
10156 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10157
10158 * analyzer.h (fndecl_has_gimple_body_p): New decl.
10159 * engine.cc (impl_region_model_context::on_unknown_change): New
10160 function.
10161 (fndecl_has_gimple_body_p): Make non-static.
10162 (exploded_node::on_stmt): Treat __analyzer_dump_exploded_nodes as
10163 known. Track whether we have a call with unknown side-effects and
10164 pass it to on_call_post.
10165 * exploded-graph.h (impl_region_model_context::on_unknown_change):
10166 New decl.
10167 * program-state.cc (sm_state_map::on_unknown_change): New function.
10168 * program-state.h (sm_state_map::on_unknown_change): New decl.
10169 * region-model.cc: Include "bitmap.h".
10170 (region_model::on_call_pre): Return a bool, capturing whether the
10171 call has unknown side effects.
10172 (region_model::on_call_post): Add arg "bool unknown_side_effects"
10173 and if true, call handle_unrecognized_call.
10174 (class reachable_regions): New class.
10175 (region_model::handle_unrecognized_call): New function.
10176 * region-model.h (region_model::on_call_pre): Return a bool.
10177 (region_model::on_call_post): Add arg "bool unknown_side_effects".
10178 (region_model::handle_unrecognized_call): New decl.
10179 (region_model_context::on_unknown_change): New vfunc.
10180 (test_region_model_context::on_unknown_change): New function.
10181
10182 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10183
10184 * diagnostic-manager.cc (saved_diagnostic::operator==): Move here
10185 from header. Replace pointer equality test on m_var with call to
10186 pending_diagnostic::same_tree_p.
10187 * diagnostic-manager.h (saved_diagnostic::operator==): Move to
10188 diagnostic-manager.cc.
10189 * pending-diagnostic.cc (pending_diagnostic::same_tree_p): New.
10190 * pending-diagnostic.h (pending_diagnostic::same_tree_p): New.
10191 * sm-file.cc (file_diagnostic::subclass_equal_p): Replace pointer
10192 equality on m_arg with call to pending_diagnostic::same_tree_p.
10193 * sm-malloc.cc (malloc_diagnostic::subclass_equal_p): Likewise.
10194 (possible_null_arg::subclass_equal_p): Likewise.
10195 (null_arg::subclass_equal_p): Likewise.
10196 (free_of_non_heap::subclass_equal_p): Likewise.
10197 * sm-pattern-test.cc (pattern_match::operator==): Likewise.
10198 * sm-sensitive.cc (exposure_through_output_file::operator==):
10199 Likewise.
10200 * sm-taint.cc (tainted_array_index::operator==): Likewise.
10201
10202 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10203
10204 * diagnostic-manager.cc (dedupe_winners::add): Add logging
10205 of deduplication decisions made.
10206
10207 2020-01-14 David Malcolm <dmalcolm@redhat.com>
10208
10209 * ChangeLog: New file.
10210 * analyzer-selftests.cc: New file.
10211 * analyzer-selftests.h: New file.
10212 * analyzer.opt: New file.
10213 * analysis-plan.cc: New file.
10214 * analysis-plan.h: New file.
10215 * analyzer-logging.cc: New file.
10216 * analyzer-logging.h: New file.
10217 * analyzer-pass.cc: New file.
10218 * analyzer.cc: New file.
10219 * analyzer.h: New file.
10220 * call-string.cc: New file.
10221 * call-string.h: New file.
10222 * checker-path.cc: New file.
10223 * checker-path.h: New file.
10224 * constraint-manager.cc: New file.
10225 * constraint-manager.h: New file.
10226 * diagnostic-manager.cc: New file.
10227 * diagnostic-manager.h: New file.
10228 * engine.cc: New file.
10229 * engine.h: New file.
10230 * exploded-graph.h: New file.
10231 * pending-diagnostic.cc: New file.
10232 * pending-diagnostic.h: New file.
10233 * program-point.cc: New file.
10234 * program-point.h: New file.
10235 * program-state.cc: New file.
10236 * program-state.h: New file.
10237 * region-model.cc: New file.
10238 * region-model.h: New file.
10239 * sm-file.cc: New file.
10240 * sm-malloc.cc: New file.
10241 * sm-malloc.dot: New file.
10242 * sm-pattern-test.cc: New file.
10243 * sm-sensitive.cc: New file.
10244 * sm-signal.cc: New file.
10245 * sm-taint.cc: New file.
10246 * sm.cc: New file.
10247 * sm.h: New file.
10248 * state-purge.cc: New file.
10249 * state-purge.h: New file.
10250 * supergraph.cc: New file.
10251 * supergraph.h: New file.
10252
10253 2019-12-13 David Malcolm <dmalcolm@redhat.com>
10254
10255 * Initial creation
10256
10257 \f
10258 Copyright (C) 2019-2023 Free Software Foundation, Inc.
10259
10260 Copying and distribution of this file, with or without modification,
10261 are permitted in any medium without royalty provided the copyright
10262 notice and this notice are preserved.