LCOV - code coverage report
Current view: top level - gcc/analyzer - checker-path.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 95.2 % 42 40
Test Date: 2024-11-30 13:30:02 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-2024 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                 :        3849 :   checker_path (logger *logger)
      35                 :        3849 :   : diagnostic_path (),
      36                 :        3849 :     m_thread ("main"),
      37                 :        3849 :     m_logger (logger)
      38                 :        3849 :   {}
      39                 :             : 
      40                 :             :   /* Implementation of diagnostic_path vfuncs.  */
      41                 :             : 
      42                 :      139948 :   unsigned num_events () const final override
      43                 :             :   {
      44                 :      260178 :     return m_events.length ();
      45                 :             :   }
      46                 :             : 
      47                 :       35931 :   const diagnostic_event & get_event (int idx) const final override
      48                 :             :   {
      49                 :       35931 :     return *m_events[idx];
      50                 :             :   }
      51                 :           0 :   unsigned num_threads () const final override
      52                 :             :   {
      53                 :           0 :     return 1;
      54                 :             :   }
      55                 :             :   const diagnostic_thread &
      56                 :         253 :   get_thread (diagnostic_thread_id_t) const final override
      57                 :             :   {
      58                 :         253 :     return m_thread;
      59                 :             :   }
      60                 :             : 
      61                 :      117428 :   checker_event *get_checker_event (int idx)
      62                 :             :   {
      63                 :      117428 :     return m_events[idx];
      64                 :             :   }
      65                 :             : 
      66                 :             :   bool
      67                 :             :   same_function_p (int event_idx_a,
      68                 :             :                    int event_idx_b) const final override;
      69                 :             : 
      70                 :             :   void dump (pretty_printer *pp) const;
      71                 :             :   void debug () const;
      72                 :             : 
      73                 :          79 :   logger *get_logger () const { return m_logger; }
      74                 :             :   void maybe_log (logger *logger, const char *desc) const;
      75                 :             : 
      76                 :             :   void add_event (std::unique_ptr<checker_event> event);
      77                 :             : 
      78                 :       39989 :   void delete_event (int idx)
      79                 :             :   {
      80                 :       39989 :     checker_event *event = m_events[idx];
      81                 :       39989 :     m_events.ordered_remove (idx);
      82                 :       39989 :     delete event;
      83                 :       39989 :   }
      84                 :             : 
      85                 :          67 :   void delete_events (unsigned start_idx, unsigned len)
      86                 :             :   {
      87                 :         207 :     for (unsigned i = start_idx; i < start_idx + len; i++)
      88                 :         140 :       delete m_events[i];
      89                 :          67 :     m_events.block_remove (start_idx, len);
      90                 :          67 :   }
      91                 :             : 
      92                 :         134 :   void replace_event (unsigned idx, checker_event *new_event)
      93                 :             :   {
      94                 :         134 :     delete m_events[idx];
      95                 :         134 :     m_events[idx] = new_event;
      96                 :         134 :   }
      97                 :             : 
      98                 :             :   void add_region_creation_events (pending_diagnostic *pd,
      99                 :             :                                    const region *reg,
     100                 :             :                                    const region_model *model,
     101                 :             :                                    const event_loc_info &loc_info,
     102                 :             :                                    bool debug);
     103                 :             : 
     104                 :             :   /* After all event-pruning, a hook for notifying each event what
     105                 :             :      its ID will be.  The events are notified in order, allowing
     106                 :             :      for later events to refer to the IDs of earlier events in
     107                 :             :      their descriptions.  */
     108                 :        3849 :   void prepare_for_emission (pending_diagnostic *pd)
     109                 :             :   {
     110                 :        3849 :     checker_event *e;
     111                 :        3849 :     int i;
     112                 :       20334 :     FOR_EACH_VEC_ELT (m_events, i, e)
     113                 :       16485 :       e->prepare_for_emission (this, pd, diagnostic_event_id_t (i));
     114                 :        3849 :   }
     115                 :             : 
     116                 :             :   void fixup_locations (pending_diagnostic *pd);
     117                 :             : 
     118                 :          20 :   void record_setjmp_event (const exploded_node *enode,
     119                 :             :                             diagnostic_event_id_t setjmp_emission_id)
     120                 :             :   {
     121                 :          20 :     m_setjmp_event_ids.put (enode, setjmp_emission_id);
     122                 :             :   }
     123                 :             : 
     124                 :          15 :   bool get_setjmp_event (const exploded_node *enode,
     125                 :             :                          diagnostic_event_id_t *out_emission_id)
     126                 :             :   {
     127                 :          15 :     if (diagnostic_event_id_t *emission_id = m_setjmp_event_ids.get (enode))
     128                 :             :       {
     129                 :          15 :         *out_emission_id = *emission_id;
     130                 :          15 :         return true;
     131                 :             :       }
     132                 :             :     return false;
     133                 :             :   }
     134                 :             : 
     135                 :             :   bool cfg_edge_pair_at_p (unsigned idx) const;
     136                 :             : 
     137                 :             :   void inject_any_inlined_call_events (logger *logger);
     138                 :             : 
     139                 :             : private:
     140                 :             :   DISABLE_COPY_AND_ASSIGN(checker_path);
     141                 :             : 
     142                 :             :   simple_diagnostic_thread m_thread;
     143                 :             : 
     144                 :             :   /* The events that have occurred along this path.  */
     145                 :             :   auto_delete_vec<checker_event> m_events;
     146                 :             : 
     147                 :             :   /* During prepare_for_emission (and after), the setjmp_event for each
     148                 :             :      exploded_node *, so that rewind events can refer to them in their
     149                 :             :      descriptions.  */
     150                 :             :   hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
     151                 :             : 
     152                 :             :   logger *m_logger;
     153                 :             : };
     154                 :             : 
     155                 :             : } // namespace ana
     156                 :             : 
     157                 :             : #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.