GCC Middle and Back End API Reference
input.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "intl.h"
#include "input.h"
Include dependency graph for input.c:

Macros

#define ONE_K   1024
#define ONE_M   (ONE_K * ONE_K)
#define SCALE(x)
#define STAT_LABEL(x)   ((x) < 10 * ONE_K ? ' ' : ((x) < 10 * ONE_M ? 'k' : 'M'))
#define FORMAT_AMOUNT(size)   SCALE (size), STAT_LABEL (size)

Functions

static expanded_location expand_location_1 (source_location loc, bool expansion_point_p)
static const char * read_line ()
const char * location_get_source_line ()
expanded_location expand_location ()
expanded_location expand_location_to_spelling_point ()
source_location expansion_point_location_if_in_system_header ()
void dump_line_table_statistics ()

Variables

location_t input_location
struct line_maps * line_table

Macro Definition Documentation

#define FORMAT_AMOUNT (   size)    SCALE (size), STAT_LABEL (size)

Display an integer amount as multiple of 1K or 1M (in base 2). Display the correct unit (either k, M, or ' ') after the amout, as well.

#define ONE_K   1024
#define ONE_M   (ONE_K * ONE_K)
#define SCALE (   x)
Value:
((unsigned long) ((x) < 10 * ONE_K \
? (x) \
: ((x) < 10 * ONE_M \
? (x) / ONE_K \
: (x) / ONE_M)))

Display a number as an integer multiple of either:

  • 1024, if said integer is >= to 10 K (in base 2)
  • 1024 * 1024, if said integer is >= 10 M in (base 2)
#define STAT_LABEL (   x)    ((x) < 10 * ONE_K ? ' ' : ((x) < 10 * ONE_M ? 'k' : 'M'))

For a given integer, display either:

  • the character 'k', if the number is higher than 10 K (in base 2) but strictly lower than 10 M (in base 2)
  • the character 'M' if the number is higher than 10 M (in base2)
  • the charcter ' ' if the number is strictly lower than 10 K

Function Documentation

void dump_line_table_statistics ( void  )

Dump statistics to stderr about the memory usage of the line_table set of line maps. This also displays some statistics about macro expansion.

expanded_location expand_location ( )

Expand the source location LOC into a human readable location. If LOC is virtual, it resolves to the expansion point of the involved macro. If LOC resolves to a builtin location, the file name of the readable location is set to the string "<built-in>".

References expand_location_1().

Referenced by dump_omp_clauses(), dump_ssaname_info(), gen_array_type_die(), lhd_print_error_function(), pp_cfg_jump(), and process_switch().

static expanded_location expand_location_1 ( source_location  loc,
bool  expansion_point_p 
)
static

Expand the source location LOC into a human readable location. If LOC resolves to a builtin location, the file name of the readable location is set to the string "<built-in>". If EXPANSION_POINT_P is TRUE and LOC is virtual, then it is resolved to the expansion point of the involved macro. Otherwise, it is resolved to the spelling location of the token.

When resolving to the spelling location of the token, if the resulting location is for a built-in location (that is, it has no associated line/column) in the context of a macro expansion, the returned location is the first one (while unwinding the macro location towards its expansion point) that is in real source code.

We want to resolve LOC to its spelling location.

But if that spelling location is a reserved location that appears in the context of a macro expansion (like for a location for a built-in token), let's consider the first location (toward the expansion point) that is not reserved; that is, the first location that is in real source code.

References LOCATION_BLOCK, and LOCATION_LOCUS.

Referenced by expand_location().

expanded_location expand_location_to_spelling_point ( )

Expand the source location LOC into a human readable location. If LOC is virtual, it resolves to the expansion location of the relevant macro. If LOC resolves to a builtin location, the file name of the readable location is set to the string "<built-in>".

References in_system_header_at, line_table, and NULL.

Referenced by adjust_line().

source_location expansion_point_location_if_in_system_header ( )

If LOCATION is in a system header and if it's a virtual location for a token coming from the expansion of a macro M, unwind it to the location of the expansion point of M. Otherwise, just return LOCATION.

This is used for instance when we want to emit diagnostics about a token that is located in a macro that is itself defined in a system header – e.g for the NULL macro. In that case, if LOCATION is passed to diagnostics emitting functions like warning_at as is, no diagnostic won't be emitted.

const char* location_get_source_line ( )

Return the physical source line that corresponds to xloc in a buffer that is statically allocated. The newline is replaced by the null character.

Referenced by adjust_line().

static const char* read_line ( )
static

Reads one line from file into a static buffer.


Variable Documentation

location_t input_location

Data and functions related to line maps and input files. Copyright (C) 2004-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Current position in real source file.

Referenced by create_tmp_var_name(), diagnostic_for_asm(), emit_diagnostic(), gimplify_expr(), number_of_iterations_exit(), permerror(), read_profile_edge_counts(), thunk_adjust(), vrp_initialize(), and wrapup_global_declarations().

struct line_maps* line_table

Declarations for variables relating to reading the source file. Used by parsers, lexical analyzers, and error message routines. Copyright (C) 1993-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

Referenced by diagnostic_report_current_module(), expand_location_to_spelling_point(), and signed_or_unsigned_type_for().