GCC Middle and Back End API Reference
complexity.h
Go to the documentation of this file.
1/* Measuring the complexity of symbolic nodes.
2 Copyright (C) 2020-2026 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 a symbolic node, so that
27 we can impose bounds on the growth of these tree-like structures
28 and thus avoid infinite chains of analysis. */
29
31{
32 complexity (unsigned num_nodes, unsigned max_depth)
33 : m_num_nodes (num_nodes), m_max_depth (max_depth)
34 {}
35
37 complexity (const region *reg);
38 complexity (const svalue *sval);
39
40 static complexity
41 from_pair (const complexity &c1, const complexity &c);
42
43 static complexity
45
46 static complexity
47 from_child_complexities (const complexity &child_complexities);
48
49 bool
50 operator== (const complexity &other) const
51 {
52 return (m_num_nodes == other.m_num_nodes
53 && m_max_depth == other.m_max_depth);
54 }
55
57 operator+ (const complexity &other) const;
58
60 operator+= (const complexity &other);
61
62 /* The total number of nodes in the tree of this
63 entity, including the entity itself. */
64 unsigned m_num_nodes;
65
66 /* The maximum depth of the tree of this entity, including the
67 entity itself. */
68 unsigned m_max_depth;
69};
70
71} // namespace ana
72
73#endif /* GCC_ANALYZER_COMPLEXITY_H */
Definition region.h:130
Definition svalue.h:82
Definition symbolic-nodes.h:116
Definition access-diagram.h:30
@ other
Definition common.h:535
Definition complexity.h:31
static complexity from_vec_svalue(const vec< const svalue * > &vec)
complexity(const region *reg)
unsigned m_num_nodes
Definition complexity.h:64
complexity operator+(const complexity &other) const
unsigned m_max_depth
Definition complexity.h:68
static complexity from_child_complexities(const complexity &child_complexities)
complexity & operator+=(const complexity &other)
complexity(const symbolic::node &n)
complexity(unsigned num_nodes, unsigned max_depth)
Definition complexity.h:32
bool operator==(const complexity &other) const
Definition complexity.h:50
complexity(const svalue *sval)
static complexity from_pair(const complexity &c1, const complexity &c)
Definition vec.h:450