LCOV - code coverage report
Current view: top level - gcc/diagnostics - selftest-context.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 13 13
Test Date: 2025-09-20 13:40:47 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Selftest support for diagnostics.
       2                 :             :    Copyright (C) 2016-2025 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #ifndef GCC_DIAGNOSTICS_SELFTEST_CONTEXT_H
      21                 :             : #define GCC_DIAGNOSTICS_SELFTEST_CONTEXT_H
      22                 :             : 
      23                 :             : /* The selftest code should entirely disappear in a production
      24                 :             :    configuration, hence we guard all of it with #if CHECKING_P.  */
      25                 :             : 
      26                 :             : #if CHECKING_P
      27                 :             : 
      28                 :             : namespace diagnostics {
      29                 :             : namespace selftest {
      30                 :             : 
      31                 :             : /* Convenience subclass of diagnostics::context for testing
      32                 :             :    the diagnostic subsystem.  */
      33                 :             : 
      34                 :             : class test_context : public context
      35                 :             : {
      36                 :             :  public:
      37                 :             :   test_context ();
      38                 :             :   ~test_context ();
      39                 :             : 
      40                 :             :   /* Implementation of diagnostics::start_span_fn, hiding the
      41                 :             :      real filename (to avoid printing the names of tempfiles).  */
      42                 :             :   static void
      43                 :             :   start_span_cb (const location_print_policy &,
      44                 :             :                  to_text &sink,
      45                 :             :                  expanded_location exploc);
      46                 :             : 
      47                 :             :   /* Report a diagnostic to this context.  For a selftest, this
      48                 :             :      should only be called on a context that uses a non-standard formatter
      49                 :             :      that e.g. gathers the results in memory, rather than emits to stderr.  */
      50                 :             :   bool
      51                 :             :   report (enum kind kind,
      52                 :             :           rich_location &richloc,
      53                 :             :           const metadata *,
      54                 :             :           option_id opt_id,
      55                 :             :           const char * fmt, ...) ATTRIBUTE_GCC_DIAG(6,7);
      56                 :             : 
      57                 :             :   const char *test_show_locus (rich_location &richloc);
      58                 :             : 
      59                 :             :   /* Setters for the context's source_printing_options
      60                 :             :      for use in selftests.  */
      61                 :          64 :   void colorize_source (bool val)
      62                 :             :   {
      63                 :          64 :     get_source_printing_options ().colorize_source_p = val;
      64                 :             :   }
      65                 :          64 :   void show_labels (bool val)
      66                 :             :   {
      67                 :          64 :     get_source_printing_options ().show_labels_p = val;
      68                 :             :   }
      69                 :        3700 :   void show_line_numbers (bool val)
      70                 :             :   {
      71                 :        3700 :     get_source_printing_options ().show_line_numbers_p = val;
      72                 :             :   }
      73                 :         320 :   void show_ruler (bool val)
      74                 :             :   {
      75                 :         320 :     get_source_printing_options ().show_ruler_p = val;
      76                 :             :   }
      77                 :        1252 :   void show_event_links (bool val)
      78                 :             :   {
      79                 :        1252 :     get_source_printing_options ().show_event_links_p = val;
      80                 :             :   }
      81                 :         384 :   void set_caret_char (unsigned idx, char ch)
      82                 :             :   {
      83                 :         384 :     gcc_assert (idx < rich_location::STATICALLY_ALLOCATED_RANGES);
      84                 :         384 :     get_source_printing_options ().caret_chars[idx] = ch;
      85                 :             :   }
      86                 :             : };
      87                 :             : 
      88                 :             : } // namespace selftest
      89                 :             : } // namespace diagnostics
      90                 :             : 
      91                 :             : #endif /* #if CHECKING_P */
      92                 :             : 
      93                 :             : #endif /* GCC_DIAGNOSTICS_SELFTEST_CONTEXT_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.