LCOV - code coverage report
Current view: top level - gcc/analyzer - checker-path.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 95.5 % 44 42
Test Date: 2025-07-05 13:26:22 Functions: 90.0 % 10 9
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Subclass of diagnostic_path for analyzer diagnostics.
       2                 :             :    Copyright (C) 2019-2025 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_CHECKER_PATH_H
      22                 :             : #define GCC_ANALYZER_CHECKER_PATH_H
      23                 :             : 
      24                 :             : #include "analyzer/checker-event.h"
      25                 :             : #include "simple-diagnostic-path.h"
      26                 :             : 
      27                 :             : namespace ana {
      28                 :             : 
      29                 :             : /* Subclass of diagnostic_path for analyzer diagnostics.  */
      30                 :             : 
      31                 :             : class checker_path : public diagnostic_path
      32                 :             : {
      33                 :             : public:
      34                 :        3983 :   checker_path (const logical_location_manager &logical_loc_mgr,
      35                 :             :                 const extrinsic_state &ext_state,
      36                 :             :                 logger *logger)
      37                 :        3983 :   : diagnostic_path (logical_loc_mgr),
      38                 :        3983 :     m_ext_state (ext_state),
      39                 :        3983 :     m_thread ("main"),
      40                 :        3983 :     m_logger (logger)
      41                 :        3983 :   {}
      42                 :             : 
      43                 :             :   /* Implementation of diagnostic_path vfuncs.  */
      44                 :             : 
      45                 :      162019 :   unsigned num_events () const final override
      46                 :             :   {
      47                 :      303611 :     return m_events.length ();
      48                 :             :   }
      49                 :             : 
      50                 :       37222 :   const diagnostic_event & get_event (int idx) const final override
      51                 :             :   {
      52                 :       37222 :     return *m_events[idx];
      53                 :             :   }
      54                 :           0 :   unsigned num_threads () const final override
      55                 :             :   {
      56                 :           0 :     return 1;
      57                 :             :   }
      58                 :             :   const diagnostic_thread &
      59                 :         281 :   get_thread (diagnostic_thread_id_t) const final override
      60                 :             :   {
      61                 :         281 :     return m_thread;
      62                 :             :   }
      63                 :             : 
      64                 :          28 :   const extrinsic_state &get_ext_state () const { return m_ext_state; }
      65                 :             : 
      66                 :           6 :   checker_event *get_checker_event (int idx)
      67                 :             :   {
      68                 :      135111 :     return m_events[idx];
      69                 :             :   }
      70                 :             : 
      71                 :             :   bool
      72                 :             :   same_function_p (int event_idx_a,
      73                 :             :                    int event_idx_b) const final override;
      74                 :             : 
      75                 :             :   void dump (pretty_printer *pp) const;
      76                 :             :   void debug () const;
      77                 :             : 
      78                 :          79 :   logger *get_logger () const { return m_logger; }
      79                 :             :   void maybe_log (logger *logger, const char *desc) const;
      80                 :             : 
      81                 :             :   void add_event (std::unique_ptr<checker_event> event);
      82                 :             : 
      83                 :       42127 :   void delete_event (int idx)
      84                 :             :   {
      85                 :       42127 :     checker_event *event = m_events[idx];
      86                 :       42127 :     m_events.ordered_remove (idx);
      87                 :       42127 :     delete event;
      88                 :       42127 :   }
      89                 :             : 
      90                 :          97 :   void delete_events (unsigned start_idx, unsigned len)
      91                 :             :   {
      92                 :         295 :     for (unsigned i = start_idx; i < start_idx + len; i++)
      93                 :         198 :       delete m_events[i];
      94                 :          97 :     m_events.block_remove (start_idx, len);
      95                 :          97 :   }
      96                 :             : 
      97                 :         182 :   void replace_event (unsigned idx, checker_event *new_event)
      98                 :             :   {
      99                 :         182 :     delete m_events[idx];
     100                 :         182 :     m_events[idx] = new_event;
     101                 :         182 :   }
     102                 :             : 
     103                 :             :   void add_region_creation_events (pending_diagnostic *pd,
     104                 :             :                                    const region *reg,
     105                 :             :                                    const region_model *model,
     106                 :             :                                    const event_loc_info &loc_info,
     107                 :             :                                    bool debug);
     108                 :             : 
     109                 :             :   /* After all event-pruning, a hook for notifying each event what
     110                 :             :      its ID will be.  The events are notified in order, allowing
     111                 :             :      for later events to refer to the IDs of earlier events in
     112                 :             :      their descriptions.  */
     113                 :        3983 :   void prepare_for_emission (pending_diagnostic *pd)
     114                 :             :   {
     115                 :        3983 :     checker_event *e;
     116                 :        3983 :     int i;
     117                 :       21144 :     FOR_EACH_VEC_ELT (m_events, i, e)
     118                 :       17161 :       e->prepare_for_emission (this, pd, diagnostic_event_id_t (i));
     119                 :        3983 :   }
     120                 :             : 
     121                 :             :   void fixup_locations (pending_diagnostic *pd);
     122                 :             : 
     123                 :          20 :   void record_setjmp_event (const exploded_node *enode,
     124                 :             :                             diagnostic_event_id_t setjmp_emission_id)
     125                 :             :   {
     126                 :          20 :     m_setjmp_event_ids.put (enode, setjmp_emission_id);
     127                 :             :   }
     128                 :             : 
     129                 :          15 :   bool get_setjmp_event (const exploded_node *enode,
     130                 :             :                          diagnostic_event_id_t *out_emission_id)
     131                 :             :   {
     132                 :          15 :     if (diagnostic_event_id_t *emission_id = m_setjmp_event_ids.get (enode))
     133                 :             :       {
     134                 :          15 :         *out_emission_id = *emission_id;
     135                 :          15 :         return true;
     136                 :             :       }
     137                 :             :     return false;
     138                 :             :   }
     139                 :             : 
     140                 :             :   bool cfg_edge_pair_at_p (unsigned idx) const;
     141                 :             : 
     142                 :             :   void inject_any_inlined_call_events (logger *logger);
     143                 :             : 
     144                 :             : private:
     145                 :             :   DISABLE_COPY_AND_ASSIGN(checker_path);
     146                 :             : 
     147                 :             :   const extrinsic_state &m_ext_state;
     148                 :             : 
     149                 :             :   simple_diagnostic_thread m_thread;
     150                 :             : 
     151                 :             :   /* The events that have occurred along this path.  */
     152                 :             :   auto_delete_vec<checker_event> m_events;
     153                 :             : 
     154                 :             :   /* During prepare_for_emission (and after), the setjmp_event for each
     155                 :             :      exploded_node *, so that rewind events can refer to them in their
     156                 :             :      descriptions.  */
     157                 :             :   hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
     158                 :             : 
     159                 :             :   logger *m_logger;
     160                 :             : };
     161                 :             : 
     162                 :             : } // namespace ana
     163                 :             : 
     164                 :             : #endif /* GCC_ANALYZER_CHECKER_PATH_H */
        

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