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: call_string()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 hashval_t hash () const; 51 empty_p()52 bool empty_p () const { return m_return_edges.is_empty (); } 53 54 void push_call (const supergraph &sg, 55 const call_superedge *sedge); pop()56 const return_superedge *pop () { return m_return_edges.pop (); } 57 58 int calc_recursion_depth () const; 59 60 static int cmp (const call_string &a, 61 const call_string &b); 62 length()63 unsigned length () const { return m_return_edges.length (); } 64 const return_superedge *operator[] (unsigned idx) const 65 { 66 return m_return_edges[idx]; 67 } 68 69 void validate () const; 70 71 private: 72 auto_vec<const return_superedge *> m_return_edges; 73 }; 74 75 } // namespace ana 76 77 #endif /* GCC_ANALYZER_CALL_STRING_H */ 78