LCOV - code coverage report
Current view: top level - gcc/rust - rust-linemap.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 30.8 % 26 8
Test Date: 2026-02-28 14:20:25 Functions: 50.0 % 4 2
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 2020-2026 Free Software Foundation, Inc.
       2              : 
       3              : // This file is part of GCC.
       4              : 
       5              : // GCC is free software; you can redistribute it and/or modify it under
       6              : // the terms of the GNU General Public License as published by the Free
       7              : // Software Foundation; either version 3, or (at your option) any later
       8              : // version.
       9              : 
      10              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13              : // for more details.
      14              : 
      15              : // You should have received a copy of the GNU General Public License
      16              : // along with GCC; see the file COPYING3.  If not see
      17              : // <http://www.gnu.org/licenses/>.
      18              : 
      19              : // rust-linemap.cc -- GCC implementation of Linemap.
      20              : 
      21              : #include "rust-linemap.h"
      22              : 
      23              : Linemap *Linemap::instance_ = NULL;
      24              : 
      25              : // Start getting locations from a new file.
      26              : 
      27              : void
      28         4690 : Linemap::start_file (const char *file_name, unsigned line_begin)
      29              : {
      30         4690 :   if (this->in_file_)
      31           55 :     linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
      32         4690 :   linemap_add (line_table, LC_ENTER, 0, file_name, line_begin);
      33         4690 :   this->in_file_ = true;
      34         4690 : }
      35              : 
      36              : // Stringify a location
      37              : 
      38              : std::string
      39            0 : Linemap::location_to_string (location_t location)
      40              : {
      41            0 :   const line_map_ordinary *lmo;
      42            0 :   location_t resolved_location;
      43              : 
      44              :   // Screen out unknown and predeclared locations; produce output
      45              :   // only for simple file:line locations.
      46            0 :   resolved_location = linemap_resolve_location (line_table, location,
      47              :                                                 LRK_SPELLING_LOCATION, &lmo);
      48            0 :   if (lmo == NULL || resolved_location < RESERVED_LOCATION_COUNT)
      49            0 :     return "";
      50            0 :   const char *path = LINEMAP_FILE (lmo);
      51            0 :   if (!path)
      52            0 :     return "";
      53              : 
      54              :   // Strip the source file down to the base file, to reduce clutter.
      55            0 :   std::stringstream ss;
      56            0 :   ss << lbasename (path) << ":" << SOURCE_LINE (lmo, location) << ":"
      57            0 :      << SOURCE_COLUMN (lmo, location);
      58            0 :   return ss.str ();
      59            0 : }
      60              : 
      61              : // Stop getting locations.
      62              : 
      63              : void
      64            0 : Linemap::stop ()
      65              : {
      66            0 :   linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
      67            0 :   this->in_file_ = false;
      68            0 : }
      69              : 
      70              : // Return the Linemap to use for the gcc backend.
      71              : 
      72              : Linemap *
      73         4635 : rust_get_linemap ()
      74              : {
      75         4635 :   return new Linemap;
      76              : }
        

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.