GCC Middle and Back End API Reference
exploded-graph.h
Go to the documentation of this file.
1/* Classes for managing a directed graph of <point, state> pairs.
2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_EXPLODED_GRAPH_H
22#define GCC_ANALYZER_EXPLODED_GRAPH_H
23
24#include "alloc-pool.h"
25#include "fibonacci_heap.h"
26#include "supergraph.h"
27#include "sbitmap.h"
28#include "shortest-paths.h"
29#include "analyzer/sm.h"
33
34namespace ana {
35
36/* Concrete implementation of region_model_context, wiring it up to the
37 rest of the analysis engine. */
38
40{
41 public:
43 exploded_node *enode_for_diag,
44
45 /* TODO: should we be getting the ECs from the
46 old state, rather than the new? */
47 const program_state *old_state,
48 program_state *new_state,
49 uncertainty_t *uncertainty,
50 path_context *path_ctxt,
51 const gimple *stmt = nullptr,
52 bool *out_could_have_done_work = nullptr);
53
56 uncertainty_t *uncertainty,
57 logger *logger = nullptr);
58
59 bool
60 warn_at (std::unique_ptr<pending_diagnostic> d,
61 pending_location &&ploc) final override;
62 void add_note (std::unique_ptr<pending_note> pn) final override;
63 void add_event (std::unique_ptr<checker_event> event) final override;
64 void on_svalue_leak (const svalue *) override;
65 void on_liveness_change (const svalue_set &live_svalues,
66 const region_model *model) final override;
67 logger *get_logger () final override
68 {
69 return m_logger.get_logger ();
70 }
71
73 const svalue *sval,
75
76 void on_condition (const svalue *lhs,
77 enum tree_code op,
78 const svalue *rhs) final override;
79
80 void on_bounded_ranges (const svalue &sval,
81 const bounded_ranges &ranges) final override;
82
83 void on_pop_frame (const frame_region *frame_reg) final override;
84
85 void on_unknown_change (const svalue *sval, bool is_mutable) final override;
86
87 void on_phi (const gphi *phi, tree rhs) final override;
88
90 const dump_location_t &loc) final override;
91
92 void on_escaped_function (tree fndecl) final override;
93
95
96 void purge_state_involving (const svalue *sval) final override;
97
98 void bifurcate (std::unique_ptr<custom_edge_info> info) final override;
99 void terminate_path () final override;
100 const extrinsic_state *get_ext_state () const final override
101 {
102 return &m_ext_state;
103 }
104 bool
105 get_state_map_by_name (const char *name,
106 sm_state_map **out_smap,
107 const state_machine **out_sm,
108 unsigned *out_sm_idx,
109 std::unique_ptr<sm_context> *out_sm_context) override;
110
111 const gimple *get_stmt () const override { return m_stmt; }
112 const exploded_graph *get_eg () const override { return m_eg; }
113
114 const program_state *get_state () const override { return m_new_state; }
115
116 void maybe_did_work () override;
117 bool checking_for_infinite_loop_p () const override { return false; }
119
122
133};
134
135/* A <program_point, program_state> pair, used internally by
136 exploded_node as its immutable data, and as a key for identifying
137 exploded_nodes we've already seen in the graph. */
138
140{
141public:
143 const program_state &state)
144 : m_point (point),
145 m_state (state),
146 m_hash (m_point.hash () ^ m_state.hash ())
147 {
148 /* We shouldn't be building point_and_states and thus exploded_nodes
149 for states that aren't valid. */
150 gcc_assert (state.m_valid);
151 }
152
153 hashval_t hash () const
154 {
155 return m_hash;
156 }
157 bool operator== (const point_and_state &other) const
158 {
159 return m_point == other.m_point && m_state == other.m_state;
160 }
161
162 const program_point &get_point () const { return m_point; }
163 const program_state &get_state () const { return m_state; }
164
166 {
167 m_state = state;
168 m_hash = m_point.hash () ^ m_state.hash ();
169 }
170
171 void validate (const extrinsic_state &ext_state) const;
172
173private:
176 hashval_t m_hash;
177};
178
179/* A traits class for exploded graphs and their nodes and edges. */
180
182{
187 {
188 dump_args_t (const exploded_graph &eg) : m_eg (eg) {}
189
190 bool show_enode_details_p (const exploded_node &enode) const;
191
192 virtual void
194
196 };
197 typedef exploded_cluster cluster_t;
198};
199
200/* An exploded_node is a unique, immutable <point, state> pair within the
201 exploded_graph.
202 Each exploded_node has a unique index within the graph
203 (for ease of debugging). */
204
205class exploded_node : public dnode<eg_traits>
206{
207 public:
208 /* Has this enode had exploded_graph::process_node called on it?
209 This allows us to distinguish enodes that were merged during
210 worklist-handling, and thus never had process_node called on them
211 (in favor of processing the merged node). */
212 enum class status
213 {
214 /* Node is in the worklist. */
216
217 /* Node has had exploded_graph::process_node called on it. */
219
220 /* Node was excluded from worklist on creation.
221 e.g. for handling exception-unwinding. */
223
224 /* Node was left unprocessed due to merger; it won't have had
225 exploded_graph::process_node called on it. */
227
228 /* Node was processed by maybe_process_run_of_enodes. */
230 };
231 static const char * status_to_str (enum status s);
232
233 exploded_node (const point_and_state &ps, int index);
234
235 hashval_t hash () const { return m_ps.hash (); }
236
237 const char * get_dot_fillcolor () const;
238 void dump_dot (graphviz_out *gv, const dump_args_t &args)
239 const final override;
240 void dump_dot_id (pretty_printer *pp) const;
241
243 void dump (FILE *fp, const extrinsic_state &ext_state) const;
244 void dump (const extrinsic_state &ext_state) const;
245
248
249 std::unique_ptr<json::object> to_json (const extrinsic_state &ext_state) const;
250
252 const gcall &call,
253 program_state *new_state,
256 const gcall &call,
257 const program_point &after_throw_point,
258 program_state *new_state,
259 bool is_rethrow,
261
263
264 const program_point &get_point () const { return m_ps.get_point (); }
265 const supernode *get_supernode () const
266 {
267 return get_point ().get_supernode ();
268 }
269 location_t get_location () const
270 {
271 return get_point ().get_location ();
272 }
274 {
275 return get_point ().get_function ();
276 }
277 int get_stack_depth () const
278 {
279 return get_point ().get_stack_depth ();
280 }
281
282 const program_state &get_state () const { return m_ps.get_state (); }
283
284 const point_and_state *get_ps_key () const { return &m_ps; }
285 const program_point *get_point_key () const { return &m_ps.get_point (); }
286
287 void dump_succs_and_preds (FILE *outf) const;
288
289 enum status get_status () const { return m_status; }
290 void set_status (enum status s)
291 {
293 m_status = s;
294 }
295
297 {
298 m_saved_diagnostics.safe_push (sd);
299 }
300 unsigned get_num_diagnostics () const
301 {
302 return m_saved_diagnostics.length ();
303 }
304 const saved_diagnostic *get_saved_diagnostic (unsigned idx) const
305 {
306 return m_saved_diagnostics[idx];
307 }
308
309private:
311
312 /* The <program_point, program_state> pair. This is const, as it
313 is immutable once the exploded_node has been created. */
315
317
318 /* The saved_diagnostics at this enode, borrowed from the
319 diagnostic_manager. */
320 auto_vec <const saved_diagnostic *> m_saved_diagnostics;
321
322public:
323 /* The index of this exploded_node. */
324 const int m_index;
325};
326
327/* An edge within the exploded graph.
328 Some exploded_edges have an underlying superedge; others don't. */
329
330class exploded_edge : public dedge<eg_traits>
331{
332 public:
334 const superedge *sedge, bool could_do_work,
335 std::unique_ptr<custom_edge_info> custom_info);
336 void dump_dot (graphviz_out *gv, const dump_args_t &args)
337 const final override;
339
340 std::unique_ptr<json::object> to_json () const;
341
342 //private:
343 const superedge *const m_sedge;
344
345 /* nullptr for most edges; will be non-NULL for special cases
346 such as an unwind from a longjmp to a setjmp, or when
347 a signal is delivered to a signal-handler. */
348 std::unique_ptr<custom_edge_info> m_custom_info;
349
350 bool could_do_work_p () const { return m_could_do_work_p; }
351
352 const gimple *maybe_get_stmt () const;
353 const operation *maybe_get_op () const;
354
355private:
357
358 /* For -Wanalyzer-infinite-loop.
359 Set to true during processing if any of the activity along
360 this edge is "externally-visible work" (and thus ruling this
361 out as being part of an infinite loop.
362
363 For example, given:
364
365 while (1)
366 do_something ();
367
368 although it is an infinite loop, presumably the point of the
369 program is the loop body, and thus reporting this as an infinite
370 loop is likely to be unhelpful to the user. */
372};
373
374/* Extra data for an exploded_edge that represents an interprocedural
375 call. */
376
378{
379public:
381 function &callee_fun)
382 : m_op (op),
383 m_callee_fun (callee_fun)
384 {}
385
386 void print (pretty_printer *pp) const final override;
387
388 void get_dot_attrs (const char *&out_style,
389 const char *&out_color) const final override;
390
392 const exploded_edge *eedge,
393 region_model_context *ctxt) const final override;
394
396 const exploded_edge *eedge,
397 region_model_context *ctxt) const final override;
398
399 void add_events_to_path (checker_path *emission_path,
400 const exploded_edge &eedge,
402 const state_transition *state_trans) const final override;
403
404 bool
405 try_to_rewind_data_flow (rewind_context &) const final override;
406
407 const gcall &get_gcall () const;
408
409private:
412};
413
414/* Extra data for an exploded_edge that represents an interprocedural
415 return. */
416
418{
419public:
420 interprocedural_return (const gcall &call_stmt)
421 : m_call_stmt (call_stmt)
422 {}
423
424 void print (pretty_printer *pp) const final override;
425
426 void get_dot_attrs (const char *&out_style,
427 const char *&out_color) const final override;
428
430 const exploded_edge *eedge,
431 region_model_context *ctxt) const final override;
432
434 const exploded_edge *eedge,
435 region_model_context *ctxt) const final override;
436
437 void add_events_to_path (checker_path *emission_path,
438 const exploded_edge &eedge,
440 const state_transition *state_trans) const final override;
441
442 bool
443 try_to_rewind_data_flow (rewind_context &) const final override;
444
445private:
447};
448
449/* Extra data for an exploded_edge that represents a rewind from a
450 longjmp to a setjmp (or from a siglongjmp to a sigsetjmp). */
451
453{
454public:
456 const gcall &longjmp_call)
458 m_longjmp_call (longjmp_call)
459 {}
460
461 void print (pretty_printer *pp) const final override
462 {
463 pp_string (pp, "rewind");
464 }
465
467 const exploded_edge *eedge,
468 region_model_context *ctxt) const final override;
469
470 void add_events_to_path (checker_path *emission_path,
471 const exploded_edge &eedge,
473 const state_transition *state_trans) const final override;
474
477 {
478 return get_enode_origin ()->get_point ();
479 }
480
483 {
484 const program_point &origin_point = get_enode_origin ()->get_point ();
485 return program_point (m_setjmp_record.m_sedge->m_dest,
486 origin_point.get_call_string ());
487 }
488
489 const gcall &get_setjmp_call () const
490 {
491 return *m_setjmp_record.m_setjmp_call;
492 }
493
494 const gcall &get_longjmp_call () const
495 {
496 return m_longjmp_call;
497 }
498
500 {
501 return m_setjmp_record.m_enode;
502 }
503
504private:
507};
508
509/* Statistics about aspects of an exploded_graph. */
510
511struct stats
512{
513 stats (int num_supernodes);
514 void log (logger *logger) const;
515 void dump (FILE *out) const;
516
517 int get_total_enodes () const;
518
523};
524
525/* Traits class for ensuring uniqueness of point_and_state data within
526 an exploded_graph. */
527
529{
530 typedef const point_and_state *key_type;
533
534 static inline hashval_t hash (const key_type &k)
535 {
536 gcc_assert (k != nullptr);
537 gcc_assert (k != reinterpret_cast<key_type> (1));
538 return k->hash ();
539 }
540 static inline bool equal_keys (const key_type &k1, const key_type &k2)
541 {
542 gcc_assert (k1 != nullptr);
543 gcc_assert (k2 != nullptr);
544 gcc_assert (k1 != reinterpret_cast<key_type> (1));
545 gcc_assert (k2 != reinterpret_cast<key_type> (1));
546 if (k1 && k2)
547 return *k1 == *k2;
548 else
549 /* Otherwise they must both be non-NULL. */
550 return k1 == k2;
551 }
552 template <typename T>
553 static inline void remove (T &)
554 {
555 /* empty; the nodes are handled elsewhere. */
556 }
557 template <typename T>
558 static inline void mark_deleted (T &entry)
559 {
560 entry.m_key = reinterpret_cast<key_type> (1);
561 }
562 template <typename T>
563 static inline void mark_empty (T &entry)
564 {
565 entry.m_key = nullptr;
566 }
567 template <typename T>
568 static inline bool is_deleted (const T &entry)
569 {
570 return entry.m_key == reinterpret_cast<key_type> (1);
571 }
572 template <typename T>
573 static inline bool is_empty (const T &entry)
574 {
575 return entry.m_key == nullptr;
576 }
577 static const bool empty_zero_p = false;
578};
579
580/* Per-program_point data for an exploded_graph. */
581
583{
585 : m_key (key), m_excess_enodes (0)
586 {}
587
590 /* The number of attempts to create an enode for this point
591 after exceeding --param=analyzer-max-enodes-per-program-point. */
593};
594
595/* Traits class for storing per-program_point data within
596 an exploded_graph. */
597
599{
600 typedef const program_point *key_type;
603
604 static inline hashval_t hash (const key_type &k)
605 {
606 gcc_assert (k != nullptr);
607 gcc_assert (k != reinterpret_cast<key_type> (1));
608 return k->hash ();
609 }
610 static inline bool equal_keys (const key_type &k1, const key_type &k2)
611 {
612 gcc_assert (k1 != nullptr);
613 gcc_assert (k2 != nullptr);
614 gcc_assert (k1 != reinterpret_cast<key_type> (1));
615 gcc_assert (k2 != reinterpret_cast<key_type> (1));
616 if (k1 && k2)
617 return *k1 == *k2;
618 else
619 /* Otherwise they must both be non-NULL. */
620 return k1 == k2;
621 }
622 template <typename T>
623 static inline void remove (T &)
624 {
625 /* empty; the nodes are handled elsewhere. */
626 }
627 template <typename T>
628 static inline void mark_deleted (T &entry)
629 {
630 entry.m_key = reinterpret_cast<key_type> (1);
631 }
632 template <typename T>
633 static inline void mark_empty (T &entry)
634 {
635 entry.m_key = nullptr;
636 }
637 template <typename T>
638 static inline bool is_deleted (const T &entry)
639 {
640 return entry.m_key == reinterpret_cast<key_type> (1);
641 }
642 template <typename T>
643 static inline bool is_empty (const T &entry)
644 {
645 return entry.m_key == nullptr;
646 }
647 static const bool empty_zero_p = false;
648};
649
650/* Data about a particular call_string within an exploded_graph. */
651
653{
654 per_call_string_data (const call_string &key, int num_supernodes)
655 : m_key (key), m_stats (num_supernodes)
656 {}
657
660};
661
662/* Data about a particular function within an exploded_graph. */
663
673
674/* The strongly connected components of a supergraph.
675 In particular, this allows us to compute a partial ordering
676 of supernodes. */
677
679{
680public:
682
683 int get_scc_id (int node_index) const
684 {
685 return m_per_node[node_index].m_lowlink;
686 }
687
688 void dump () const;
689
690 std::unique_ptr<json::array> to_json () const;
691
692private:
694 {
696 : m_id (-1), m_lowlink (-1), m_on_stack (false)
697 {}
698
699 int m_id;
702 };
703
704 void strong_connect (unsigned index, logger *logger);
705
709};
710
711/* The worklist of exploded_node instances that have been added to
712 an exploded_graph, but that haven't yet been processed to find
713 their successors (or warnings).
714
715 The enodes are stored in a priority queue, ordered by a topological
716 sort of the SCCs in the supergraph, so that enodes for the same
717 program_point should appear at the front of the queue together.
718 This allows for state-merging at CFG join-points, so that
719 sufficiently-similar enodes can be merged into one. */
720
722{
723public:
724 worklist (const exploded_graph &eg, const analysis_plan &plan);
725 unsigned length () const;
728 void add_node (exploded_node *enode);
729 int get_scc_id (const supernode &snode) const
730 {
731 return m_scc.get_scc_id (snode.m_id);
732 }
733
734 std::unique_ptr<json::object> to_json () const;
735
736private:
737 class key_t
738 {
739 public:
740 key_t (const worklist &w, exploded_node *enode)
741 : m_worklist (w), m_enode (enode)
742 {}
743
744 bool operator< (const key_t &other) const
745 {
746 return cmp (*this, other) < 0;
747 }
748
749 bool operator== (const key_t &other) const
750 {
751 return cmp (*this, other) == 0;
752 }
753
754 bool operator> (const key_t &other) const
755 {
756 return !(*this == other || *this < other);
757 }
758
759 private:
760 static int cmp (const key_t &ka, const key_t &kb);
761
762 int get_scc_id (const exploded_node *enode) const
763 {
764 const supernode *snode = enode->get_supernode ();
765 if (snode == nullptr)
766 return 0;
767 return m_worklist.m_scc.get_scc_id (snode->m_id);
768 }
769
772 };
773
774 /* The order is important here: m_scc needs to stick around
775 until after m_queue has finished being cleaned up (the dtor
776 calls the ordering fns). */
779
780 /* Priority queue, backed by a fibonacci_heap. */
783};
784
785/* An exploded_graph is a directed graph of unique <point, state> pairs.
786 It also has a worklist of nodes that are waiting for their successors
787 to be added to the graph. */
788
789class exploded_graph : public digraph<eg_traits>
790{
791public:
792 typedef hash_map <const call_string *,
794
797 const state_purge_map *purge_map,
798 const analysis_plan &plan,
799 int verbosity);
801
802 logger *get_logger () const { return m_logger.get_logger (); }
803
804 const supergraph &get_supergraph () const { return m_sg; }
805 const extrinsic_state &get_ext_state () const { return m_ext_state; }
806 engine *get_engine () const { return m_ext_state.get_engine (); }
807 const state_purge_map *get_purge_map () const { return m_purge_map; }
808 const analysis_plan &get_analysis_plan () const { return m_plan; }
809
810 exploded_node *get_origin () const { return m_origin; }
811
813
818
820 const program_state &state,
821 exploded_node *enode_for_diag,
822 bool add_to_worklist = true);
824 const superedge *sedge, bool could_do_work,
825 std::unique_ptr<custom_edge_info> custom = nullptr);
826
831
834
838
840 const exploded_node *enode,
841 const supernode *node, const gimple *stmt,
844
850 {
852 }
853
856 void log_stats () const;
857 void dump_stats (FILE *) const;
858 void dump_exploded_nodes () const;
859
860 std::unique_ptr<json::object> to_json () const;
861
863
866
867 int get_scc_id (const supernode &node) const
868 {
869 return m_worklist.get_scc_id (node);
870 }
871
873
875 const gimple *stmt,
877
878 /* In infinite-loop.cc */
879 void detect_infinite_loops ();
880
881 /* In infinite-recursion.cc */
884 exploded_node *enode) const;
885
886private:
888
890
892
894
895 /* Map from point/state to exploded node.
896 To avoid duplication we store point_and_state
897 *pointers* as keys, rather than point_and_state, using the
898 instance from within the exploded_node, with a custom hasher. */
899 typedef hash_map <const point_and_state *, exploded_node *,
902
903 /* Map from program_point to per-program_point data. */
907
909
911
913
915
917
920
922
923 /* Stats. */
928
930
931 /* Functions with a top-level enode, to make add_function_entry
932 be idempotent, for use in handling callbacks. */
934};
935
936/* A reason why a particular exploded_path is infeasible. */
937
939{
940public:
941 feasibility_problem (unsigned eedge_idx,
942 const exploded_edge &eedge,
943 std::unique_ptr<rejected_constraint> rc)
944 : m_eedge_idx (eedge_idx), m_eedge (eedge),
945 m_rc (std::move (rc))
946 {}
947
948 void dump_to_pp (pretty_printer *pp) const;
949
950 unsigned m_eedge_idx;
952 std::unique_ptr<rejected_constraint> m_rc;
953};
954
955/* A class for capturing the state of a node when checking a path
956 through the exploded_graph for feasibility. */
957
959{
960public:
962 const supergraph &sg);
964 const supergraph &sg);
966
968
970 const exploded_edge *eedge,
972 std::unique_ptr<rejected_constraint> *out_rc);
973
975 const region_model &get_model () const { return m_model; }
978
979 void dump_to_pp (pretty_printer *pp, bool simple, bool multiline) const;
980
981private:
984};
985
986// TODO: split the above up?
987
988} // namespace ana
989
990#endif /* GCC_ANALYZER_EXPLODED_GRAPH_H */
Definition analysis-plan.h:35
Definition ops.h:433
Definition call-string.h:41
Definition checker-path.h:32
Definition common.h:439
Definition diagnostic-manager.h:161
Definition region-model.h:1314
Definition exploded-graph.h:331
std::unique_ptr< json::object > to_json() const
const operation * maybe_get_op() const
void dump_dot_label(pretty_printer *pp) const
bool m_could_do_work_p
Definition exploded-graph.h:371
exploded_edge(exploded_node *src, exploded_node *dest, const superedge *sedge, bool could_do_work, std::unique_ptr< custom_edge_info > custom_info)
std::unique_ptr< custom_edge_info > m_custom_info
Definition exploded-graph.h:348
void dump_dot(graphviz_out *gv, const dump_args_t &args) const final override
bool could_do_work_p() const
Definition exploded-graph.h:350
DISABLE_COPY_AND_ASSIGN(exploded_edge)
const gimple * maybe_get_stmt() const
const superedge *const m_sedge
Definition exploded-graph.h:343
Definition exploded-graph.h:790
hash_map< const point_and_state *, exploded_node *, eg_hash_map_traits > map_t
Definition exploded-graph.h:900
void log_stats() const
stats * get_global_stats()
Definition exploded-graph.h:854
const call_string_data_map_t * get_per_call_string_data() const
Definition exploded-graph.h:864
const state_purge_map * get_purge_map() const
Definition exploded-graph.h:807
const extrinsic_state & m_ext_state
Definition exploded-graph.h:912
void detect_infinite_recursion(exploded_node *enode)
Definition infinite-recursion.cc:585
call_string_data_map_t m_per_call_string_data
Definition exploded-graph.h:929
stats m_functionless_stats
Definition exploded-graph.h:927
exploded_node * find_previous_entry_to(function *top_of_stack_fun, exploded_node *enode) const
Definition infinite-recursion.cc:328
function_stat_map_t m_per_function_stats
Definition exploded-graph.h:926
exploded_edge * add_edge(exploded_node *src, exploded_node *dest, const superedge *sedge, bool could_do_work, std::unique_ptr< custom_edge_info > custom=nullptr)
void detect_infinite_loops()
Definition infinite-loop.cc:555
void process_node(exploded_node *node)
engine * get_engine() const
Definition exploded-graph.h:806
point_map_t m_per_point_data
Definition exploded-graph.h:906
diagnostic_manager & get_diagnostic_manager()
Definition exploded-graph.h:845
exploded_node * add_function_entry(const function &fun)
per_function_data * get_per_function_data(function *) const
log_user m_logger
Definition exploded-graph.h:893
bool maybe_process_run_of_enodes(exploded_node *node)
const supergraph & get_supergraph() const
Definition exploded-graph.h:804
const analysis_plan & get_analysis_plan() const
Definition exploded-graph.h:808
map_t m_point_and_state_to_node
Definition exploded-graph.h:901
const supergraph & m_sg
Definition exploded-graph.h:891
exploded_graph(const supergraph &sg, logger *logger, const extrinsic_state &ext_state, const state_purge_map *purge_map, const analysis_plan &plan, int verbosity)
diagnostic_manager m_diagnostic_manager
Definition exploded-graph.h:921
hash_map< function *, per_function_data * > per_function_data_t
Definition exploded-graph.h:918
void build_initial_worklist()
per_call_string_data * get_or_create_per_call_string_data(const call_string &)
const diagnostic_manager & get_diagnostic_manager() const
Definition exploded-graph.h:849
per_program_point_data * get_per_program_point_data(const program_point &) const
logger * get_logger() const
Definition exploded-graph.h:802
exploded_node * m_origin
Definition exploded-graph.h:910
per_function_data * get_or_create_per_function_data(function *)
void on_escaped_function(tree fndecl)
void dump_exploded_nodes() const
hash_map< const call_string *, per_call_string_data * > call_string_data_map_t
Definition exploded-graph.h:793
hash_set< function * > m_functions_with_enodes
Definition exploded-graph.h:933
stats * get_or_create_function_stats(function *fn)
void print_bar_charts(pretty_printer *pp) const
stats m_global_stats
Definition exploded-graph.h:924
ordered_hash_map< function *, stats * > function_stat_map_t
Definition exploded-graph.h:925
const extrinsic_state & get_ext_state() const
Definition exploded-graph.h:805
worklist m_worklist
Definition exploded-graph.h:908
void dump_stats(FILE *) const
int get_scc_id(const supernode &node) const
Definition exploded-graph.h:867
hash_map< const program_point *, per_program_point_data *, eg_point_hash_map_traits > point_map_t
Definition exploded-graph.h:905
std::unique_ptr< json::object > to_json() const
void save_diagnostic(const state_machine &sm, const exploded_node *enode, const supernode *node, const gimple *stmt, tree var, state_machine::state_t state, pending_diagnostic *d)
const state_purge_map *const m_purge_map
Definition exploded-graph.h:914
const analysis_plan & m_plan
Definition exploded-graph.h:916
void unwind_from_exception(exploded_node &enode, const gimple *stmt, region_model_context *ctxt)
exploded_node * get_or_create_node(const program_point &point, const program_state &state, exploded_node *enode_for_diag, bool add_to_worklist=true)
per_program_point_data * get_or_create_per_program_point_data(const program_point &)
per_function_data_t m_per_function_data
Definition exploded-graph.h:919
exploded_node * get_origin() const
Definition exploded-graph.h:810
exploded_node * get_node_by_index(int idx) const
DISABLE_COPY_AND_ASSIGN(exploded_graph)
Definition exploded-graph.h:206
DISABLE_COPY_AND_ASSIGN(exploded_node)
const point_and_state * get_ps_key() const
Definition exploded-graph.h:284
void dump(const extrinsic_state &ext_state) const
status
Definition exploded-graph.h:213
@ special
Definition exploded-graph.h:222
@ bulk_merged
Definition exploded-graph.h:229
@ worklist
Definition exploded-graph.h:215
@ merger
Definition exploded-graph.h:226
function * get_function() const
Definition exploded-graph.h:273
void dump_to_pp(pretty_printer *pp, const extrinsic_state &ext_state) const
location_t get_location() const
Definition exploded-graph.h:269
unsigned get_num_diagnostics() const
Definition exploded-graph.h:300
void dump_saved_diagnostics(pretty_printer *pp) const
void dump_dot(graphviz_out *gv, const dump_args_t &args) const final override
void on_throw(exploded_graph &eg, const gcall &call, const program_point &after_throw_point, program_state *new_state, bool is_rethrow, region_model_context *ctxt)
std::unique_ptr< json::object > to_json(const extrinsic_state &ext_state) const
void add_diagnostic(const saved_diagnostic *sd)
Definition exploded-graph.h:296
void dump_processed_stmts(pretty_printer *pp) const
const point_and_state m_ps
Definition exploded-graph.h:314
const char * get_dot_fillcolor() const
void dump_dot_id(pretty_printer *pp) const
const program_state & get_state() const
Definition exploded-graph.h:282
static const char * status_to_str(enum status s)
void dump_succs_and_preds(FILE *outf) const
const int m_index
Definition exploded-graph.h:324
const program_point * get_point_key() const
Definition exploded-graph.h:285
enum status get_status() const
Definition exploded-graph.h:289
void set_status(enum status s)
Definition exploded-graph.h:290
int get_stack_depth() const
Definition exploded-graph.h:277
void on_longjmp(exploded_graph &eg, const gcall &call, program_state *new_state, region_model_context *ctxt)
exploded_node(const point_and_state &ps, int index)
const program_point & get_point() const
Definition exploded-graph.h:264
void dump(FILE *fp, const extrinsic_state &ext_state) const
auto_vec< const saved_diagnostic * > m_saved_diagnostics
Definition exploded-graph.h:320
const supernode * get_supernode() const
Definition exploded-graph.h:265
void detect_leaks(exploded_graph &eg)
hashval_t hash() const
Definition exploded-graph.h:235
enum status m_status
Definition exploded-graph.h:316
const saved_diagnostic * get_saved_diagnostic(unsigned idx) const
Definition exploded-graph.h:304
Definition program-state.h:34
feasibility_problem(unsigned eedge_idx, const exploded_edge &eedge, std::unique_ptr< rejected_constraint > rc)
Definition exploded-graph.h:941
const exploded_edge & m_eedge
Definition exploded-graph.h:951
void dump_to_pp(pretty_printer *pp) const
unsigned m_eedge_idx
Definition exploded-graph.h:950
std::unique_ptr< rejected_constraint > m_rc
Definition exploded-graph.h:952
bool maybe_update_for_edge(logger *logger, const exploded_edge *eedge, region_model_context *ctxt, std::unique_ptr< rejected_constraint > *out_rc)
auto_sbitmap & get_snodes_visited()
Definition exploded-graph.h:976
feasibility_state(const region_model &model, const supergraph &sg)
auto_sbitmap m_snodes_visited
Definition exploded-graph.h:983
feasibility_state(region_model_manager *manager, const supergraph &sg)
void dump_to_pp(pretty_printer *pp, bool simple, bool multiline) const
region_model & get_model()
Definition exploded-graph.h:974
feasibility_state(const feasibility_state &other)
region_model m_model
Definition exploded-graph.h:982
const region_model & get_model() const
Definition exploded-graph.h:975
feasibility_state & operator=(const feasibility_state &other)
const auto_sbitmap & get_snodes_visited() const
Definition exploded-graph.h:977
Definition region.h:320
void on_condition(const svalue *lhs, enum tree_code op, const svalue *rhs) final override
void on_unknown_change(const svalue *sval, bool is_mutable) final override
void terminate_path() final override
impl_region_model_context(exploded_graph &eg, exploded_node *enode_for_diag, const program_state *old_state, program_state *new_state, uncertainty_t *uncertainty, path_context *path_ctxt, const gimple *stmt=nullptr, bool *out_could_have_done_work=nullptr)
exploded_graph * m_eg
Definition exploded-graph.h:123
const extrinsic_state & m_ext_state
Definition exploded-graph.h:129
logger * get_logger() final override
Definition exploded-graph.h:67
void on_svalue_leak(const svalue *) override
void on_pop_frame(const frame_region *frame_reg) final override
void on_liveness_change(const svalue_set &live_svalues, const region_model *model) final override
void add_note(std::unique_ptr< pending_note > pn) final override
bool * m_out_could_have_done_work
Definition exploded-graph.h:132
bool warn_at(std::unique_ptr< pending_diagnostic > d, pending_location &&ploc) final override
void on_state_leak(const state_machine &sm, const svalue *sval, state_machine::state_t state)
impl_region_model_context(program_state *state, const extrinsic_state &ext_state, uncertainty_t *uncertainty, logger *logger=nullptr)
void add_event(std::unique_ptr< checker_event > event) final override
pending_location get_pending_location_for_diag() const override
program_state * m_new_state
Definition exploded-graph.h:127
log_user m_logger
Definition exploded-graph.h:124
const program_state * m_old_state
Definition exploded-graph.h:126
void on_unusable_in_infinite_loop() override
Definition exploded-graph.h:118
const program_state * get_state() const override
Definition exploded-graph.h:114
void on_phi(const gphi *phi, tree rhs) final override
void on_unexpected_tree_code(tree t, const dump_location_t &loc) final override
void on_escaped_function(tree fndecl) final override
void bifurcate(std::unique_ptr< custom_edge_info > info) final override
path_context * m_path_ctxt
Definition exploded-graph.h:131
void purge_state_involving(const svalue *sval) final override
void on_bounded_ranges(const svalue &sval, const bounded_ranges &ranges) final override
uncertainty_t * get_uncertainty() final override
const gimple * m_stmt
Definition exploded-graph.h:128
uncertainty_t * m_uncertainty
Definition exploded-graph.h:130
const gimple * get_stmt() const override
Definition exploded-graph.h:111
bool get_state_map_by_name(const char *name, sm_state_map **out_smap, const state_machine **out_sm, unsigned *out_sm_idx, std::unique_ptr< sm_context > *out_sm_context) override
bool checking_for_infinite_loop_p() const override
Definition exploded-graph.h:117
const extrinsic_state * get_ext_state() const final override
Definition exploded-graph.h:100
const exploded_graph * get_eg() const override
Definition exploded-graph.h:112
exploded_node * m_enode_for_diag
Definition exploded-graph.h:125
interprocedural_call(const call_and_return_op &op, function &callee_fun)
Definition exploded-graph.h:380
void get_dot_attrs(const char *&out_style, const char *&out_color) const final override
bool update_model(region_model *model, const exploded_edge *eedge, region_model_context *ctxt) const final override
const gcall & get_gcall() const
void add_events_to_path(checker_path *emission_path, const exploded_edge &eedge, pending_diagnostic &pd, const state_transition *state_trans) const final override
const call_and_return_op & m_op
Definition exploded-graph.h:410
bool update_state(program_state *state, const exploded_edge *eedge, region_model_context *ctxt) const final override
bool try_to_rewind_data_flow(rewind_context &) const final override
function & m_callee_fun
Definition exploded-graph.h:411
void print(pretty_printer *pp) const final override
const gcall & m_call_stmt
Definition exploded-graph.h:446
void print(pretty_printer *pp) const final override
bool try_to_rewind_data_flow(rewind_context &) const final override
interprocedural_return(const gcall &call_stmt)
Definition exploded-graph.h:420
bool update_model(region_model *model, const exploded_edge *eedge, region_model_context *ctxt) const final override
bool update_state(program_state *state, const exploded_edge *eedge, region_model_context *ctxt) const final override
void get_dot_attrs(const char *&out_style, const char *&out_color) const final override
void add_events_to_path(checker_path *emission_path, const exploded_edge &eedge, pending_diagnostic &pd, const state_transition *state_trans) const final override
Definition analyzer-logging.h:193
Definition analyzer-logging.h:36
Definition ops.h:113
Definition common.h:489
Definition pending-diagnostic.h:258
Definition exploded-graph.h:140
hashval_t m_hash
Definition exploded-graph.h:176
bool operator==(const point_and_state &other) const
Definition exploded-graph.h:157
void validate(const extrinsic_state &ext_state) const
const program_state & get_state() const
Definition exploded-graph.h:163
program_state m_state
Definition exploded-graph.h:175
program_point m_point
Definition exploded-graph.h:174
point_and_state(const program_point &point, const program_state &state)
Definition exploded-graph.h:142
const program_point & get_point() const
Definition exploded-graph.h:162
hashval_t hash() const
Definition exploded-graph.h:153
void set_state(const program_state &state)
Definition exploded-graph.h:165
Definition program-point.h:54
location_t get_location() const
Definition program-point.h:98
function * get_function() const
Definition program-point.h:88
const supernode * get_supernode() const
Definition program-point.h:82
int get_stack_depth() const
Definition program-point.h:107
const call_string & get_call_string() const
Definition program-point.h:86
hashval_t hash() const
Definition program-state.h:224
Definition region-model.h:748
Definition region-model-manager.h:32
Definition region-model.h:294
setjmp_record m_setjmp_record
Definition exploded-graph.h:505
program_point get_point_before_setjmp() const
Definition exploded-graph.h:476
bool update_model(region_model *model, const exploded_edge *eedge, region_model_context *ctxt) const final override
void add_events_to_path(checker_path *emission_path, const exploded_edge &eedge, pending_diagnostic &pd, const state_transition *state_trans) const final override
const gcall & get_setjmp_call() const
Definition exploded-graph.h:489
void print(pretty_printer *pp) const final override
Definition exploded-graph.h:461
const exploded_node * get_enode_origin() const
Definition exploded-graph.h:499
const gcall & m_longjmp_call
Definition exploded-graph.h:506
program_point get_point_after_setjmp() const
Definition exploded-graph.h:482
rewind_info_t(const setjmp_record &setjmp_record, const gcall &longjmp_call)
Definition exploded-graph.h:455
const gcall & get_longjmp_call() const
Definition exploded-graph.h:494
Definition diagnostic-manager.h:79
Definition program-state.h:92
Definition sm.h:43
const state_machine::state * state_t
Definition sm.h:63
Definition state-purge.h:31
Definition state-transition.h:31
Definition exploded-graph.h:679
void strong_connect(unsigned index, logger *logger)
int get_scc_id(int node_index) const
Definition exploded-graph.h:683
auto_vec< per_node_data > m_per_node
Definition exploded-graph.h:708
const supergraph & m_sg
Definition exploded-graph.h:706
strongly_connected_components(const supergraph &sg, logger *logger)
auto_vec< unsigned > m_stack
Definition exploded-graph.h:707
std::unique_ptr< json::array > to_json() const
Definition supergraph.h:281
Definition supergraph.h:105
Definition supergraph.h:224
int m_id
Definition supergraph.h:268
Definition svalue.h:92
Definition store.h:162
bool operator<(const key_t &other) const
Definition exploded-graph.h:744
const worklist & m_worklist
Definition exploded-graph.h:770
bool operator==(const key_t &other) const
Definition exploded-graph.h:749
exploded_node * m_enode
Definition exploded-graph.h:771
bool operator>(const key_t &other) const
Definition exploded-graph.h:754
static int cmp(const key_t &ka, const key_t &kb)
int get_scc_id(const exploded_node *enode) const
Definition exploded-graph.h:762
key_t(const worklist &w, exploded_node *enode)
Definition exploded-graph.h:740
Definition exploded-graph.h:722
std::unique_ptr< json::object > to_json() const
void add_node(exploded_node *enode)
strongly_connected_components m_scc
Definition exploded-graph.h:777
worklist(const exploded_graph &eg, const analysis_plan &plan)
queue_t m_queue
Definition exploded-graph.h:782
exploded_node * take_next()
fibonacci_heap< key_t, exploded_node > queue_t
Definition exploded-graph.h:781
exploded_node * peek_next()
const analysis_plan & m_plan
Definition exploded-graph.h:778
int get_scc_id(const supernode &snode) const
Definition exploded-graph.h:729
unsigned length() const
Definition sbitmap.h:303
Definition vec.h:1667
dedge(node_t *src, node_t *dest)
Definition digraph.h:93
eg_traits::dump_args_t dump_args_t
Definition digraph.h:91
digraph()
Definition digraph.h:128
Definition digraph.h:43
eg_traits::dump_args_t dump_args_t
Definition digraph.h:46
Definition dumpfile.h:446
Definition ree.cc:583
Definition fibonacci_heap.h:143
Definition graphviz.h:388
Definition hash-map.h:40
Definition hash-set.h:37
Definition ordered-hash-map.h:35
Definition pretty-print.h:241
union tree_node * tree
Definition coretypes.h:97
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2009
tree_code
Definition genmatch.cc:1002
Definition access-diagram.h:30
@ stmt
Definition checker-event.h:38
@ custom
Definition checker-event.h:37
hash_set< const svalue * > svalue_set
Definition common.h:76
Definition custom-sarif-properties/state-graphs.h:33
void pp_string(pretty_printer *pp, const char *str)
Definition pretty-print.cc:2764
Definition constraint-manager.h:123
Definition exploded-graph.h:529
static bool equal_keys(const key_type &k1, const key_type &k2)
Definition exploded-graph.h:540
static void mark_empty(T &entry)
Definition exploded-graph.h:563
static void mark_deleted(T &entry)
Definition exploded-graph.h:558
static bool is_deleted(const T &entry)
Definition exploded-graph.h:568
static const bool empty_zero_p
Definition exploded-graph.h:577
exploded_node * compare_type
Definition exploded-graph.h:532
const point_and_state * key_type
Definition exploded-graph.h:530
exploded_node * value_type
Definition exploded-graph.h:531
static void remove(T &)
Definition exploded-graph.h:553
static hashval_t hash(const key_type &k)
Definition exploded-graph.h:534
static bool is_empty(const T &entry)
Definition exploded-graph.h:573
Definition exploded-graph.h:599
static bool is_deleted(const T &entry)
Definition exploded-graph.h:638
static const bool empty_zero_p
Definition exploded-graph.h:647
static void mark_empty(T &entry)
Definition exploded-graph.h:633
static hashval_t hash(const key_type &k)
Definition exploded-graph.h:604
const program_point * key_type
Definition exploded-graph.h:600
per_program_point_data * value_type
Definition exploded-graph.h:601
per_program_point_data * compare_type
Definition exploded-graph.h:602
static void mark_deleted(T &entry)
Definition exploded-graph.h:628
static bool is_empty(const T &entry)
Definition exploded-graph.h:643
static bool equal_keys(const key_type &k1, const key_type &k2)
Definition exploded-graph.h:610
static void remove(T &)
Definition exploded-graph.h:623
bool show_enode_details_p(const exploded_node &enode) const
const exploded_graph & m_eg
Definition exploded-graph.h:195
virtual void dump_extra_info(const exploded_node *, pretty_printer *) const
Definition exploded-graph.h:193
dump_args_t(const exploded_graph &eg)
Definition exploded-graph.h:188
Definition exploded-graph.h:182
exploded_graph graph_t
Definition exploded-graph.h:185
exploded_edge edge_t
Definition exploded-graph.h:184
exploded_node node_t
Definition exploded-graph.h:183
exploded_cluster cluster_t
Definition exploded-graph.h:197
Definition diagnostic-manager.h:35
Definition exploded-graph.h:653
stats m_stats
Definition exploded-graph.h:659
const call_string & m_key
Definition exploded-graph.h:658
per_call_string_data(const call_string &key, int num_supernodes)
Definition exploded-graph.h:654
Definition exploded-graph.h:665
per_function_data()
Definition exploded-graph.h:666
auto_vec< call_summary * > m_summaries
Definition exploded-graph.h:671
void add_call_summary(exploded_node *node)
Definition exploded-graph.h:583
const program_point m_key
Definition exploded-graph.h:588
int m_excess_enodes
Definition exploded-graph.h:592
per_program_point_data(const program_point &key)
Definition exploded-graph.h:584
auto_vec< exploded_node * > m_enodes
Definition exploded-graph.h:589
Definition ops.h:78
Definition svalue.h:551
Definition exploded-graph.h:512
void log(logger *logger) const
void dump(FILE *out) const
int m_num_nodes
Definition exploded-graph.h:519
int m_num_supernodes
Definition exploded-graph.h:522
int m_node_reuse_after_merge_count
Definition exploded-graph.h:521
stats(int num_supernodes)
int get_total_enodes() const
int m_node_reuse_count
Definition exploded-graph.h:520
per_node_data()
Definition exploded-graph.h:695
bool m_on_stack
Definition exploded-graph.h:701
int m_id
Definition exploded-graph.h:699
int m_lowlink
Definition exploded-graph.h:700
Definition function.h:249
Definition gimple.h:355
Definition gimple.h:224
Definition gimple.h:464
Definition ira-emit.cc:158
Definition gengtype.h:377
Definition genautomata.cc:669
#define gcc_assert(EXPR)
Definition system.h:817
#define false
Definition system.h:891
static sbitmap processed
Definition tree-ssa-dce.cc:89
static void add_to_worklist(same_succ *same)
Definition tree-ssa-tail-merge.cc:714