1*e4b17023SJohn Marino /* Map logical line numbers to (source file, line number) pairs. 2*e4b17023SJohn Marino Copyright (C) 2001, 2003, 2004, 2007, 2008, 2009, 2010, 2011 3*e4b17023SJohn Marino Free Software Foundation, Inc. 4*e4b17023SJohn Marino 5*e4b17023SJohn Marino This program is free software; you can redistribute it and/or modify it 6*e4b17023SJohn Marino under the terms of the GNU General Public License as published by the 7*e4b17023SJohn Marino Free Software Foundation; either version 3, or (at your option) any 8*e4b17023SJohn Marino later version. 9*e4b17023SJohn Marino 10*e4b17023SJohn Marino This program is distributed in the hope that it will be useful, 11*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 12*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*e4b17023SJohn Marino GNU General Public License for more details. 14*e4b17023SJohn Marino 15*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 16*e4b17023SJohn Marino along with this program; see the file COPYING3. If not see 17*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. 18*e4b17023SJohn Marino 19*e4b17023SJohn Marino In other words, you are welcome to use, share and improve this program. 20*e4b17023SJohn Marino You are forbidden to forbid anyone else to use, share and improve 21*e4b17023SJohn Marino what you give them. Help stamp out software-hoarding! */ 22*e4b17023SJohn Marino 23*e4b17023SJohn Marino #ifndef LIBCPP_LINE_MAP_H 24*e4b17023SJohn Marino #define LIBCPP_LINE_MAP_H 25*e4b17023SJohn Marino 26*e4b17023SJohn Marino #ifndef GTY 27*e4b17023SJohn Marino #define GTY(x) /* nothing */ 28*e4b17023SJohn Marino #endif 29*e4b17023SJohn Marino 30*e4b17023SJohn Marino /* Reason for creating a new line map with linemap_add. LC_ENTER is 31*e4b17023SJohn Marino when including a new file, e.g. a #include directive in C. 32*e4b17023SJohn Marino LC_LEAVE is when reaching a file's end. LC_RENAME is when a file 33*e4b17023SJohn Marino name or line number changes for neither of the above reasons 34*e4b17023SJohn Marino (e.g. a #line directive in C); LC_RENAME_VERBATIM is like LC_RENAME 35*e4b17023SJohn Marino but a filename of "" is not specially interpreted as standard 36*e4b17023SJohn Marino input. LC_ENTER_MACRO is when a macro expansion is about to start. */ 37*e4b17023SJohn Marino enum lc_reason 38*e4b17023SJohn Marino { 39*e4b17023SJohn Marino LC_ENTER = 0, 40*e4b17023SJohn Marino LC_LEAVE, 41*e4b17023SJohn Marino LC_RENAME, 42*e4b17023SJohn Marino LC_RENAME_VERBATIM, 43*e4b17023SJohn Marino LC_ENTER_MACRO 44*e4b17023SJohn Marino /* FIXME: add support for stringize and paste. */ 45*e4b17023SJohn Marino }; 46*e4b17023SJohn Marino 47*e4b17023SJohn Marino /* The type of line numbers. */ 48*e4b17023SJohn Marino typedef unsigned int linenum_type; 49*e4b17023SJohn Marino 50*e4b17023SJohn Marino /* A logical line/column number, i.e. an "index" into a line_map. */ 51*e4b17023SJohn Marino typedef unsigned int source_location; 52*e4b17023SJohn Marino 53*e4b17023SJohn Marino /* Memory allocation function typedef. Works like xrealloc. */ 54*e4b17023SJohn Marino typedef void *(*line_map_realloc) (void *, size_t); 55*e4b17023SJohn Marino 56*e4b17023SJohn Marino /* Memory allocator function that returns the actual allocated size, 57*e4b17023SJohn Marino for a given requested allocation. */ 58*e4b17023SJohn Marino typedef size_t (*line_map_round_alloc_size_func) (size_t); 59*e4b17023SJohn Marino 60*e4b17023SJohn Marino /* An ordinary line map encodes physical source locations. Those 61*e4b17023SJohn Marino physical source locations are called "spelling locations". 62*e4b17023SJohn Marino 63*e4b17023SJohn Marino Physical source file TO_FILE at line TO_LINE at column 0 is represented 64*e4b17023SJohn Marino by the logical START_LOCATION. TO_LINE+L at column C is represented by 65*e4b17023SJohn Marino START_LOCATION+(L*(1<<column_bits))+C, as long as C<(1<<column_bits), 66*e4b17023SJohn Marino and the result_location is less than the next line_map's start_location. 67*e4b17023SJohn Marino (The top line is line 1 and the leftmost column is column 1; line/column 0 68*e4b17023SJohn Marino means "entire file/line" or "unknown line/column" or "not applicable".) 69*e4b17023SJohn Marino 70*e4b17023SJohn Marino The highest possible source location is MAX_SOURCE_LOCATION. */ 71*e4b17023SJohn Marino struct GTY(()) line_map_ordinary { 72*e4b17023SJohn Marino const char *to_file; 73*e4b17023SJohn Marino linenum_type to_line; 74*e4b17023SJohn Marino 75*e4b17023SJohn Marino /* An index into the set that gives the line mapping at whose end 76*e4b17023SJohn Marino the current one was included. File(s) at the bottom of the 77*e4b17023SJohn Marino include stack have this set to -1. */ 78*e4b17023SJohn Marino int included_from; 79*e4b17023SJohn Marino 80*e4b17023SJohn Marino /* SYSP is one for a system header, two for a C system header file 81*e4b17023SJohn Marino that therefore needs to be extern "C" protected in C++, and zero 82*e4b17023SJohn Marino otherwise. This field isn't really needed now that it's in 83*e4b17023SJohn Marino cpp_buffer. */ 84*e4b17023SJohn Marino unsigned char sysp; 85*e4b17023SJohn Marino 86*e4b17023SJohn Marino /* Number of the low-order source_location bits used for a column number. */ 87*e4b17023SJohn Marino unsigned int column_bits : 8; 88*e4b17023SJohn Marino }; 89*e4b17023SJohn Marino 90*e4b17023SJohn Marino /* This is the highest possible source location encoded within an 91*e4b17023SJohn Marino ordinary or macro map. */ 92*e4b17023SJohn Marino #define MAX_SOURCE_LOCATION 0xFFFFFFFF 93*e4b17023SJohn Marino 94*e4b17023SJohn Marino struct cpp_hashnode; 95*e4b17023SJohn Marino 96*e4b17023SJohn Marino /* A macro line map encodes location of tokens coming from a macro 97*e4b17023SJohn Marino expansion. 98*e4b17023SJohn Marino 99*e4b17023SJohn Marino Please note that this struct line_map_macro is a field of struct 100*e4b17023SJohn Marino line_map below, go read the comments of struct line_map below and 101*e4b17023SJohn Marino then come back here. 102*e4b17023SJohn Marino 103*e4b17023SJohn Marino The offset from START_LOCATION is used to index into 104*e4b17023SJohn Marino MACRO_LOCATIONS; this holds the original location of the token. */ 105*e4b17023SJohn Marino struct GTY(()) line_map_macro { 106*e4b17023SJohn Marino /* The cpp macro which expansion gave birth to this macro map. */ 107*e4b17023SJohn Marino struct cpp_hashnode * GTY ((nested_ptr (union tree_node, 108*e4b17023SJohn Marino "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", 109*e4b17023SJohn Marino "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"))) 110*e4b17023SJohn Marino macro; 111*e4b17023SJohn Marino 112*e4b17023SJohn Marino /* The number of tokens inside the replacement-list of MACRO. */ 113*e4b17023SJohn Marino unsigned int n_tokens; 114*e4b17023SJohn Marino 115*e4b17023SJohn Marino /* This array of location is actually an array of pairs of 116*e4b17023SJohn Marino locations. The elements inside it thus look like: 117*e4b17023SJohn Marino 118*e4b17023SJohn Marino x0,y0, x1,y1, x2,y2, ...., xn,yn. 119*e4b17023SJohn Marino 120*e4b17023SJohn Marino where n == n_tokens; 121*e4b17023SJohn Marino 122*e4b17023SJohn Marino Remember that these xI,yI are collected when libcpp is about to 123*e4b17023SJohn Marino expand a given macro. 124*e4b17023SJohn Marino 125*e4b17023SJohn Marino yI is the location in the macro definition, either of the token 126*e4b17023SJohn Marino itself or of a macro parameter that it replaces. 127*e4b17023SJohn Marino 128*e4b17023SJohn Marino Imagine this: 129*e4b17023SJohn Marino 130*e4b17023SJohn Marino #define PLUS(A, B) A + B <--- #1 131*e4b17023SJohn Marino 132*e4b17023SJohn Marino int a = PLUS (1,2); <--- #2 133*e4b17023SJohn Marino 134*e4b17023SJohn Marino There is a macro map for the expansion of PLUS in #2. PLUS is 135*e4b17023SJohn Marino expanded into its expansion-list. The expansion-list is the 136*e4b17023SJohn Marino replacement-list of PLUS where the macro parameters are replaced 137*e4b17023SJohn Marino with their arguments. So the replacement-list of PLUS is made of 138*e4b17023SJohn Marino the tokens: 139*e4b17023SJohn Marino 140*e4b17023SJohn Marino A, +, B 141*e4b17023SJohn Marino 142*e4b17023SJohn Marino and the expansion-list is made of the tokens: 143*e4b17023SJohn Marino 144*e4b17023SJohn Marino 1, +, 2 145*e4b17023SJohn Marino 146*e4b17023SJohn Marino Let's consider the case of token "+". Its y1 [yI for I == 1] is 147*e4b17023SJohn Marino its spelling location in #1. 148*e4b17023SJohn Marino 149*e4b17023SJohn Marino y0 (thus for token "1") is the spelling location of A in #1. 150*e4b17023SJohn Marino 151*e4b17023SJohn Marino And y2 (of token "2") is the spelling location of B in #1. 152*e4b17023SJohn Marino 153*e4b17023SJohn Marino When the token is /not/ an argument for a macro, xI is the same 154*e4b17023SJohn Marino location as yI. Otherwise, xI is the location of the token 155*e4b17023SJohn Marino outside this macro expansion. If this macro was expanded from 156*e4b17023SJohn Marino another macro expansion, xI is a virtual location representing 157*e4b17023SJohn Marino the token in that macro expansion; otherwise, it is the spelling 158*e4b17023SJohn Marino location of the token. 159*e4b17023SJohn Marino 160*e4b17023SJohn Marino Note that a virtual location is a location returned by 161*e4b17023SJohn Marino linemap_add_macro_token. It encodes the relevant locations (x,y 162*e4b17023SJohn Marino pairs) of that token accross the macro expansions from which it 163*e4b17023SJohn Marino (the token) might come from. 164*e4b17023SJohn Marino 165*e4b17023SJohn Marino In the example above x1 (for token "+") is going to be the same 166*e4b17023SJohn Marino as y1. x0 is the spelling location for the argument token "1", 167*e4b17023SJohn Marino and x2 is the spelling location for the argument token "2". */ 168*e4b17023SJohn Marino source_location * GTY((length ("2 * %h.n_tokens"))) macro_locations; 169*e4b17023SJohn Marino 170*e4b17023SJohn Marino /* This is the location of the expansion point of the current macro 171*e4b17023SJohn Marino map. It's the location of the macro name. That location is held 172*e4b17023SJohn Marino by the map that was current right before the current one. It 173*e4b17023SJohn Marino could have been either a macro or an ordinary map, depending on 174*e4b17023SJohn Marino if we are in a nested expansion context not. */ 175*e4b17023SJohn Marino source_location expansion; 176*e4b17023SJohn Marino }; 177*e4b17023SJohn Marino 178*e4b17023SJohn Marino /* A line_map encodes a sequence of locations. 179*e4b17023SJohn Marino There are two kinds of maps. Ordinary maps and macro expansion 180*e4b17023SJohn Marino maps, a.k.a macro maps. 181*e4b17023SJohn Marino 182*e4b17023SJohn Marino A macro map encodes source locations of tokens that are part of a 183*e4b17023SJohn Marino macro replacement-list, at a macro expansion point. E.g, in: 184*e4b17023SJohn Marino 185*e4b17023SJohn Marino #define PLUS(A,B) A + B 186*e4b17023SJohn Marino 187*e4b17023SJohn Marino No macro map is going to be created there, because we are not at a 188*e4b17023SJohn Marino macro expansion point. We are at a macro /definition/ point. So the 189*e4b17023SJohn Marino locations of the tokens of the macro replacement-list (i.e, A + B) 190*e4b17023SJohn Marino will be locations in an ordinary map, not a macro map. 191*e4b17023SJohn Marino 192*e4b17023SJohn Marino On the other hand, if we later do: 193*e4b17023SJohn Marino 194*e4b17023SJohn Marino int a = PLUS (1,2); 195*e4b17023SJohn Marino 196*e4b17023SJohn Marino The invocation of PLUS here is a macro expansion. So we are at a 197*e4b17023SJohn Marino macro expansion point. The preprocessor expands PLUS (1,2) and 198*e4b17023SJohn Marino replaces it with the tokens of its replacement-list: 1 + 2. A macro 199*e4b17023SJohn Marino map is going to be created to hold (or rather to map, haha ...) the 200*e4b17023SJohn Marino locations of the tokens 1, + and 2. The macro map also records the 201*e4b17023SJohn Marino location of the expansion point of PLUS. That location is mapped in 202*e4b17023SJohn Marino the map that is active right before the location of the invocation 203*e4b17023SJohn Marino of PLUS. */ 204*e4b17023SJohn Marino struct GTY(()) line_map { 205*e4b17023SJohn Marino source_location start_location; 206*e4b17023SJohn Marino 207*e4b17023SJohn Marino /* The reason for creation of this line map. */ 208*e4b17023SJohn Marino ENUM_BITFIELD (lc_reason) reason : CHAR_BIT; 209*e4b17023SJohn Marino 210*e4b17023SJohn Marino union map_u { 211*e4b17023SJohn Marino struct line_map_ordinary GTY((tag ("0"))) ordinary; 212*e4b17023SJohn Marino struct line_map_macro GTY((tag ("1"))) macro; 213*e4b17023SJohn Marino } GTY((desc ("%1.reason == LC_ENTER_MACRO"))) d; 214*e4b17023SJohn Marino }; 215*e4b17023SJohn Marino 216*e4b17023SJohn Marino #define MAP_START_LOCATION(MAP) (MAP)->start_location 217*e4b17023SJohn Marino 218*e4b17023SJohn Marino #define ORDINARY_MAP_FILE_NAME(MAP) \ 219*e4b17023SJohn Marino linemap_check_ordinary (MAP)->d.ordinary.to_file 220*e4b17023SJohn Marino 221*e4b17023SJohn Marino #define ORDINARY_MAP_STARTING_LINE_NUMBER(MAP) \ 222*e4b17023SJohn Marino linemap_check_ordinary (MAP)->d.ordinary.to_line 223*e4b17023SJohn Marino 224*e4b17023SJohn Marino #define ORDINARY_MAP_INCLUDER_FILE_INDEX(MAP) \ 225*e4b17023SJohn Marino linemap_check_ordinary (MAP)->d.ordinary.included_from 226*e4b17023SJohn Marino 227*e4b17023SJohn Marino #define ORDINARY_MAP_IN_SYSTEM_HEADER_P(MAP) \ 228*e4b17023SJohn Marino linemap_check_ordinary (MAP)->d.ordinary.sysp 229*e4b17023SJohn Marino 230*e4b17023SJohn Marino #define ORDINARY_MAP_NUMBER_OF_COLUMN_BITS(MAP) \ 231*e4b17023SJohn Marino linemap_check_ordinary (MAP)->d.ordinary.column_bits 232*e4b17023SJohn Marino 233*e4b17023SJohn Marino #define MACRO_MAP_MACRO(MAP) (MAP)->d.macro.macro 234*e4b17023SJohn Marino 235*e4b17023SJohn Marino #define MACRO_MAP_NUM_MACRO_TOKENS(MAP) (MAP)->d.macro.n_tokens 236*e4b17023SJohn Marino 237*e4b17023SJohn Marino #define MACRO_MAP_LOCATIONS(MAP) (MAP)->d.macro.macro_locations 238*e4b17023SJohn Marino 239*e4b17023SJohn Marino #define MACRO_MAP_EXPANSION_POINT_LOCATION(MAP) (MAP)->d.macro.expansion 240*e4b17023SJohn Marino 241*e4b17023SJohn Marino /* The abstraction of a set of location maps. There can be several 242*e4b17023SJohn Marino types of location maps. This abstraction contains the attributes 243*e4b17023SJohn Marino that are independent from the type of the map. */ 244*e4b17023SJohn Marino struct GTY(()) maps_info { 245*e4b17023SJohn Marino /* This array contains the different line maps. 246*e4b17023SJohn Marino A line map is created for the following events: 247*e4b17023SJohn Marino - when a new preprocessing unit start. 248*e4b17023SJohn Marino - when a preprocessing unit ends. 249*e4b17023SJohn Marino - when a macro expansion occurs. */ 250*e4b17023SJohn Marino struct line_map * GTY ((length ("%h.used"))) maps; 251*e4b17023SJohn Marino 252*e4b17023SJohn Marino /* The total number of allocated maps. */ 253*e4b17023SJohn Marino unsigned int allocated; 254*e4b17023SJohn Marino 255*e4b17023SJohn Marino /* The number of elements used in maps. This number is smaller 256*e4b17023SJohn Marino or equal to ALLOCATED. */ 257*e4b17023SJohn Marino unsigned int used; 258*e4b17023SJohn Marino 259*e4b17023SJohn Marino unsigned int cache; 260*e4b17023SJohn Marino }; 261*e4b17023SJohn Marino 262*e4b17023SJohn Marino /* A set of chronological line_map structures. */ 263*e4b17023SJohn Marino struct GTY(()) line_maps { 264*e4b17023SJohn Marino 265*e4b17023SJohn Marino struct maps_info info_ordinary; 266*e4b17023SJohn Marino 267*e4b17023SJohn Marino struct maps_info info_macro; 268*e4b17023SJohn Marino 269*e4b17023SJohn Marino /* Depth of the include stack, including the current file. */ 270*e4b17023SJohn Marino unsigned int depth; 271*e4b17023SJohn Marino 272*e4b17023SJohn Marino /* If true, prints an include trace a la -H. */ 273*e4b17023SJohn Marino bool trace_includes; 274*e4b17023SJohn Marino 275*e4b17023SJohn Marino /* Highest source_location "given out". */ 276*e4b17023SJohn Marino source_location highest_location; 277*e4b17023SJohn Marino 278*e4b17023SJohn Marino /* Start of line of highest source_location "given out". */ 279*e4b17023SJohn Marino source_location highest_line; 280*e4b17023SJohn Marino 281*e4b17023SJohn Marino /* The maximum column number we can quickly allocate. Higher numbers 282*e4b17023SJohn Marino may require allocating a new line_map. */ 283*e4b17023SJohn Marino unsigned int max_column_hint; 284*e4b17023SJohn Marino 285*e4b17023SJohn Marino /* If non-null, the allocator to use when resizing 'maps'. If null, 286*e4b17023SJohn Marino xrealloc is used. */ 287*e4b17023SJohn Marino line_map_realloc reallocator; 288*e4b17023SJohn Marino 289*e4b17023SJohn Marino /* The allocators' function used to know the actual size it 290*e4b17023SJohn Marino allocated, for a certain allocation size requested. */ 291*e4b17023SJohn Marino line_map_round_alloc_size_func round_alloc_size; 292*e4b17023SJohn Marino }; 293*e4b17023SJohn Marino 294*e4b17023SJohn Marino /* Returns the pointer to the memory region where information about 295*e4b17023SJohn Marino maps are stored in the line table SET. MACRO_MAP_P is a flag 296*e4b17023SJohn Marino telling if we want macro or ordinary maps. */ 297*e4b17023SJohn Marino #define LINEMAPS_MAP_INFO(SET, MACRO_MAP_P) \ 298*e4b17023SJohn Marino ((MACRO_MAP_P) \ 299*e4b17023SJohn Marino ? &((SET)->info_macro) \ 300*e4b17023SJohn Marino : &((SET)->info_ordinary)) 301*e4b17023SJohn Marino 302*e4b17023SJohn Marino /* Returns the pointer to the memory region where maps are stored in 303*e4b17023SJohn Marino the line table SET. MAP_KIND shall be TRUE if we are interested in 304*e4b17023SJohn Marino macro maps false otherwise. */ 305*e4b17023SJohn Marino #define LINEMAPS_MAPS(SET, MAP_KIND) \ 306*e4b17023SJohn Marino (LINEMAPS_MAP_INFO (SET, MAP_KIND))->maps 307*e4b17023SJohn Marino 308*e4b17023SJohn Marino /* Returns the number of allocated maps so far. MAP_KIND shall be TRUE 309*e4b17023SJohn Marino if we are interested in macro maps, FALSE otherwise. */ 310*e4b17023SJohn Marino #define LINEMAPS_ALLOCATED(SET, MAP_KIND) \ 311*e4b17023SJohn Marino (LINEMAPS_MAP_INFO (SET, MAP_KIND))->allocated 312*e4b17023SJohn Marino 313*e4b17023SJohn Marino /* Returns the number of used maps so far. MAP_KIND shall be TRUE if 314*e4b17023SJohn Marino we are interested in macro maps, FALSE otherwise.*/ 315*e4b17023SJohn Marino #define LINEMAPS_USED(SET, MAP_KIND) \ 316*e4b17023SJohn Marino (LINEMAPS_MAP_INFO (SET, MAP_KIND))->used 317*e4b17023SJohn Marino 318*e4b17023SJohn Marino /* Returns the index of the last map that was looked up with 319*e4b17023SJohn Marino linemap_lookup. MAP_KIND shall be TRUE if we are interested in 320*e4b17023SJohn Marino macro maps, FALSE otherwise. */ 321*e4b17023SJohn Marino #define LINEMAPS_CACHE(SET, MAP_KIND) \ 322*e4b17023SJohn Marino (LINEMAPS_MAP_INFO (SET, MAP_KIND))->cache 323*e4b17023SJohn Marino 324*e4b17023SJohn Marino /* Return the map at a given index. */ 325*e4b17023SJohn Marino #define LINEMAPS_MAP_AT(SET, MAP_KIND, INDEX) \ 326*e4b17023SJohn Marino (&((LINEMAPS_MAPS (SET, MAP_KIND))[(INDEX)])) 327*e4b17023SJohn Marino 328*e4b17023SJohn Marino /* Returns the last map used in the line table SET. MAP_KIND 329*e4b17023SJohn Marino shall be TRUE if we are interested in macro maps, FALSE 330*e4b17023SJohn Marino otherwise.*/ 331*e4b17023SJohn Marino #define LINEMAPS_LAST_MAP(SET, MAP_KIND) \ 332*e4b17023SJohn Marino LINEMAPS_MAP_AT (SET, MAP_KIND, (LINEMAPS_USED (SET, MAP_KIND) - 1)) 333*e4b17023SJohn Marino 334*e4b17023SJohn Marino /* Returns the last map that was allocated in the line table SET. 335*e4b17023SJohn Marino MAP_KIND shall be TRUE if we are interested in macro maps, FALSE 336*e4b17023SJohn Marino otherwise.*/ 337*e4b17023SJohn Marino #define LINEMAPS_LAST_ALLOCATED_MAP(SET, MAP_KIND) \ 338*e4b17023SJohn Marino LINEMAPS_MAP_AT (SET, MAP_KIND, LINEMAPS_ALLOCATED (SET, MAP_KIND) - 1) 339*e4b17023SJohn Marino 340*e4b17023SJohn Marino /* Returns a pointer to the memory region where ordinary maps are 341*e4b17023SJohn Marino allocated in the line table SET. */ 342*e4b17023SJohn Marino #define LINEMAPS_ORDINARY_MAPS(SET) \ 343*e4b17023SJohn Marino LINEMAPS_MAPS (SET, false) 344*e4b17023SJohn Marino 345*e4b17023SJohn Marino /* Returns the INDEXth ordinary map. */ 346*e4b17023SJohn Marino #define LINEMAPS_ORDINARY_MAP_AT(SET, INDEX) \ 347*e4b17023SJohn Marino LINEMAPS_MAP_AT (SET, false, INDEX) 348*e4b17023SJohn Marino 349*e4b17023SJohn Marino /* Return the number of ordinary maps allocated in the line table 350*e4b17023SJohn Marino SET. */ 351*e4b17023SJohn Marino #define LINEMAPS_ORDINARY_ALLOCATED(SET) \ 352*e4b17023SJohn Marino LINEMAPS_ALLOCATED(SET, false) 353*e4b17023SJohn Marino 354*e4b17023SJohn Marino /* Return the number of ordinary maps used in the line table SET. */ 355*e4b17023SJohn Marino #define LINEMAPS_ORDINARY_USED(SET) \ 356*e4b17023SJohn Marino LINEMAPS_USED(SET, false) 357*e4b17023SJohn Marino 358*e4b17023SJohn Marino /* Return the index of the last ordinary map that was looked up with 359*e4b17023SJohn Marino linemap_lookup. */ 360*e4b17023SJohn Marino #define LINEMAPS_ORDINARY_CACHE(SET) \ 361*e4b17023SJohn Marino LINEMAPS_CACHE(SET, false) 362*e4b17023SJohn Marino 363*e4b17023SJohn Marino /* Returns a pointer to the last ordinary map used in the line table 364*e4b17023SJohn Marino SET. */ 365*e4b17023SJohn Marino #define LINEMAPS_LAST_ORDINARY_MAP(SET) \ 366*e4b17023SJohn Marino LINEMAPS_LAST_MAP(SET, false) 367*e4b17023SJohn Marino 368*e4b17023SJohn Marino /* Returns a pointer to the last ordinary map allocated the line table 369*e4b17023SJohn Marino SET. */ 370*e4b17023SJohn Marino #define LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP(SET) \ 371*e4b17023SJohn Marino LINEMAPS_LAST_ALLOCATED_MAP(SET, false) 372*e4b17023SJohn Marino 373*e4b17023SJohn Marino /* Returns a pointer to the begining of the region where macro maps 374*e4b17023SJohn Marino are allcoated. */ 375*e4b17023SJohn Marino #define LINEMAPS_MACRO_MAPS(SET) \ 376*e4b17023SJohn Marino LINEMAPS_MAPS(SET, true) 377*e4b17023SJohn Marino 378*e4b17023SJohn Marino /* Returns the INDEXth macro map. */ 379*e4b17023SJohn Marino #define LINEMAPS_MACRO_MAP_AT(SET, INDEX) \ 380*e4b17023SJohn Marino LINEMAPS_MAP_AT (SET, true, INDEX) 381*e4b17023SJohn Marino 382*e4b17023SJohn Marino /* Returns the number of macro maps that were allocated in the line 383*e4b17023SJohn Marino table SET. */ 384*e4b17023SJohn Marino #define LINEMAPS_MACRO_ALLOCATED(SET) \ 385*e4b17023SJohn Marino LINEMAPS_ALLOCATED(SET, true) 386*e4b17023SJohn Marino 387*e4b17023SJohn Marino /* Returns the number of macro maps used in the line table SET. */ 388*e4b17023SJohn Marino #define LINEMAPS_MACRO_USED(SET) \ 389*e4b17023SJohn Marino LINEMAPS_USED(SET, true) 390*e4b17023SJohn Marino 391*e4b17023SJohn Marino /* Returns the index of the last macro map looked up with 392*e4b17023SJohn Marino linemap_lookup. */ 393*e4b17023SJohn Marino #define LINEMAPS_MACRO_CACHE(SET) \ 394*e4b17023SJohn Marino LINEMAPS_CACHE(SET, true) 395*e4b17023SJohn Marino 396*e4b17023SJohn Marino /* Returns the lowest location [of a token resulting from macro 397*e4b17023SJohn Marino expansion] encoded in this line table. */ 398*e4b17023SJohn Marino #define LINEMAPS_MACRO_LOWEST_LOCATION(SET) \ 399*e4b17023SJohn Marino (LINEMAPS_MACRO_USED (set) \ 400*e4b17023SJohn Marino ? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set)) \ 401*e4b17023SJohn Marino : MAX_SOURCE_LOCATION) 402*e4b17023SJohn Marino 403*e4b17023SJohn Marino /* Returns the last macro map used in the line table SET. */ 404*e4b17023SJohn Marino #define LINEMAPS_LAST_MACRO_MAP(SET) \ 405*e4b17023SJohn Marino LINEMAPS_LAST_MAP (SET, true) 406*e4b17023SJohn Marino 407*e4b17023SJohn Marino /* Returns the last macro map allocated in the line table SET. */ 408*e4b17023SJohn Marino #define LINEMAPS_LAST_ALLOCATED_MACRO_MAP(SET) \ 409*e4b17023SJohn Marino LINEMAPS_LAST_ALLOCATED_MAP (SET, true) 410*e4b17023SJohn Marino 411*e4b17023SJohn Marino /* Initialize a line map set. */ 412*e4b17023SJohn Marino extern void linemap_init (struct line_maps *); 413*e4b17023SJohn Marino 414*e4b17023SJohn Marino /* Check for and warn about line_maps entered but not exited. */ 415*e4b17023SJohn Marino 416*e4b17023SJohn Marino extern void linemap_check_files_exited (struct line_maps *); 417*e4b17023SJohn Marino 418*e4b17023SJohn Marino /* Return a source_location for the start (i.e. column==0) of 419*e4b17023SJohn Marino (physical) line TO_LINE in the current source file (as in the 420*e4b17023SJohn Marino most recent linemap_add). MAX_COLUMN_HINT is the highest column 421*e4b17023SJohn Marino number we expect to use in this line (but it does not change 422*e4b17023SJohn Marino the highest_location). */ 423*e4b17023SJohn Marino 424*e4b17023SJohn Marino extern source_location linemap_line_start 425*e4b17023SJohn Marino (struct line_maps *set, linenum_type to_line, unsigned int max_column_hint); 426*e4b17023SJohn Marino 427*e4b17023SJohn Marino /* Add a mapping of logical source line to physical source file and 428*e4b17023SJohn Marino line number. This function creates an "ordinary map", which is a 429*e4b17023SJohn Marino map that records locations of tokens that are not part of macro 430*e4b17023SJohn Marino replacement-lists present at a macro expansion point. 431*e4b17023SJohn Marino 432*e4b17023SJohn Marino The text pointed to by TO_FILE must have a lifetime 433*e4b17023SJohn Marino at least as long as the lifetime of SET. An empty 434*e4b17023SJohn Marino TO_FILE means standard input. If reason is LC_LEAVE, and 435*e4b17023SJohn Marino TO_FILE is NULL, then TO_FILE, TO_LINE and SYSP are given their 436*e4b17023SJohn Marino natural values considering the file we are returning to. 437*e4b17023SJohn Marino 438*e4b17023SJohn Marino A call to this function can relocate the previous set of 439*e4b17023SJohn Marino maps, so any stored line_map pointers should not be used. */ 440*e4b17023SJohn Marino extern const struct line_map *linemap_add 441*e4b17023SJohn Marino (struct line_maps *, enum lc_reason, unsigned int sysp, 442*e4b17023SJohn Marino const char *to_file, linenum_type to_line); 443*e4b17023SJohn Marino 444*e4b17023SJohn Marino /* Given a logical source location, returns the map which the 445*e4b17023SJohn Marino corresponding (source file, line, column) triplet can be deduced 446*e4b17023SJohn Marino from. Since the set is built chronologically, the logical lines are 447*e4b17023SJohn Marino monotonic increasing, and so the list is sorted and we can use a 448*e4b17023SJohn Marino binary search. If no line map have been allocated yet, this 449*e4b17023SJohn Marino function returns NULL. */ 450*e4b17023SJohn Marino extern const struct line_map *linemap_lookup 451*e4b17023SJohn Marino (struct line_maps *, source_location); 452*e4b17023SJohn Marino 453*e4b17023SJohn Marino /* Returns TRUE if the line table set tracks token locations accross 454*e4b17023SJohn Marino macro expansion, FALSE otherwise. */ 455*e4b17023SJohn Marino bool linemap_tracks_macro_expansion_locs_p (struct line_maps *); 456*e4b17023SJohn Marino 457*e4b17023SJohn Marino /* Return TRUE if MAP encodes locations coming from a macro 458*e4b17023SJohn Marino replacement-list at macro expansion point. */ 459*e4b17023SJohn Marino bool linemap_macro_expansion_map_p (const struct line_map *); 460*e4b17023SJohn Marino 461*e4b17023SJohn Marino /* Return the name of the macro associated to MACRO_MAP. */ 462*e4b17023SJohn Marino const char* linemap_map_get_macro_name (const struct line_map*); 463*e4b17023SJohn Marino 464*e4b17023SJohn Marino /* Return a positive value if LOCATION is the locus of a token that is 465*e4b17023SJohn Marino located in a system header, O otherwise. It returns 1 if LOCATION 466*e4b17023SJohn Marino is the locus of a token that is located in a system header, and 2 467*e4b17023SJohn Marino if LOCATION is the locus of a token located in a C system header 468*e4b17023SJohn Marino that therefore needs to be extern "C" protected in C++. 469*e4b17023SJohn Marino 470*e4b17023SJohn Marino Note that this function returns 1 if LOCATION belongs to a token 471*e4b17023SJohn Marino that is part of a macro replacement-list defined in a system 472*e4b17023SJohn Marino header, but expanded in a non-system file. */ 473*e4b17023SJohn Marino int linemap_location_in_system_header_p (struct line_maps *, 474*e4b17023SJohn Marino source_location); 475*e4b17023SJohn Marino 476*e4b17023SJohn Marino /* Return TRUE if LOCATION is a source code location of a token coming 477*e4b17023SJohn Marino from a macro replacement-list at a macro expansion point, FALSE 478*e4b17023SJohn Marino otherwise. */ 479*e4b17023SJohn Marino bool linemap_location_from_macro_expansion_p (struct line_maps *, 480*e4b17023SJohn Marino source_location); 481*e4b17023SJohn Marino 482*e4b17023SJohn Marino /* source_location values from 0 to RESERVED_LOCATION_COUNT-1 will 483*e4b17023SJohn Marino be reserved for libcpp user as special values, no token from libcpp 484*e4b17023SJohn Marino will contain any of those locations. */ 485*e4b17023SJohn Marino #define RESERVED_LOCATION_COUNT 2 486*e4b17023SJohn Marino 487*e4b17023SJohn Marino /* Converts a map and a source_location to source line. */ 488*e4b17023SJohn Marino #define SOURCE_LINE(MAP, LOC) \ 489*e4b17023SJohn Marino (((((LOC) - linemap_check_ordinary (MAP)->start_location) \ 490*e4b17023SJohn Marino >> (MAP)->d.ordinary.column_bits) + (MAP)->d.ordinary.to_line)) 491*e4b17023SJohn Marino 492*e4b17023SJohn Marino /* Convert a map and source_location to source column number. */ 493*e4b17023SJohn Marino #define SOURCE_COLUMN(MAP, LOC) \ 494*e4b17023SJohn Marino ((((LOC) - linemap_check_ordinary (MAP)->start_location) \ 495*e4b17023SJohn Marino & ((1 << (MAP)->d.ordinary.column_bits) - 1))) 496*e4b17023SJohn Marino 497*e4b17023SJohn Marino /* Returns the last source line number within an ordinary map. This 498*e4b17023SJohn Marino is the (last) line of the #include, or other directive, that caused 499*e4b17023SJohn Marino a map change. */ 500*e4b17023SJohn Marino #define LAST_SOURCE_LINE(MAP) \ 501*e4b17023SJohn Marino SOURCE_LINE (MAP, LAST_SOURCE_LINE_LOCATION (MAP)) 502*e4b17023SJohn Marino 503*e4b17023SJohn Marino /* Return the last column number within an ordinary map. */ 504*e4b17023SJohn Marino #define LAST_SOURCE_COLUMN(MAP) \ 505*e4b17023SJohn Marino SOURCE_COLUMN (MAP, LAST_SOURCE_LINE_LOCATION (MAP)) 506*e4b17023SJohn Marino 507*e4b17023SJohn Marino /* Return the location of the last source line within an ordinary 508*e4b17023SJohn Marino map. */ 509*e4b17023SJohn Marino #define LAST_SOURCE_LINE_LOCATION(MAP) \ 510*e4b17023SJohn Marino ((((linemap_check_ordinary (MAP)[1].start_location - 1 \ 511*e4b17023SJohn Marino - (MAP)->start_location) \ 512*e4b17023SJohn Marino & ~((1 << (MAP)->d.ordinary.column_bits) - 1)) \ 513*e4b17023SJohn Marino + (MAP)->start_location)) 514*e4b17023SJohn Marino 515*e4b17023SJohn Marino /* Returns the map a given map was included from, or NULL if the map 516*e4b17023SJohn Marino belongs to the main file, i.e, a file that wasn't included by 517*e4b17023SJohn Marino another one. */ 518*e4b17023SJohn Marino #define INCLUDED_FROM(SET, MAP) \ 519*e4b17023SJohn Marino ((linemap_check_ordinary (MAP)->d.ordinary.included_from == -1) \ 520*e4b17023SJohn Marino ? NULL \ 521*e4b17023SJohn Marino : (&LINEMAPS_ORDINARY_MAPS (SET)[(MAP)->d.ordinary.included_from])) 522*e4b17023SJohn Marino 523*e4b17023SJohn Marino /* Nonzero if the map is at the bottom of the include stack. */ 524*e4b17023SJohn Marino #define MAIN_FILE_P(MAP) \ 525*e4b17023SJohn Marino ((linemap_check_ordinary (MAP)->d.ordinary.included_from < 0)) 526*e4b17023SJohn Marino 527*e4b17023SJohn Marino #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) 528*e4b17023SJohn Marino 529*e4b17023SJohn Marino /* Assertion macro to be used in line-map code. */ 530*e4b17023SJohn Marino #define linemap_assert(EXPR) \ 531*e4b17023SJohn Marino do { \ 532*e4b17023SJohn Marino if (! (EXPR)) \ 533*e4b17023SJohn Marino abort (); \ 534*e4b17023SJohn Marino } while (0) 535*e4b17023SJohn Marino 536*e4b17023SJohn Marino /* Assert that MAP encodes locations of tokens that are not part of 537*e4b17023SJohn Marino the replacement-list of a macro expansion. */ 538*e4b17023SJohn Marino #define linemap_check_ordinary(LINE_MAP) __extension__ \ 539*e4b17023SJohn Marino ({linemap_assert (!linemap_macro_expansion_map_p (LINE_MAP)); \ 540*e4b17023SJohn Marino (LINE_MAP);}) 541*e4b17023SJohn Marino #else 542*e4b17023SJohn Marino #define linemap_assert(EXPR) 543*e4b17023SJohn Marino #define linemap_check_ordinary(LINE_MAP) (LINE_MAP) 544*e4b17023SJohn Marino #endif 545*e4b17023SJohn Marino 546*e4b17023SJohn Marino /* Encode and return a source_location from a column number. The 547*e4b17023SJohn Marino source line considered is the last source line used to call 548*e4b17023SJohn Marino linemap_line_start, i.e, the last source line which a location was 549*e4b17023SJohn Marino encoded from. */ 550*e4b17023SJohn Marino extern source_location 551*e4b17023SJohn Marino linemap_position_for_column (struct line_maps *, unsigned int); 552*e4b17023SJohn Marino 553*e4b17023SJohn Marino /* Encode and return a source location from a given line and 554*e4b17023SJohn Marino column. */ 555*e4b17023SJohn Marino source_location linemap_position_for_line_and_column (struct line_map *, 556*e4b17023SJohn Marino linenum_type, 557*e4b17023SJohn Marino unsigned int); 558*e4b17023SJohn Marino /* Return the file this map is for. */ 559*e4b17023SJohn Marino #define LINEMAP_FILE(MAP) \ 560*e4b17023SJohn Marino (linemap_check_ordinary (MAP)->d.ordinary.to_file) 561*e4b17023SJohn Marino 562*e4b17023SJohn Marino /* Return the line number this map started encoding location from. */ 563*e4b17023SJohn Marino #define LINEMAP_LINE(MAP) \ 564*e4b17023SJohn Marino (linemap_check_ordinary (MAP)->d.ordinary.to_line) 565*e4b17023SJohn Marino 566*e4b17023SJohn Marino /* Return a positive value if map encodes locations from a system 567*e4b17023SJohn Marino header, 0 otherwise. Returns 1 if MAP encodes locations in a 568*e4b17023SJohn Marino system header and 2 if it encodes locations in a C system header 569*e4b17023SJohn Marino that therefore needs to be extern "C" protected in C++. */ 570*e4b17023SJohn Marino #define LINEMAP_SYSP(MAP) \ 571*e4b17023SJohn Marino (linemap_check_ordinary (MAP)->d.ordinary.sysp) 572*e4b17023SJohn Marino 573*e4b17023SJohn Marino /* Return a positive value if PRE denotes the location of a token that 574*e4b17023SJohn Marino comes before the token of POST, 0 if PRE denotes the location of 575*e4b17023SJohn Marino the same token as the token for POST, and a negative value 576*e4b17023SJohn Marino otherwise. */ 577*e4b17023SJohn Marino int linemap_compare_locations (struct line_maps *set, 578*e4b17023SJohn Marino source_location pre, 579*e4b17023SJohn Marino source_location post); 580*e4b17023SJohn Marino 581*e4b17023SJohn Marino /* Return TRUE if LOC_A denotes the location a token that comes 582*e4b17023SJohn Marino topogically before the token denoted by location LOC_B, or if they 583*e4b17023SJohn Marino are equal. */ 584*e4b17023SJohn Marino #define linemap_location_before_p(SET, LOC_A, LOC_B) \ 585*e4b17023SJohn Marino (linemap_compare_locations ((SET), (LOC_A), (LOC_B)) >= 0) 586*e4b17023SJohn Marino 587*e4b17023SJohn Marino typedef struct 588*e4b17023SJohn Marino { 589*e4b17023SJohn Marino /* The name of the source file involved. */ 590*e4b17023SJohn Marino const char *file; 591*e4b17023SJohn Marino 592*e4b17023SJohn Marino /* The line-location in the source file. */ 593*e4b17023SJohn Marino int line; 594*e4b17023SJohn Marino 595*e4b17023SJohn Marino int column; 596*e4b17023SJohn Marino 597*e4b17023SJohn Marino /* In a system header?. */ 598*e4b17023SJohn Marino bool sysp; 599*e4b17023SJohn Marino } expanded_location; 600*e4b17023SJohn Marino 601*e4b17023SJohn Marino /* This is enum is used by the function linemap_resolve_location 602*e4b17023SJohn Marino below. The meaning of the values is explained in the comment of 603*e4b17023SJohn Marino that function. */ 604*e4b17023SJohn Marino enum location_resolution_kind 605*e4b17023SJohn Marino { 606*e4b17023SJohn Marino LRK_MACRO_EXPANSION_POINT, 607*e4b17023SJohn Marino LRK_SPELLING_LOCATION, 608*e4b17023SJohn Marino LRK_MACRO_DEFINITION_LOCATION 609*e4b17023SJohn Marino }; 610*e4b17023SJohn Marino 611*e4b17023SJohn Marino /* Resolve a virtual location into either a spelling location, an 612*e4b17023SJohn Marino expansion point location or a token argument replacement point 613*e4b17023SJohn Marino location. Return the map that encodes the virtual location as well 614*e4b17023SJohn Marino as the resolved location. 615*e4b17023SJohn Marino 616*e4b17023SJohn Marino If LOC is *NOT* the location of a token resulting from the 617*e4b17023SJohn Marino expansion of a macro, then the parameter LRK (which stands for 618*e4b17023SJohn Marino Location Resolution Kind) is ignored and the resulting location 619*e4b17023SJohn Marino just equals the one given in argument. 620*e4b17023SJohn Marino 621*e4b17023SJohn Marino Now if LOC *IS* the location of a token resulting from the 622*e4b17023SJohn Marino expansion of a macro, this is what happens. 623*e4b17023SJohn Marino 624*e4b17023SJohn Marino * If LRK is set to LRK_MACRO_EXPANSION_POINT 625*e4b17023SJohn Marino ------------------------------- 626*e4b17023SJohn Marino 627*e4b17023SJohn Marino The virtual location is resolved to the first macro expansion point 628*e4b17023SJohn Marino that led to this macro expansion. 629*e4b17023SJohn Marino 630*e4b17023SJohn Marino * If LRK is set to LRK_SPELLING_LOCATION 631*e4b17023SJohn Marino ------------------------------------- 632*e4b17023SJohn Marino 633*e4b17023SJohn Marino The virtual location is resolved to the locus where the token has 634*e4b17023SJohn Marino been spelled in the source. This can follow through all the macro 635*e4b17023SJohn Marino expansions that led to the token. 636*e4b17023SJohn Marino 637*e4b17023SJohn Marino * If LRK is set to LRK_MACRO_DEFINITION_LOCATION 638*e4b17023SJohn Marino -------------------------------------- 639*e4b17023SJohn Marino 640*e4b17023SJohn Marino The virtual location is resolved to the locus of the token in the 641*e4b17023SJohn Marino context of the macro definition. 642*e4b17023SJohn Marino 643*e4b17023SJohn Marino If LOC is the locus of a token that is an argument of a 644*e4b17023SJohn Marino function-like macro [replacing a parameter in the replacement list 645*e4b17023SJohn Marino of the macro] the virtual location is resolved to the locus of the 646*e4b17023SJohn Marino parameter that is replaced, in the context of the definition of the 647*e4b17023SJohn Marino macro. 648*e4b17023SJohn Marino 649*e4b17023SJohn Marino If LOC is the locus of a token that is not an argument of a 650*e4b17023SJohn Marino function-like macro, then the function behaves as if LRK was set to 651*e4b17023SJohn Marino LRK_SPELLING_LOCATION. 652*e4b17023SJohn Marino 653*e4b17023SJohn Marino If LOC_MAP is not NULL, *LOC_MAP is set to the map encoding the 654*e4b17023SJohn Marino returned location. Note that if the resturned location wasn't originally 655*e4b17023SJohn Marino encoded by a map, the *MAP is set to NULL. This can happen if LOC 656*e4b17023SJohn Marino resolves to a location reserved for the client code, like 657*e4b17023SJohn Marino UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */ 658*e4b17023SJohn Marino 659*e4b17023SJohn Marino source_location linemap_resolve_location (struct line_maps *, 660*e4b17023SJohn Marino source_location loc, 661*e4b17023SJohn Marino enum location_resolution_kind lrk, 662*e4b17023SJohn Marino const struct line_map **loc_map); 663*e4b17023SJohn Marino 664*e4b17023SJohn Marino /* Suppose that LOC is the virtual location of a token coming from the 665*e4b17023SJohn Marino expansion of a macro M. This function then steps up to get the 666*e4b17023SJohn Marino location L of the point where M got expanded. If L is a spelling 667*e4b17023SJohn Marino location inside a macro expansion M', then this function returns 668*e4b17023SJohn Marino the point where M' was expanded. LOC_MAP is an output parameter. 669*e4b17023SJohn Marino When non-NULL, *LOC_MAP is set the the map of the returned 670*e4b17023SJohn Marino location. */ 671*e4b17023SJohn Marino source_location linemap_unwind_toward_expansion (struct line_maps *, 672*e4b17023SJohn Marino source_location loc, 673*e4b17023SJohn Marino const struct line_map **loc_map); 674*e4b17023SJohn Marino 675*e4b17023SJohn Marino /* Expand source code location LOC and return a user readable source 676*e4b17023SJohn Marino code location. LOC must be a spelling (non-virtual) location. If 677*e4b17023SJohn Marino it's a location < RESERVED_LOCATION_COUNT a zeroed expanded source 678*e4b17023SJohn Marino location is returned. */ 679*e4b17023SJohn Marino expanded_location linemap_expand_location (struct line_maps *, 680*e4b17023SJohn Marino const struct line_map *, 681*e4b17023SJohn Marino source_location loc); 682*e4b17023SJohn Marino 683*e4b17023SJohn Marino /* Statistics about maps allocation and usage as returned by 684*e4b17023SJohn Marino linemap_get_statistics. */ 685*e4b17023SJohn Marino struct linemap_stats 686*e4b17023SJohn Marino { 687*e4b17023SJohn Marino long num_ordinary_maps_allocated; 688*e4b17023SJohn Marino long num_ordinary_maps_used; 689*e4b17023SJohn Marino long ordinary_maps_allocated_size; 690*e4b17023SJohn Marino long ordinary_maps_used_size; 691*e4b17023SJohn Marino long num_expanded_macros; 692*e4b17023SJohn Marino long num_macro_tokens; 693*e4b17023SJohn Marino long num_macro_maps_used; 694*e4b17023SJohn Marino long macro_maps_allocated_size; 695*e4b17023SJohn Marino long macro_maps_used_size; 696*e4b17023SJohn Marino long macro_maps_locations_size; 697*e4b17023SJohn Marino long duplicated_macro_maps_locations_size; 698*e4b17023SJohn Marino }; 699*e4b17023SJohn Marino 700*e4b17023SJohn Marino /* Compute and return statistics about the memory consumption of some 701*e4b17023SJohn Marino parts of the line table SET. */ 702*e4b17023SJohn Marino void linemap_get_statistics (struct line_maps *, struct linemap_stats *); 703*e4b17023SJohn Marino 704*e4b17023SJohn Marino /* Dump debugging information about source location LOC into the file 705*e4b17023SJohn Marino stream STREAM. SET is the line map set LOC comes from. */ 706*e4b17023SJohn Marino void linemap_dump_location (struct line_maps *, source_location, FILE *); 707*e4b17023SJohn Marino 708*e4b17023SJohn Marino /* Dump line map at index IX in line table SET to STREAM. If STREAM 709*e4b17023SJohn Marino is NULL, use stderr. IS_MACRO is true if the caller wants to 710*e4b17023SJohn Marino dump a macro map, false otherwise. */ 711*e4b17023SJohn Marino void linemap_dump (FILE *, struct line_maps *, unsigned, bool); 712*e4b17023SJohn Marino 713*e4b17023SJohn Marino /* Dump line table SET to STREAM. If STREAM is NULL, stderr is used. 714*e4b17023SJohn Marino NUM_ORDINARY specifies how many ordinary maps to dump. NUM_MACRO 715*e4b17023SJohn Marino specifies how many macro maps to dump. */ 716*e4b17023SJohn Marino void line_table_dump (FILE *, struct line_maps *, unsigned int, unsigned int); 717*e4b17023SJohn Marino 718*e4b17023SJohn Marino #endif /* !LIBCPP_LINE_MAP_H */ 719