1 /* Call stacks at program points.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
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)
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.
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/>. */
21 #ifndef GCC_ANALYZER_CALL_STRING_H
22 #define GCC_ANALYZER_CALL_STRING_H
26 class return_superedge
;
28 /* A string of return_superedge pointers, representing a call stack
31 This is used to ensure that we generate interprocedurally valid paths
32 i.e. that we return to the same callsite that called us.
34 The class actually stores the return edges, rather than the call edges,
35 since that's what we need to compare against. */
40 call_string () : m_return_edges () {}
41 call_string (const call_string
&other
);
42 call_string
& operator= (const call_string
&other
);
44 bool operator== (const call_string
&other
) const;
46 void print (pretty_printer
*pp
) const;
48 hashval_t
hash () const;
50 bool empty_p () const { return m_return_edges
.is_empty (); }
52 void push_call (const supergraph
&sg
,
53 const call_superedge
*sedge
);
54 const return_superedge
*pop () { return m_return_edges
.pop (); }
56 int calc_recursion_depth () const;
58 static int cmp (const call_string
&a
,
59 const call_string
&b
);
61 unsigned length () const { return m_return_edges
.length (); }
62 const return_superedge
*operator[] (unsigned idx
) const
64 return m_return_edges
[idx
];
67 void validate () const;
70 static int cmp_1 (const call_string
&a
,
71 const call_string
&b
);
73 auto_vec
<const return_superedge
*> m_return_edges
;
76 #endif /* GCC_ANALYZER_CALL_STRING_H */