LCOV - code coverage report
Current view: top level - gcc - pretty-print-markup.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 23 23
Test Date: 2026-02-28 14:20:25 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Copyright (C) 2024-2026 Free Software Foundation, Inc.
       2              :    Contributed by David Malcolm <dmalcolm@redhat.com>
       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_PRETTY_PRINT_MARKUP_H
      21              : #define GCC_PRETTY_PRINT_MARKUP_H
      22              : 
      23              : #include "diagnostics/color.h"
      24              : 
      25              : class pp_token_list;
      26              : 
      27              : namespace pp_markup {
      28              : 
      29              : class context
      30              : {
      31              : public:
      32        23023 :   context (pretty_printer &pp,
      33              :            bool &quoted,
      34              :            pp_token_list *formatted_token_list)
      35        23023 :   : m_pp (pp),
      36        23023 :     m_buf (*pp_buffer (&pp)),
      37        23023 :     m_quoted (quoted),
      38        23023 :     m_formatted_token_list (formatted_token_list)
      39              :   {
      40              :   }
      41              : 
      42              :   void begin_quote ();
      43              :   void end_quote ();
      44              : 
      45              :   void begin_highlight_color (const char *color_name);
      46              :   void end_highlight_color ();
      47              : 
      48              :   void begin_url (const char *url);
      49              :   void end_url ();
      50              : 
      51              :   void add_event_id (diagnostic_event_id_t event_id);
      52              : 
      53              :   void push_back_any_text ();
      54              : 
      55              :   pretty_printer &m_pp;
      56              :   output_buffer &m_buf;
      57              :   bool &m_quoted;
      58              :   pp_token_list *m_formatted_token_list;
      59              : };
      60              : 
      61              : /* Abstract base class for use in pp_format for handling "%e".
      62              :    This can add arbitrary content to the buffer being constructed, and
      63              :    isolates the non-typesafe part of the formatting call in one place.  */
      64              : 
      65              : class element
      66              : {
      67              : public:
      68        18869 :   virtual ~element () {}
      69              :   virtual void add_to_phase_2 (context &ctxt) = 0;
      70              : 
      71              : protected:
      72        18913 :   element () {}
      73              : 
      74              : private:
      75              :   DISABLE_COPY_AND_ASSIGN (element);
      76              : };
      77              : 
      78              : /* Concrete subclass: handle "%e" by printing a comma-separated list
      79              :    of quoted strings.  */
      80              : 
      81          180 : class comma_separated_quoted_strings : public element
      82              : {
      83              : public:
      84          188 :   comma_separated_quoted_strings (const auto_vec<const char *> &strings)
      85          184 :   : m_strings (strings)
      86              :   {
      87              :   }
      88              : 
      89              :   void add_to_phase_2 (context &ctxt) final override;
      90              : 
      91              : private:
      92              :   const auto_vec<const char *> &m_strings;
      93              : };
      94              : 
      95              : } // namespace pp_markup
      96              : 
      97           74 : class pp_element_quoted_string : public pp_element
      98              : {
      99              : public:
     100           74 :   pp_element_quoted_string (const char *text,
     101              :                             const char *highlight_color = nullptr)
     102           74 :   : m_text (text),
     103           74 :     m_highlight_color (highlight_color)
     104              :   {}
     105              : 
     106          144 :   void add_to_phase_2 (pp_markup::context &ctxt) final override
     107              :   {
     108          144 :     ctxt.begin_quote ();
     109          144 :     if (m_highlight_color)
     110          132 :       ctxt.begin_highlight_color (m_highlight_color);
     111          144 :     pp_string (&ctxt.m_pp, m_text);
     112          144 :     if (m_highlight_color)
     113          132 :       ctxt.end_highlight_color ();
     114          144 :     ctxt.end_quote ();
     115          144 :   }
     116              : 
     117              : private:
     118              :   const char *m_text;
     119              :   const char *m_highlight_color;
     120              : };
     121              : 
     122              : #endif /* GCC_PRETTY_PRINT_MARKUP_H */
        

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