LCOV - code coverage report
Current view: top level - gcc/analyzer - complexity.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 19 19
Test Date: 2026-02-28 14:20:25 Functions: 100.0 % 4 4
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Measuring the complexity of svalues/regions.
       2              :    Copyright (C) 2020-2026 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              : #include "analyzer/common.h"
      22              : 
      23              : #include "options.h"
      24              : #include "cgraph.h"
      25              : #include "cfg.h"
      26              : #include "digraph.h"
      27              : 
      28              : #include "analyzer/analyzer-logging.h"
      29              : #include "analyzer/call-string.h"
      30              : #include "analyzer/program-point.h"
      31              : #include "analyzer/store.h"
      32              : #include "analyzer/complexity.h"
      33              : #include "analyzer/svalue.h"
      34              : #include "analyzer/region.h"
      35              : 
      36              : #if ENABLE_ANALYZER
      37              : 
      38              : namespace ana {
      39              : 
      40              : /* struct complexity.  */
      41              : 
      42              : /* Get complexity for a new node that references REG
      43              :    (the complexity of REG, plus one for the new node).  */
      44              : 
      45       277889 : complexity::complexity (const region *reg)
      46       277889 : : m_num_nodes (reg->get_complexity ().m_num_nodes + 1),
      47       277889 :   m_max_depth (reg->get_complexity ().m_max_depth + 1)
      48              : {
      49       277889 : }
      50              : 
      51              : /* Get complexity for a new node that references SVAL.
      52              :    (the complexity of SVAL, plus one for the new node).  */
      53              : 
      54        30177 : complexity::complexity (const svalue *sval)
      55        30177 : : m_num_nodes (sval->get_complexity ().m_num_nodes + 1),
      56        30177 :   m_max_depth (sval->get_complexity ().m_max_depth + 1)
      57              : {
      58        30177 : }
      59              : 
      60              : /* Get complexity for a new node that references nodes with complexity
      61              :    C1 and C2.  */
      62              : 
      63              : complexity
      64        45406 : complexity::from_pair (const complexity &c1, const complexity &c2)
      65              : {
      66        90812 :   return complexity (c1.m_num_nodes + c2.m_num_nodes + 1,
      67        45406 :                      MAX (c1.m_max_depth, c2.m_max_depth) + 1);
      68              : }
      69              : 
      70              : /* Get complexity for a new node that references the svalues in VEC.  */
      71              : 
      72              : complexity
      73          379 : complexity::from_vec_svalue (const vec<const svalue *> &vec)
      74              : {
      75          379 :   unsigned num_nodes = 0;
      76          379 :   unsigned max_depth = 0;
      77         1509 :   for (auto iter_sval : vec)
      78              :     {
      79          468 :       const complexity &iter_c = iter_sval->get_complexity ();
      80          468 :       num_nodes += iter_c.m_num_nodes;
      81          468 :       max_depth = MAX (max_depth, iter_c.m_max_depth);
      82              :     }
      83          379 :   return complexity (num_nodes + 1, max_depth + 1);
      84              : }
      85              : 
      86              : } // namespace ana
      87              : 
      88              : #endif /* #if ENABLE_ANALYZER */
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.