LCOV - code coverage report
Current view: top level - gcc - diagnostic-event-id.h (source / functions) Hit Total Coverage
Test: gcc.info Lines: 6 6 100.0 %
Date: 2020-05-30 12:51:24 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* A class for referring to events within a diagnostic_path.
       2                 :            :    Copyright (C) 2019-2020 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 under
       8                 :            : the terms of the GNU General Public License as published by the Free
       9                 :            : Software Foundation; either version 3, or (at your option) any later
      10                 :            : version.
      11                 :            : 
      12                 :            : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13                 :            : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14                 :            : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15                 :            : 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_DIAGNOSTIC_EVENT_ID_H
      22                 :            : #define GCC_DIAGNOSTIC_EVENT_ID_H
      23                 :            : 
      24                 :            : /* A class for referring to events within a diagnostic_path.
      25                 :            : 
      26                 :            :    They are stored as 0-based offsets into the events, but
      27                 :            :    printed (e.g. via %@) as 1-based numbers.
      28                 :            : 
      29                 :            :    For example, a 3-event path has event offsets 0, 1, and 2,
      30                 :            :    which would be shown to the user as "(1)", "(2)" and "(3)".
      31                 :            : 
      32                 :            :    This has its own header so that pretty-print.c can use this
      33                 :            :    to implement "%@" without bringing in all of diagnostic_path
      34                 :            :    (which e.g. refers to "tree").  */
      35                 :            : 
      36                 :            : class diagnostic_event_id_t
      37                 :            : {
      38                 :            :  public:
      39                 :       6076 :   diagnostic_event_id_t () : m_index (UNKNOWN_EVENT_IDX) {}
      40                 :       3044 :   diagnostic_event_id_t (int zero_based_idx) : m_index (zero_based_idx) {}
      41                 :            : 
      42                 :       2463 :   bool known_p () const { return m_index != UNKNOWN_EVENT_IDX; }
      43                 :            : 
      44                 :       1976 :   int one_based () const
      45                 :            :   {
      46                 :       1976 :     gcc_assert (known_p ());
      47                 :       1976 :     return m_index + 1;
      48                 :            :   }
      49                 :            : 
      50                 :            :  private:
      51                 :            :   static const int UNKNOWN_EVENT_IDX = -1;
      52                 :            :   int m_index; // zero-based
      53                 :            : };
      54                 :            : 
      55                 :            : /* A pointer to a diagnostic_event_id_t, for use with the "%@" format
      56                 :            :    code, which will print a 1-based representation for it, with suitable
      57                 :            :    colorization, e.g. "(1)".
      58                 :            :    The %@ format code requires that known_p be true for the event ID. */
      59                 :            : typedef diagnostic_event_id_t *diagnostic_event_id_ptr;
      60                 :            : 
      61                 :            : #endif /* ! GCC_DIAGNOSTIC_EVENT_ID_H */

Generated by: LCOV version 1.0

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 --enable-host-shared. GCC test suite is run with the built compiler.