diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-10-28 20:09:04 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-10-28 20:09:04 -0400 |
commit | e9751143e237b507a81234a573a200ea45e7111a (patch) | |
tree | 67c5ae2a3112bd02c8b4aa98f8287251481a3e3a /gcc/analyzer/complexity.h | |
parent | 0a36f5f21cd9dcaaf99e78d2ec995d6cb2918274 (diff) | |
download | gcc-e9751143e237b507a81234a573a200ea45e7111a.zip gcc-e9751143e237b507a81234a573a200ea45e7111a.tar.gz gcc-e9751143e237b507a81234a573a200ea45e7111a.tar.bz2 |
analyzer: move svalue and region decls to their own header files
gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add analyzer/complexity.o.
gcc/analyzer/ChangeLog:
* analyzer.h (class state_machine): New forward decl.
(class logger): Likewise.
(class visitor): Likewise.
* complexity.cc: New file, taken from svalue.cc.
* complexity.h: New file, taken from region-model.h.
* region-model.h: Include "analyzer/svalue.h" and
"analyzer/region.h". Move struct complexity to complexity.h.
Move svalue, its subclasses and supporting decls to svalue.h.
Move region, its subclasses and supporting decls to region.h.
* region.cc: Include "analyzer/region.h".
(symbolic_region::symbolic_region): Move here from region-model.h.
* region.h: New file, based on material from region-model.h.
* svalue.cc: Include "analyzer/svalue.h".
(complexity::complexity): Move to complexity.cc.
(complexity::from_pair): Likewise.
* svalue.h: New file, based on material from region-model.h.
Diffstat (limited to 'gcc/analyzer/complexity.h')
-rw-r--r-- | gcc/analyzer/complexity.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gcc/analyzer/complexity.h b/gcc/analyzer/complexity.h new file mode 100644 index 0000000..e15967f --- /dev/null +++ b/gcc/analyzer/complexity.h @@ -0,0 +1,51 @@ +/* Measuring the complexity of svalues/regions. + Copyright (C) 2020 Free Software Foundation, Inc. + Contributed by David Malcolm <dmalcolm@redhat.com>. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef GCC_ANALYZER_COMPLEXITY_H +#define GCC_ANALYZER_COMPLEXITY_H + +namespace ana { + +/* A measurement of the complexity of an svalue or region, so that + we can impose bounds on the growth of these tree-like structures + and thus avoid infinite chains of analysis. */ + +struct complexity +{ + complexity (unsigned num_nodes, unsigned max_depth) + : m_num_nodes (num_nodes), m_max_depth (max_depth) + {} + + complexity (const region *reg); + complexity (const svalue *sval); + static complexity from_pair (const complexity &c1, const complexity &c); + + /* The total number of svalues and regions in the tree of this + entity, including the entity itself. */ + unsigned m_num_nodes; + + /* The maximum depth of the tree of this entity, including the + entity itself. */ + unsigned m_max_depth; +}; + +} // namespace ana + +#endif /* GCC_ANALYZER_COMPLEXITY_H */ |