]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/analyzer/exploded-graph.h
analyzer: fix ICEs in region_model::get_lvalue_1 [PR 93388]
[thirdparty/gcc.git] / gcc / analyzer / exploded-graph.h
1 /* Classes for managing a directed graph of <point, state> pairs.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along 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 namespace ana {
25
26 /* Concrete implementation of region_model_context, wiring it up to the
27 rest of the analysis engine. */
28
29 class impl_region_model_context : public region_model_context
30 {
31 public:
32 impl_region_model_context (exploded_graph &eg,
33 const exploded_node *enode_for_diag,
34
35 /* TODO: should we be getting the ECs from the
36 old state, rather than the new? */
37 const program_state *old_state,
38 program_state *new_state,
39 state_change *change,
40
41 const gimple *stmt,
42 stmt_finder *stmt_finder = NULL);
43
44 impl_region_model_context (program_state *state,
45 state_change *change,
46 const extrinsic_state &ext_state);
47
48 void warn (pending_diagnostic *d) FINAL OVERRIDE;
49
50 void remap_svalue_ids (const svalue_id_map &map) FINAL OVERRIDE;
51
52 int on_svalue_purge (svalue_id first_unused_sid,
53 const svalue_id_map &map) FINAL OVERRIDE;
54
55 logger *get_logger () FINAL OVERRIDE
56 {
57 return m_logger.get_logger ();
58 }
59
60 void on_state_leak (const state_machine &sm,
61 int sm_idx,
62 svalue_id sid,
63 svalue_id first_unused_sid,
64 const svalue_id_map &map,
65 state_machine::state_t state);
66
67 void on_inherited_svalue (svalue_id parent_sid,
68 svalue_id child_sid) FINAL OVERRIDE;
69
70 void on_cast (svalue_id src_sid,
71 svalue_id dst_sid) FINAL OVERRIDE;
72
73 void on_condition (tree lhs, enum tree_code op, tree rhs) FINAL OVERRIDE;
74
75 void on_unknown_change (svalue_id sid ATTRIBUTE_UNUSED) FINAL OVERRIDE;
76
77 void on_phi (const gphi *phi, tree rhs) FINAL OVERRIDE;
78
79 void on_unknown_tree_code (path_var pv,
80 const dump_location_t &loc) FINAL OVERRIDE;
81
82 exploded_graph *m_eg;
83 log_user m_logger;
84 const exploded_node *m_enode_for_diag;
85 const program_state *m_old_state;
86 program_state *m_new_state;
87 state_change *m_change;
88 const gimple *m_stmt;
89 stmt_finder *m_stmt_finder;
90 const extrinsic_state &m_ext_state;
91 };
92
93 /* A <program_point, program_state> pair, used internally by
94 exploded_node as its immutable data, and as a key for identifying
95 exploded_nodes we've already seen in the graph. */
96
97 class point_and_state
98 {
99 public:
100 point_and_state (const program_point &point,
101 const program_state &state)
102 : m_point (point),
103 m_state (state),
104 m_hash (m_point.hash () ^ m_state.hash ())
105 {
106 /* We shouldn't be building point_and_states and thus exploded_nodes
107 for states that aren't valid. */
108 gcc_assert (state.m_valid);
109 }
110
111 hashval_t hash () const
112 {
113 return m_hash;
114 }
115 bool operator== (const point_and_state &other) const
116 {
117 return m_point == other.m_point && m_state == other.m_state;
118 }
119
120 const program_point &get_point () const { return m_point; }
121 const program_state &get_state () const { return m_state; }
122
123 void set_state (const program_state &state)
124 {
125 m_state = state;
126 m_hash = m_point.hash () ^ m_state.hash ();
127 }
128
129 void validate (const extrinsic_state &ext_state) const;
130
131 private:
132 program_point m_point;
133 program_state m_state;
134 hashval_t m_hash;
135 };
136
137 /* A traits class for exploded graphs and their nodes and edges. */
138
139 struct eg_traits
140 {
141 typedef exploded_node node_t;
142 typedef exploded_edge edge_t;
143 typedef exploded_graph graph_t;
144 struct dump_args_t
145 {
146 dump_args_t (const exploded_graph &eg) : m_eg (eg) {}
147 const exploded_graph &m_eg;
148 };
149 typedef exploded_cluster cluster_t;
150 };
151
152 /* An exploded_node is a unique, immutable <point, state> pair within the
153 exploded_graph.
154 Each exploded_node has a unique index within the graph
155 (for ease of debugging). */
156
157 class exploded_node : public dnode<eg_traits>
158 {
159 public:
160 /* Has this enode had exploded_graph::process_node called on it?
161 This allows us to distinguish enodes that were merged during
162 worklist-handling, and thus never had process_node called on them
163 (in favor of processing the merged node). */
164 enum status
165 {
166 /* Node is in the worklist. */
167 STATUS_WORKLIST,
168
169 /* Node has had exploded_graph::process_node called on it. */
170 STATUS_PROCESSED,
171
172 /* Node was left unprocessed due to merger; it won't have had
173 exploded_graph::process_node called on it. */
174 STATUS_MERGER
175 };
176
177 exploded_node (point_and_state ps,
178 int index)
179 : m_ps (ps), m_status (STATUS_WORKLIST), m_index (index)
180 {
181 gcc_checking_assert (ps.get_state ().m_region_model->canonicalized_p ());
182 }
183
184 hashval_t hash () const { return m_ps.hash (); }
185
186 void dump_dot (graphviz_out *gv, const dump_args_t &args)
187 const FINAL OVERRIDE;
188 void dump_dot_id (pretty_printer *pp) const;
189
190 void dump_to_pp (pretty_printer *pp, const extrinsic_state &ext_state) const;
191 void dump (FILE *fp, const extrinsic_state &ext_state) const;
192 void dump (const extrinsic_state &ext_state) const;
193
194 /* The result of on_stmt. */
195 struct on_stmt_flags
196 {
197 on_stmt_flags (bool sm_changes)
198 : m_sm_changes (sm_changes),
199 m_terminate_path (false)
200 {}
201
202 static on_stmt_flags terminate_path ()
203 {
204 return on_stmt_flags (true, true);
205 }
206
207 static on_stmt_flags state_change (bool any_sm_changes)
208 {
209 return on_stmt_flags (any_sm_changes, false);
210 }
211
212 /* Did any sm-changes occur handling the stmt. */
213 bool m_sm_changes : 1;
214
215 /* Should we stop analyzing this path (on_stmt may have already
216 added nodes/edges, e.g. when handling longjmp). */
217 bool m_terminate_path : 1;
218
219 private:
220 on_stmt_flags (bool sm_changes,
221 bool terminate_path)
222 : m_sm_changes (sm_changes),
223 m_terminate_path (terminate_path)
224 {}
225 };
226
227 on_stmt_flags on_stmt (exploded_graph &eg,
228 const supernode *snode,
229 const gimple *stmt,
230 program_state *state,
231 state_change *change) const;
232 bool on_edge (exploded_graph &eg,
233 const superedge *succ,
234 program_point *next_point,
235 program_state *next_state,
236 state_change *change) const;
237 void on_longjmp (exploded_graph &eg,
238 const gcall *call,
239 program_state *new_state,
240 region_model_context *ctxt) const;
241
242 void detect_leaks (exploded_graph &eg) const;
243
244 const program_point &get_point () const { return m_ps.get_point (); }
245 const supernode *get_supernode () const
246 {
247 return get_point ().get_supernode ();
248 }
249 function *get_function () const
250 {
251 return get_point ().get_function ();
252 }
253 int get_stack_depth () const
254 {
255 return get_point ().get_stack_depth ();
256 }
257 const gimple *get_stmt () const { return get_point ().get_stmt (); }
258
259 const program_state &get_state () const { return m_ps.get_state (); }
260
261 const point_and_state *get_ps_key () const { return &m_ps; }
262 const program_point *get_point_key () const { return &m_ps.get_point (); }
263
264 void dump_succs_and_preds (FILE *outf) const;
265
266 enum status get_status () const { return m_status; }
267 void set_status (enum status status)
268 {
269 gcc_assert (m_status == STATUS_WORKLIST);
270 m_status = status;
271 }
272
273 private:
274 DISABLE_COPY_AND_ASSIGN (exploded_node);
275
276 const char * get_dot_fillcolor () const;
277
278 /* The <program_point, program_state> pair. This is const, as it
279 is immutable once the exploded_node has been created. */
280 const point_and_state m_ps;
281
282 enum status m_status;
283
284 public:
285 /* The index of this exploded_node. */
286 const int m_index;
287 };
288
289 /* An edge within the exploded graph.
290 Some exploded_edges have an underlying superedge; others don't. */
291
292 class exploded_edge : public dedge<eg_traits>
293 {
294 public:
295 /* Abstract base class for associating custom data with an
296 exploded_edge, for handling non-standard edges such as
297 rewinding from a longjmp, signal handlers, etc. */
298 class custom_info_t
299 {
300 public:
301 virtual ~custom_info_t () {}
302
303 /* Hook for making .dot label more readable . */
304 virtual void print (pretty_printer *pp) = 0;
305
306 /* Hook for updating MODEL within exploded_path::feasible_p. */
307 virtual void update_model (region_model *model,
308 const exploded_edge &eedge) = 0;
309
310 virtual void add_events_to_path (checker_path *emission_path,
311 const exploded_edge &eedge) = 0;
312 };
313
314 exploded_edge (exploded_node *src, exploded_node *dest,
315 const extrinsic_state &ext_state,
316 const superedge *sedge,
317 const state_change &change,
318 custom_info_t *custom_info);
319 ~exploded_edge ();
320 void dump_dot (graphviz_out *gv, const dump_args_t &args)
321 const FINAL OVERRIDE;
322
323 //private:
324 const superedge *const m_sedge;
325
326 const state_change m_change;
327
328 /* NULL for most edges; will be non-NULL for special cases
329 such as an unwind from a longjmp to a setjmp, or when
330 a signal is delivered to a signal-handler.
331
332 Owned by this class. */
333 custom_info_t *m_custom_info;
334
335 private:
336 DISABLE_COPY_AND_ASSIGN (exploded_edge);
337 };
338
339 /* Extra data for an exploded_edge that represents a rewind from a
340 longjmp to a setjmp (or from a siglongjmp to a sigsetjmp). */
341
342 class rewind_info_t : public exploded_edge::custom_info_t
343 {
344 public:
345 rewind_info_t (const setjmp_record &setjmp_record,
346 const gcall *longjmp_call)
347 : m_setjmp_record (setjmp_record),
348 m_longjmp_call (longjmp_call)
349 {}
350
351 void print (pretty_printer *pp) FINAL OVERRIDE
352 {
353 pp_string (pp, "rewind");
354 }
355
356 void update_model (region_model *model,
357 const exploded_edge &eedge) FINAL OVERRIDE;
358
359 void add_events_to_path (checker_path *emission_path,
360 const exploded_edge &eedge) FINAL OVERRIDE;
361
362 const program_point &get_setjmp_point () const
363 {
364 const program_point &origin_point = get_enode_origin ()->get_point ();
365
366 /* "origin_point" ought to be before the call to "setjmp". */
367 gcc_assert (origin_point.get_kind () == PK_BEFORE_STMT);
368
369 /* TODO: assert that it's the final stmt in its supernode. */
370
371 return origin_point;
372 }
373
374 const gcall *get_setjmp_call () const
375 {
376 return m_setjmp_record.m_setjmp_call;
377 }
378
379 const gcall *get_longjmp_call () const
380 {
381 return m_longjmp_call;
382 }
383
384 const exploded_node *get_enode_origin () const
385 {
386 return m_setjmp_record.m_enode;
387 }
388
389 private:
390 setjmp_record m_setjmp_record;
391 const gcall *m_longjmp_call;
392 };
393
394 /* Statistics about aspects of an exploded_graph. */
395
396 struct stats
397 {
398 stats (int num_supernodes);
399 void log (logger *logger) const;
400 void dump (FILE *out) const;
401
402 int m_num_nodes[NUM_POINT_KINDS];
403 int m_node_reuse_count;
404 int m_node_reuse_after_merge_count;
405 int m_num_supernodes;
406 };
407
408 /* Traits class for ensuring uniqueness of point_and_state data within
409 an exploded_graph. */
410
411 struct eg_hash_map_traits
412 {
413 typedef const point_and_state *key_type;
414 typedef exploded_node *value_type;
415 typedef exploded_node *compare_type;
416
417 static inline hashval_t hash (const key_type &k)
418 {
419 gcc_assert (k != NULL);
420 gcc_assert (k != reinterpret_cast<key_type> (1));
421 return k->hash ();
422 }
423 static inline bool equal_keys (const key_type &k1, const key_type &k2)
424 {
425 gcc_assert (k1 != NULL);
426 gcc_assert (k2 != NULL);
427 gcc_assert (k1 != reinterpret_cast<key_type> (1));
428 gcc_assert (k2 != reinterpret_cast<key_type> (1));
429 if (k1 && k2)
430 return *k1 == *k2;
431 else
432 /* Otherwise they must both be non-NULL. */
433 return k1 == k2;
434 }
435 template <typename T>
436 static inline void remove (T &)
437 {
438 /* empty; the nodes are handled elsewhere. */
439 }
440 template <typename T>
441 static inline void mark_deleted (T &entry)
442 {
443 entry.m_key = reinterpret_cast<key_type> (1);
444 }
445 template <typename T>
446 static inline void mark_empty (T &entry)
447 {
448 entry.m_key = NULL;
449 }
450 template <typename T>
451 static inline bool is_deleted (const T &entry)
452 {
453 return entry.m_key == reinterpret_cast<key_type> (1);
454 }
455 template <typename T>
456 static inline bool is_empty (const T &entry)
457 {
458 return entry.m_key == NULL;
459 }
460 static const bool empty_zero_p = false;
461 };
462
463 /* Per-program_point data for an exploded_graph. */
464
465 struct per_program_point_data
466 {
467 per_program_point_data (const program_point &key)
468 : m_key (key)
469 {}
470
471 const program_point m_key;
472 auto_vec<exploded_node *> m_enodes;
473 };
474
475 /* Traits class for storing per-program_point data within
476 an exploded_graph. */
477
478 struct eg_point_hash_map_traits
479 {
480 typedef const program_point *key_type;
481 typedef per_program_point_data *value_type;
482 typedef per_program_point_data *compare_type;
483
484 static inline hashval_t hash (const key_type &k)
485 {
486 gcc_assert (k != NULL);
487 gcc_assert (k != reinterpret_cast<key_type> (1));
488 return k->hash ();
489 }
490 static inline bool equal_keys (const key_type &k1, const key_type &k2)
491 {
492 gcc_assert (k1 != NULL);
493 gcc_assert (k2 != NULL);
494 gcc_assert (k1 != reinterpret_cast<key_type> (1));
495 gcc_assert (k2 != reinterpret_cast<key_type> (1));
496 if (k1 && k2)
497 return *k1 == *k2;
498 else
499 /* Otherwise they must both be non-NULL. */
500 return k1 == k2;
501 }
502 template <typename T>
503 static inline void remove (T &)
504 {
505 /* empty; the nodes are handled elsewhere. */
506 }
507 template <typename T>
508 static inline void mark_deleted (T &entry)
509 {
510 entry.m_key = reinterpret_cast<key_type> (1);
511 }
512 template <typename T>
513 static inline void mark_empty (T &entry)
514 {
515 entry.m_key = NULL;
516 }
517 template <typename T>
518 static inline bool is_deleted (const T &entry)
519 {
520 return entry.m_key == reinterpret_cast<key_type> (1);
521 }
522 template <typename T>
523 static inline bool is_empty (const T &entry)
524 {
525 return entry.m_key == NULL;
526 }
527 static const bool empty_zero_p = false;
528 };
529
530 /* Data about a particular call_string within an exploded_graph. */
531
532 struct per_call_string_data
533 {
534 per_call_string_data (const call_string &key, int num_supernodes)
535 : m_key (key), m_stats (num_supernodes)
536 {}
537
538 const call_string m_key;
539 stats m_stats;
540 };
541
542 /* Traits class for storing per-call_string data within
543 an exploded_graph. */
544
545 struct eg_call_string_hash_map_traits
546 {
547 typedef const call_string *key_type;
548 typedef per_call_string_data *value_type;
549 typedef per_call_string_data *compare_type;
550
551 static inline hashval_t hash (const key_type &k)
552 {
553 gcc_assert (k != NULL);
554 gcc_assert (k != reinterpret_cast<key_type> (1));
555 return k->hash ();
556 }
557 static inline bool equal_keys (const key_type &k1, const key_type &k2)
558 {
559 gcc_assert (k1 != NULL);
560 gcc_assert (k2 != NULL);
561 gcc_assert (k1 != reinterpret_cast<key_type> (1));
562 gcc_assert (k2 != reinterpret_cast<key_type> (1));
563 if (k1 && k2)
564 return *k1 == *k2;
565 else
566 /* Otherwise they must both be non-NULL. */
567 return k1 == k2;
568 }
569 template <typename T>
570 static inline void remove (T &)
571 {
572 /* empty; the nodes are handled elsewhere. */
573 }
574 template <typename T>
575 static inline void mark_deleted (T &entry)
576 {
577 entry.m_key = reinterpret_cast<key_type> (1);
578 }
579 template <typename T>
580 static inline void mark_empty (T &entry)
581 {
582 entry.m_key = NULL;
583 }
584 template <typename T>
585 static inline bool is_deleted (const T &entry)
586 {
587 return entry.m_key == reinterpret_cast<key_type> (1);
588 }
589 template <typename T>
590 static inline bool is_empty (const T &entry)
591 {
592 return entry.m_key == NULL;
593 }
594 static const bool empty_zero_p = false;
595 };
596
597 /* Data about a particular function within an exploded_graph. */
598
599 struct per_function_data
600 {
601 per_function_data () {}
602
603 void add_call_summary (exploded_node *node)
604 {
605 m_summaries.safe_push (node);
606 }
607
608 auto_vec<exploded_node *> m_summaries;
609 };
610
611
612 /* The strongly connected components of a supergraph.
613 In particular, this allows us to compute a partial ordering
614 of supernodes. */
615
616 class strongly_connected_components
617 {
618 public:
619 strongly_connected_components (const supergraph &sg, logger *logger);
620
621 int get_scc_id (int node_index) const
622 {
623 return m_per_node[node_index].m_lowlink;
624 }
625
626 void dump () const;
627
628 private:
629 struct per_node_data
630 {
631 per_node_data ()
632 : m_index (-1), m_lowlink (-1), m_on_stack (false)
633 {}
634
635 int m_index;
636 int m_lowlink;
637 bool m_on_stack;
638 };
639
640 void strong_connect (unsigned index);
641
642 const supergraph &m_sg;
643 auto_vec<unsigned> m_stack;
644 auto_vec<per_node_data> m_per_node;
645 };
646
647 /* The worklist of exploded_node instances that have been added to
648 an exploded_graph, but that haven't yet been processed to find
649 their successors (or warnings).
650
651 The enodes are stored in a priority queue, ordered by a topological
652 sort of the SCCs in the supergraph, so that enodes for the same
653 program_point should appear at the front of the queue together.
654 This allows for state-merging at CFG join-points, so that
655 sufficiently-similar enodes can be merged into one. */
656
657 class worklist
658 {
659 public:
660 worklist (const exploded_graph &eg, const analysis_plan &plan);
661 unsigned length () const;
662 exploded_node *take_next ();
663 exploded_node *peek_next ();
664 void add_node (exploded_node *enode);
665
666 private:
667 class key_t
668 {
669 public:
670 key_t (const worklist &w, exploded_node *enode)
671 : m_worklist (w), m_enode (enode)
672 {}
673
674 bool operator< (const key_t &other) const
675 {
676 return cmp (*this, other) < 0;
677 }
678
679 bool operator== (const key_t &other) const
680 {
681 return cmp (*this, other) == 0;
682 }
683
684 bool operator> (const key_t &other) const
685 {
686 return !(*this == other || *this < other);
687 }
688
689 private:
690 static int cmp (const key_t &ka, const key_t &kb);
691
692 int get_scc_id (const exploded_node *enode) const
693 {
694 const supernode *snode = enode->get_supernode ();
695 if (snode == NULL)
696 return 0;
697 return m_worklist.m_scc.get_scc_id (snode->m_index);
698 }
699
700 const worklist &m_worklist;
701 exploded_node *m_enode;
702 };
703
704 /* The order is important here: m_scc needs to stick around
705 until after m_queue has finished being cleaned up (the dtor
706 calls the ordering fns). */
707 const exploded_graph &m_eg;
708 strongly_connected_components m_scc;
709 const analysis_plan &m_plan;
710
711 /* Priority queue, backed by a fibonacci_heap. */
712 typedef fibonacci_heap<key_t, exploded_node> queue_t;
713 queue_t m_queue;
714 };
715
716 /* An exploded_graph is a directed graph of unique <point, state> pairs.
717 It also has a worklist of nodes that are waiting for their successors
718 to be added to the graph. */
719
720 class exploded_graph : public digraph<eg_traits>
721 {
722 public:
723 typedef hash_map <const call_string *, per_call_string_data *,
724 eg_call_string_hash_map_traits> call_string_data_map_t;
725
726 exploded_graph (const supergraph &sg, logger *logger,
727 const extrinsic_state &ext_state,
728 const state_purge_map *purge_map,
729 const analysis_plan &plan,
730 int verbosity);
731 ~exploded_graph ();
732
733 logger *get_logger () const { return m_logger.get_logger (); }
734
735 const supergraph &get_supergraph () const { return m_sg; }
736 const extrinsic_state &get_ext_state () const { return m_ext_state; }
737 const state_purge_map *get_purge_map () const { return m_purge_map; }
738 const analysis_plan &get_analysis_plan () const { return m_plan; }
739
740 exploded_node *get_origin () const { return m_origin; }
741
742 exploded_node *add_function_entry (function *fun);
743
744 void build_initial_worklist ();
745 void process_worklist ();
746 void process_node (exploded_node *node);
747
748 exploded_node *get_or_create_node (const program_point &point,
749 const program_state &state,
750 state_change *change);
751 exploded_edge *add_edge (exploded_node *src, exploded_node *dest,
752 const superedge *sedge,
753 const state_change &change,
754 exploded_edge::custom_info_t *custom = NULL);
755
756 per_program_point_data *
757 get_or_create_per_program_point_data (const program_point &);
758
759 per_call_string_data *
760 get_or_create_per_call_string_data (const call_string &);
761
762 per_function_data *
763 get_or_create_per_function_data (function *);
764 per_function_data *get_per_function_data (function *) const;
765
766 void save_diagnostic (const state_machine &sm,
767 const exploded_node *enode,
768 const supernode *node, const gimple *stmt,
769 stmt_finder *finder,
770 tree var, state_machine::state_t state,
771 pending_diagnostic *d);
772
773 diagnostic_manager &get_diagnostic_manager ()
774 {
775 return m_diagnostic_manager;
776 }
777 const diagnostic_manager &get_diagnostic_manager () const
778 {
779 return m_diagnostic_manager;
780 }
781
782 stats *get_global_stats () { return &m_global_stats; }
783 stats *get_or_create_function_stats (function *fn);
784 void log_stats () const;
785 void dump_stats (FILE *) const;
786 void dump_states_for_supernode (FILE *, const supernode *snode) const;
787 void dump_exploded_nodes () const;
788
789 const call_string_data_map_t *get_per_call_string_data () const
790 { return &m_per_call_string_data; }
791
792 private:
793 DISABLE_COPY_AND_ASSIGN (exploded_graph);
794
795 const supergraph &m_sg;
796
797 log_user m_logger;
798
799 /* Map from point/state to exploded node.
800 To avoid duplication we store point_and_state
801 *pointers* as keys, rather than point_and_state, using the
802 instance from within the exploded_node, with a custom hasher. */
803 typedef hash_map <const point_and_state *, exploded_node *,
804 eg_hash_map_traits> map_t;
805 map_t m_point_and_state_to_node;
806
807 /* Map from program_point to per-program_point data. */
808 typedef hash_map <const program_point *, per_program_point_data *,
809 eg_point_hash_map_traits> point_map_t;
810 point_map_t m_per_point_data;
811
812 worklist m_worklist;
813
814 exploded_node *m_origin;
815
816 const extrinsic_state &m_ext_state;
817
818 const state_purge_map *const m_purge_map;
819
820 const analysis_plan &m_plan;
821
822 typedef hash_map<function *, per_function_data *> per_function_data_t;
823 per_function_data_t m_per_function_data;
824
825 diagnostic_manager m_diagnostic_manager;
826
827 /* Stats. */
828 stats m_global_stats;
829 typedef ordered_hash_map<function *, stats *> function_stat_map_t;
830 function_stat_map_t m_per_function_stats;
831 stats m_functionless_stats;
832
833 call_string_data_map_t m_per_call_string_data;
834
835 auto_vec<int> m_PK_AFTER_SUPERNODE_per_snode;
836 };
837
838 /* A path within an exploded_graph: a sequence of edges. */
839
840 class exploded_path
841 {
842 public:
843 exploded_path () : m_edges () {}
844 exploded_path (const exploded_path &other);
845 exploded_path & operator= (const exploded_path &other);
846
847 unsigned length () const { return m_edges.length (); }
848
849 bool find_stmt_backwards (const gimple *search_stmt,
850 int *out_idx) const;
851
852 exploded_node *get_final_enode () const;
853
854 void dump_to_pp (pretty_printer *pp) const;
855 void dump (FILE *fp) const;
856 void dump () const;
857
858 bool feasible_p (logger *logger) const;
859
860 auto_vec<const exploded_edge *> m_edges;
861 };
862
863 /* Finding the shortest exploded_path within an exploded_graph. */
864
865 typedef shortest_paths<eg_traits, exploded_path> shortest_exploded_paths;
866
867 /* Abstract base class for use when passing NULL as the stmt for
868 a possible warning, allowing the choice of stmt to be deferred
869 until after we have an emission path (and know we're emitting a
870 warning). */
871
872 class stmt_finder
873 {
874 public:
875 virtual ~stmt_finder () {}
876 virtual stmt_finder *clone () const = 0;
877 virtual const gimple *find_stmt (const exploded_path &epath) = 0;
878 };
879
880 // TODO: split the above up?
881
882 } // namespace ana
883
884 #endif /* GCC_ANALYZER_EXPLODED_GRAPH_H */