LCOV - code coverage report
Current view: top level - gcc/analyzer - program-point.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 28 28
Test Date: 2026-11-14 16:39:50 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Classes for representing locations within the program.
       2              :    Copyright (C) 2019-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              : #ifndef GCC_ANALYZER_PROGRAM_POINT_H
      22              : #define GCC_ANALYZER_PROGRAM_POINT_H
      23              : 
      24              : #include "pretty-print.h"
      25              : #include "analyzer/call-string.h"
      26              : #include "analyzer/supergraph.h"
      27              : 
      28              : namespace ana {
      29              : 
      30              : class format
      31              : {
      32              : public:
      33         2218 :   format (bool newlines) : m_newlines (newlines) {}
      34              : 
      35         2218 :   void spacer (pretty_printer *pp) const
      36              :   {
      37         2218 :     if (m_newlines)
      38          659 :       pp_newline (pp);
      39              :     else
      40         1559 :       pp_space (pp);
      41         2218 :   }
      42              : 
      43              :   bool m_newlines;
      44              : };
      45              : 
      46              : /* A class for representing a location within the program, including
      47              :    interprocedural information.
      48              : 
      49              :    This represents a fine-grained location within the supergraph (or
      50              :    within one of its nodes), along with a call string giving the
      51              :    interprocedural context.  */
      52              : 
      53              : class program_point
      54              : {
      55              : public:
      56       703261 :   program_point (const supernode *snode,
      57              :                  const call_string &call_string)
      58       366106 :   : m_snode (snode),
      59        27357 :     m_call_string (&call_string)
      60              :   {
      61              :   }
      62              : 
      63              :   void print (pretty_printer *pp, const format &f) const;
      64              :   void dump () const;
      65              : 
      66              :   std::unique_ptr<text_art::tree_widget>
      67              :   make_dump_widget (symbolic::node_dump_state &nds) const;
      68              : 
      69              :   void print_source_line (pretty_printer *pp) const;
      70              : 
      71              :   std::unique_ptr<json::object> to_json () const;
      72              : 
      73              :   hashval_t hash () const;
      74      9638447 :   bool operator== (const program_point &other) const
      75              :   {
      76      9638447 :     return (m_snode == other.m_snode
      77      9638447 :             && m_call_string == other.m_call_string);
      78              :   }
      79              :   bool operator!= (const program_point &other) const
      80              :   {
      81              :     return !(*this == other);
      82              :   }
      83              : 
      84              :   /* Accessors.  */
      85              : 
      86      5518667 :   const supernode *get_supernode () const
      87              :   {
      88      5358052 :     return m_snode;
      89              :   }
      90      2539262 :   const call_string &get_call_string () const { return *m_call_string; }
      91              : 
      92      2017693 :   function *get_function () const
      93              :   {
      94      1939574 :     return m_snode ? m_snode->get_function () : nullptr;
      95              :   }
      96              :   function *get_function_at_depth (unsigned depth) const;
      97        43644 :   tree get_fndecl () const
      98              :   {
      99        77380 :     function *fn = get_function ();
     100        43765 :     return fn ? fn->decl : nullptr;
     101              :   }
     102       412296 :   location_t get_location () const
     103              :   {
     104       412171 :     return m_snode ? m_snode->get_location () : UNKNOWN_LOCATION;
     105              :   }
     106              : 
     107              :   /* Get the number of frames we expect at this program point.
     108              :      This will be one more than the length of the call_string
     109              :      (which stores the parent callsites), apart from the origin
     110              :      node, which doesn't have any frames.  */
     111       936139 :   int get_stack_depth () const
     112              :   {
     113       899218 :     if (m_snode == nullptr)
     114              :       // Origin
     115              :       return 0;
     116      1178518 :     return get_call_string ().length () + 1;
     117              :   }
     118              : 
     119       712722 :   bool state_merge_at_p () const
     120              :   {
     121       712722 :     if (m_snode)
     122       705638 :       return m_snode->m_state_merger_node;
     123              :     return false;
     124              :   }
     125              : 
     126              :   /* Factory functions for making various kinds of program_point.  */
     127              :   static program_point origin (const region_model_manager &mgr);
     128              :   static program_point from_function_entry (const region_model_manager &mgr,
     129              :                                             const supergraph &sg,
     130              :                                             const function &fun);
     131              : 
     132              :   void pop_from_call_stack ();
     133              :   void validate () const;
     134              : 
     135              :   static bool effectively_intraprocedural_p (const program_point &point_a,
     136              :                                              const program_point &point_b);
     137              : 
     138              :  private:
     139              :   const supernode *m_snode;
     140              :   const call_string *m_call_string;
     141              : };
     142              : 
     143              : } // namespace ana
     144              : 
     145              : #endif /* GCC_ANALYZER_PROGRAM_POINT_H */
        

Generated by: LCOV version 2.5.0-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.