1/* Measuring the complexity of svalues/regions.
2 Copyright (C) 2020-2024 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_COMPLEXITY_H
22#define GCC_ANALYZER_COMPLEXITY_H
23
24namespace ana {
25
26/* A measurement of the complexity of an svalue or region, so that
27 we can impose bounds on the growth of these tree-like structures
28 and thus avoid infinite chains of analysis. */
29
30struct complexity
31{
32 complexity (unsigned num_nodes, unsigned max_depth)
33 : m_num_nodes (num_nodes), m_max_depth (max_depth)
34 {}
35
36 complexity (const region *reg);
37 complexity (const svalue *sval);
38 static complexity from_pair (const complexity &c1, const complexity &c);
39 static complexity from_vec_svalue (const vec<const svalue *> &vec);
40
41 /* The total number of svalues and regions in the tree of this
42 entity, including the entity itself. */
43 unsigned m_num_nodes;
44
45 /* The maximum depth of the tree of this entity, including the
46 entity itself. */
47 unsigned m_max_depth;
48};
49
50} // namespace ana
51
52#endif /* GCC_ANALYZER_COMPLEXITY_H */
53

source code of gcc/analyzer/complexity.h