LCOV - code coverage report
Current view: top level - gcc - input.h Coverage Total Hit
Test: gcc.info Lines: 100.0 % 12 12
Test Date: 2026-02-28 14:20:25 Functions: - 0 0
Legend: Lines:     hit not hit

            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-2026 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              : /* Hierarchical discriminator support for AutoFDO.
      93              : Discriminator format: [Base:8][Multiplicity:7][CopyID:11][Unused:6]
      94              : - Base discriminator (bits 0-7): Distinguishes instructions at same line
      95              : - Multiplicity (bits 8-14): Duplication factor for unrolling/vectorization
      96              : - CopyID (bits 15-25): Unique identifier for code copies
      97              : - Unused (bits 26-31): Reserved.  */
      98              : 
      99              : /* Discriminator bit layout constants.  */
     100              : #define DISCR_BASE_BITS 8
     101              : #define DISCR_MULTIPLICITY_BITS 7
     102              : #define DISCR_COPYID_BITS 11
     103              : #define DISCR_UNUSED_BITS 6
     104              : 
     105              : #define DISCR_BASE_MASK ((1u << DISCR_BASE_BITS) - 1)
     106              : #define DISCR_MULTIPLICITY_MASK ((1u << DISCR_MULTIPLICITY_BITS) - 1)
     107              : #define DISCR_COPYID_MASK ((1u << DISCR_COPYID_BITS) - 1)
     108              : 
     109              : #define DISCR_BASE_SHIFT 0
     110              : #define DISCR_MULTIPLICITY_SHIFT DISCR_BASE_BITS
     111              : #define DISCR_COPYID_SHIFT (DISCR_BASE_BITS + DISCR_MULTIPLICITY_BITS)
     112              : 
     113              : /* Maximum values for each discriminator field.  */
     114              : #define DISCR_BASE_MAX DISCR_BASE_MASK
     115              : #define DISCR_MULTIPLICITY_MAX DISCR_MULTIPLICITY_MASK
     116              : #define DISCR_COPYID_MAX DISCR_COPYID_MASK
     117              : 
     118              : /* Structure to hold hierarchical discriminator components.  */
     119              : struct discriminator_components
     120              : {
     121              :   unsigned int base;         /* Front-end discriminator (bits 0-7).  */
     122              :   unsigned int multiplicity; /* Duplication factor (bits 8-14).  */
     123              :   unsigned int copyid;       /* Copy identifier (bits 15-25).  */
     124              : };
     125              : 
     126              : /* Create location with hierarchical discriminator.  */
     127              : extern location_t
     128              : location_with_discriminator_components (location_t,
     129              :                                         const discriminator_components &);
     130              : 
     131              : /* Get discriminator components from location.  */
     132              : extern discriminator_components
     133              : get_discriminator_components_from_loc (location_t);
     134              : 
     135              : #define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
     136              : #define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
     137              : #define LOCATION_COLUMN(LOC)((expand_location (LOC)).column)
     138              : #define LOCATION_LOCUS(LOC) \
     139              :   ((IS_ADHOC_LOC (LOC)) ? get_location_from_adhoc_loc (line_table, LOC) \
     140              :    : (LOC))
     141              : #define LOCATION_BLOCK(LOC) \
     142              :   ((tree) ((IS_ADHOC_LOC (LOC)) ? get_data_from_adhoc_loc (line_table, (LOC)) \
     143              :    : NULL))
     144              : #define RESERVED_LOCATION_P(LOC) \
     145              :   (LOCATION_LOCUS (LOC) < RESERVED_LOCATION_COUNT)
     146              : 
     147              : /* Return a positive value if LOCATION is the locus of a token that is
     148              :    located in a system header, O otherwise. It returns 1 if LOCATION
     149              :    is the locus of a token that is located in a system header, and 2
     150              :    if LOCATION is the locus of a token located in a C system header
     151              :    that therefore needs to be extern "C" protected in C++.
     152              : 
     153              :    Note that this function returns 1 if LOCATION belongs to a token
     154              :    that is part of a macro replacement-list defined in a system
     155              :    header, but expanded in a non-system file.  */
     156              : 
     157              : inline int
     158   1176748673 : in_system_header_at (location_t loc)
     159              : {
     160   1176748673 :   return linemap_location_in_system_header_p (line_table, loc);
     161              : }
     162              : 
     163              : /* Return true if LOCATION is the locus of a token that
     164              :    comes from a macro expansion, false otherwise.  */
     165              : 
     166              : inline bool
     167      5035583 : from_macro_expansion_at (location_t loc)
     168              : {
     169      5035583 :   return linemap_location_from_macro_expansion_p (line_table, loc);
     170              : }
     171              : 
     172              : /* Return true if LOCATION is the locus of a token that comes from
     173              :    a macro definition, false otherwise.  This differs from from_macro_expansion_at
     174              :    in its treatment of macro arguments, for which this returns false.  */
     175              : 
     176              : inline bool
     177         1688 : from_macro_definition_at (location_t loc)
     178              : {
     179         1688 :   return linemap_location_from_macro_definition_p (line_table, loc);
     180              : }
     181              : 
     182              : inline location_t
     183   3900678436 : get_pure_location (location_t loc)
     184              : {
     185   3900678436 :   return get_pure_location (line_table, loc);
     186              : }
     187              : 
     188              : /* Get the start of any range encoded within location LOC.  */
     189              : 
     190              : inline location_t
     191    744742751 : get_start (location_t loc)
     192              : {
     193    744742751 :   return get_range_from_loc (line_table, loc).m_start;
     194              : }
     195              : 
     196              : /* Get the endpoint of any range encoded within location LOC.  */
     197              : 
     198              : inline location_t
     199    826687967 : get_finish (location_t loc)
     200              : {
     201    826687967 :   return get_range_from_loc (line_table, loc).m_finish;
     202              : }
     203              : 
     204              : extern location_t make_location (location_t caret,
     205              :                                  location_t start, location_t finish);
     206              : extern location_t make_location (location_t caret, source_range src_range);
     207              : 
     208              : void dump_line_table_statistics (void);
     209              : 
     210              : void dump_location_info (FILE *stream);
     211              : 
     212              : class GTY(()) string_concat
     213              : {
     214              : public:
     215              :   string_concat (int num, location_t *locs);
     216              : 
     217              :   int m_num;
     218              :   location_t * GTY ((atomic)) m_locs;
     219              : };
     220              : 
     221              : class GTY(()) string_concat_db
     222              : {
     223              :  public:
     224              :   string_concat_db ();
     225              :   void record_string_concatenation (int num, location_t *locs);
     226              : 
     227              :   bool get_string_concatenation (location_t loc,
     228              :                                  int *out_num,
     229              :                                  location_t **out_locs);
     230              : 
     231              :  private:
     232              :   static location_t get_key_loc (location_t loc);
     233              : 
     234              :   /* For the fields to be private, we must grant access to the
     235              :      generated code in gtype-desc.cc.  */
     236              : 
     237              :   friend void ::gt_ggc_mx_string_concat_db (void *x_p);
     238              :   friend void ::gt_pch_nx_string_concat_db (void *x_p);
     239              :   friend void ::gt_pch_p_16string_concat_db (void *this_obj, void *x_p,
     240              :                                              gt_pointer_operator op,
     241              :                                              void *cookie);
     242              : 
     243              :   hash_map <location_hash, string_concat *> *m_table;
     244              : };
     245              : 
     246              : #endif
        

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.