analyzer: implement region_model::get_representative_path_var for labels
[gcc.git] / gcc / analyzer / call-string.h
1 /* Call stacks at program points.
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_CALL_STRING_H
22 #define GCC_ANALYZER_CALL_STRING_H
23
24 namespace ana {
25
26 class supergraph;
27 class call_superedge;
28 class return_superedge;
29
30 /* A string of return_superedge pointers, representing a call stack
31 at a program point.
32
33 This is used to ensure that we generate interprocedurally valid paths
34 i.e. that we return to the same callsite that called us.
35
36 The class actually stores the return edges, rather than the call edges,
37 since that's what we need to compare against. */
38
39 class call_string
40 {
41 public:
42 call_string () : m_return_edges () {}
43 call_string (const call_string &other);
44 call_string& operator= (const call_string &other);
45
46 bool operator== (const call_string &other) const;
47
48 void print (pretty_printer *pp) const;
49
50 json::value *to_json () const;
51
52 hashval_t hash () const;
53
54 bool empty_p () const { return m_return_edges.is_empty (); }
55
56 void push_call (const supergraph &sg,
57 const call_superedge *sedge);
58 const return_superedge *pop () { return m_return_edges.pop (); }
59
60 int calc_recursion_depth () const;
61
62 static int cmp (const call_string &a,
63 const call_string &b);
64
65 unsigned length () const { return m_return_edges.length (); }
66 const return_superedge *operator[] (unsigned idx) const
67 {
68 return m_return_edges[idx];
69 }
70
71 void validate () const;
72
73 private:
74 auto_vec<const return_superedge *> m_return_edges;
75 };
76
77 } // namespace ana
78
79 #endif /* GCC_ANALYZER_CALL_STRING_H */