LCOV - code coverage report
Current view: top level - gcc/text-art - dump.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 63.2 % 19 12
Test Date: 2026-02-28 14:20:25 Functions: 16.7 % 12 2
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Templates for dumping objects.
       2              :    Copyright (C) 2024-2026 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_TEXT_ART_DUMP_H
      22              : #define GCC_TEXT_ART_DUMP_H
      23              : 
      24              : #include "tree-diagnostic.h"
      25              : #include "text-art/canvas.h"
      26              : #include "text-art/widget.h"
      27              : #include "text-art/dump-widget-info.h"
      28              : 
      29              : /* A family of templates for dumping objects via the text_art::widget
      30              :    system.
      31              :    Any type T that has a make_dump_widget member function ought to be
      32              :    dumpable via these functions.  */
      33              : 
      34              : namespace text_art {
      35              : 
      36              : /* Dump OBJ to PP, using OBJ's make_dump_widget member function.  */
      37              : 
      38              : template <typename T>
      39           31 : void dump_to_pp (const T &obj, text_art::theme *theme, pretty_printer *pp)
      40              : {
      41           31 :   if (!theme)
      42           27 :     return;
      43              : 
      44            4 :   style_manager sm;
      45            4 :   style tree_style (get_style_from_color_cap_name ("note"));
      46              : 
      47            4 :   style::id_t tree_style_id (sm.get_or_create_id (tree_style));
      48              : 
      49            4 :   dump_widget_info dwi (sm, *theme, tree_style_id);
      50            8 :   if (std::unique_ptr<widget> w = obj.make_dump_widget (dwi))
      51              :     {
      52            4 :       text_art::canvas c (w->to_canvas (dwi.m_sm));
      53            4 :       c.print_to_pp (pp);
      54            4 :     }
      55            4 : }
      56              : 
      57              : /* Dump OBJ to OUTF, using OBJ's make_dump_widget member function.  */
      58              : 
      59              : template <typename T>
      60            0 : void dump_to_file (const T &obj, FILE *outf)
      61              : {
      62            0 :   tree_dump_pretty_printer pp (outf);
      63            0 :   text_art::theme *theme = global_dc->get_diagram_theme ();
      64            0 :   dump_to_pp (obj, theme, &pp);
      65            0 : }
      66              : 
      67              : /* Dump OBJ to stderr, using OBJ's make_dump_widget member function.  */
      68              : 
      69              : template <typename T>
      70            0 : void dump (const T &obj)
      71              : {
      72            0 :   dump_to_file (obj, stderr);
      73              : }
      74              : 
      75              : } // namespace text_art
      76              : 
      77              : #endif /* GCC_TEXT_ART_DUMP_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.