LCOV - code coverage report
Current view: top level - gcc - input.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 12 12
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                 :             : /* Declarations for variables relating to reading the source file.
       2                 :             :    Used by parsers, lexical analyzers, and error message routines.
       3                 :             :    Copyright (C) 1993-2025 Free Software Foundation, Inc.
       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_INPUT_H
      22                 :             : #define GCC_INPUT_H
      23                 :             : 
      24                 :             : #include "line-map.h"
      25                 :             : 
      26                 :             : namespace diagnostics { class file_cache; }
      27                 :             : 
      28                 :             : extern GTY(()) class line_maps *line_table;
      29                 :             : extern GTY(()) class line_maps *saved_line_table;
      30                 :             : 
      31                 :             : /* A value which will never be used to represent a real location.  */
      32                 :             : #define UNKNOWN_LOCATION ((location_t) 0)
      33                 :             : 
      34                 :             : /* The location for declarations in "<built-in>" */
      35                 :             : #define BUILTINS_LOCATION ((location_t) 1)
      36                 :             : 
      37                 :             : /* Returns the translated string referring to the special location.  */
      38                 :             : const char *special_fname_builtin ();
      39                 :             : 
      40                 :             : /* line-map.cc reserves RESERVED_LOCATION_COUNT to the user.  Ensure
      41                 :             :    both UNKNOWN_LOCATION and BUILTINS_LOCATION fit into that.  */
      42                 :             : STATIC_ASSERT (BUILTINS_LOCATION < RESERVED_LOCATION_COUNT);
      43                 :             : 
      44                 :             : /* Hasher for 'location_t' values satisfying '!RESERVED_LOCATION_P', thus able
      45                 :             :    to use 'UNKNOWN_LOCATION'/'BUILTINS_LOCATION' as spare values for
      46                 :             :    'Empty'/'Deleted'.  */
      47                 :             : /* Per PR103157 "'gengtype': 'typedef' causing infinite-recursion code to be
      48                 :             :    generated", don't use
      49                 :             :        typedef int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION>
      50                 :             :          location_hash;
      51                 :             :    here.
      52                 :             : 
      53                 :             :    It works for a single-use case, but when using a 'struct'-based variant
      54                 :             :        struct location_hash
      55                 :             :          : int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION> {};
      56                 :             :    in more than one place, 'gengtype' generates duplicate functions (thus:
      57                 :             :    "error: redefinition of 'void gt_ggc_mx(location_hash&)'" etc.).
      58                 :             :    Attempting to mark that one up with GTY options, we run into a 'gengtype'
      59                 :             :    "parse error: expected '{', have '<'", which probably falls into category
      60                 :             :    "understanding of C++ is limited", as documented in 'gcc/doc/gty.texi'.
      61                 :             : 
      62                 :             :    Thus, use a plain ol' '#define':
      63                 :             : */
      64                 :             : #define location_hash int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION>
      65                 :             : 
      66                 :             : extern bool is_location_from_builtin_token (location_t);
      67                 :             : extern expanded_location expand_location (location_t);
      68                 :             : 
      69                 :             : class cpp_char_column_policy;
      70                 :             : 
      71                 :             : extern int
      72                 :             : location_compute_display_column (diagnostics::file_cache &fc,
      73                 :             :                                  expanded_location exploc,
      74                 :             :                                  const cpp_char_column_policy &policy);
      75                 :             : 
      76                 :             : extern char *
      77                 :             : get_source_text_between (diagnostics::file_cache &, location_t, location_t);
      78                 :             : 
      79                 :             : extern expanded_location
      80                 :             : expand_location_to_spelling_point (location_t,
      81                 :             :                                    enum location_aspect aspect
      82                 :             :                                      = location_aspect::caret);
      83                 :             : extern location_t expansion_point_location_if_in_system_header (location_t);
      84                 :             : extern location_t expansion_point_location (location_t);
      85                 :             : 
      86                 :             : extern location_t input_location;
      87                 :             : 
      88                 :             : extern location_t location_with_discriminator (location_t, int);
      89                 :             : extern bool has_discriminator (location_t);
      90                 :             : extern int get_discriminator_from_loc (location_t);
      91                 :             : 
      92                 :             : #define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
      93                 :             : #define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
      94                 :             : #define LOCATION_COLUMN(LOC)((expand_location (LOC)).column)
      95                 :             : #define LOCATION_LOCUS(LOC) \
      96                 :             :   ((IS_ADHOC_LOC (LOC)) ? get_location_from_adhoc_loc (line_table, LOC) \
      97                 :             :    : (LOC))
      98                 :             : #define LOCATION_BLOCK(LOC) \
      99                 :             :   ((tree) ((IS_ADHOC_LOC (LOC)) ? get_data_from_adhoc_loc (line_table, (LOC)) \
     100                 :             :    : NULL))
     101                 :             : #define RESERVED_LOCATION_P(LOC) \
     102                 :             :   (LOCATION_LOCUS (LOC) < RESERVED_LOCATION_COUNT)
     103                 :             : 
     104                 :             : /* Return a positive value if LOCATION is the locus of a token that is
     105                 :             :    located in a system header, O otherwise. It returns 1 if LOCATION
     106                 :             :    is the locus of a token that is located in a system header, and 2
     107                 :             :    if LOCATION is the locus of a token located in a C system header
     108                 :             :    that therefore needs to be extern "C" protected in C++.
     109                 :             : 
     110                 :             :    Note that this function returns 1 if LOCATION belongs to a token
     111                 :             :    that is part of a macro replacement-list defined in a system
     112                 :             :    header, but expanded in a non-system file.  */
     113                 :             : 
     114                 :             : inline int
     115                 :  1079268288 : in_system_header_at (location_t loc)
     116                 :             : {
     117                 :  1079268288 :   return linemap_location_in_system_header_p (line_table, loc);
     118                 :             : }
     119                 :             : 
     120                 :             : /* Return true if LOCATION is the locus of a token that
     121                 :             :    comes from a macro expansion, false otherwise.  */
     122                 :             : 
     123                 :             : inline bool
     124                 :     3968316 : from_macro_expansion_at (location_t loc)
     125                 :             : {
     126                 :     3968316 :   return linemap_location_from_macro_expansion_p (line_table, loc);
     127                 :             : }
     128                 :             : 
     129                 :             : /* Return true if LOCATION is the locus of a token that comes from
     130                 :             :    a macro definition, false otherwise.  This differs from from_macro_expansion_at
     131                 :             :    in its treatment of macro arguments, for which this returns false.  */
     132                 :             : 
     133                 :             : inline bool
     134                 :        1508 : from_macro_definition_at (location_t loc)
     135                 :             : {
     136                 :        1508 :   return linemap_location_from_macro_definition_p (line_table, loc);
     137                 :             : }
     138                 :             : 
     139                 :             : inline location_t
     140                 :  3498941996 : get_pure_location (location_t loc)
     141                 :             : {
     142                 :  3498941996 :   return get_pure_location (line_table, loc);
     143                 :             : }
     144                 :             : 
     145                 :             : /* Get the start of any range encoded within location LOC.  */
     146                 :             : 
     147                 :             : inline location_t
     148                 :   640875767 : get_start (location_t loc)
     149                 :             : {
     150                 :   640875767 :   return get_range_from_loc (line_table, loc).m_start;
     151                 :             : }
     152                 :             : 
     153                 :             : /* Get the endpoint of any range encoded within location LOC.  */
     154                 :             : 
     155                 :             : inline location_t
     156                 :   714779747 : get_finish (location_t loc)
     157                 :             : {
     158                 :   714779747 :   return get_range_from_loc (line_table, loc).m_finish;
     159                 :             : }
     160                 :             : 
     161                 :             : extern location_t make_location (location_t caret,
     162                 :             :                                  location_t start, location_t finish);
     163                 :             : extern location_t make_location (location_t caret, source_range src_range);
     164                 :             : 
     165                 :             : void dump_line_table_statistics (void);
     166                 :             : 
     167                 :             : void dump_location_info (FILE *stream);
     168                 :             : 
     169                 :             : class GTY(()) string_concat
     170                 :             : {
     171                 :             : public:
     172                 :             :   string_concat (int num, location_t *locs);
     173                 :             : 
     174                 :             :   int m_num;
     175                 :             :   location_t * GTY ((atomic)) m_locs;
     176                 :             : };
     177                 :             : 
     178                 :             : class GTY(()) string_concat_db
     179                 :             : {
     180                 :             :  public:
     181                 :             :   string_concat_db ();
     182                 :             :   void record_string_concatenation (int num, location_t *locs);
     183                 :             : 
     184                 :             :   bool get_string_concatenation (location_t loc,
     185                 :             :                                  int *out_num,
     186                 :             :                                  location_t **out_locs);
     187                 :             : 
     188                 :             :  private:
     189                 :             :   static location_t get_key_loc (location_t loc);
     190                 :             : 
     191                 :             :   /* For the fields to be private, we must grant access to the
     192                 :             :      generated code in gtype-desc.cc.  */
     193                 :             : 
     194                 :             :   friend void ::gt_ggc_mx_string_concat_db (void *x_p);
     195                 :             :   friend void ::gt_pch_nx_string_concat_db (void *x_p);
     196                 :             :   friend void ::gt_pch_p_16string_concat_db (void *this_obj, void *x_p,
     197                 :             :                                              gt_pointer_operator op,
     198                 :             :                                              void *cookie);
     199                 :             : 
     200                 :             :   hash_map <location_hash, string_concat *> *m_table;
     201                 :             : };
     202                 :             : 
     203                 :             : #endif
        

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.