GCC Middle and Back End API Reference
input.h File Reference
#include "line-map.h"
Include dependency graph for input.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  char_span
 
class  file_cache
 
struct  file_cache::input_context
 
class  string_concat
 
class  string_concat_db
 

Macros

#define UNKNOWN_LOCATION   ((location_t) 0)
 
#define BUILTINS_LOCATION   ((location_t) 1)
 
#define location_hash   int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION>
 
#define LOCATION_FILE(LOC)   ((expand_location (LOC)).file)
 
#define LOCATION_LINE(LOC)   ((expand_location (LOC)).line)
 
#define LOCATION_COLUMN(LOC)   ((expand_location (LOC)).column)
 
#define LOCATION_LOCUS(LOC)
 
#define LOCATION_BLOCK(LOC)
 
#define RESERVED_LOCATION_P(LOC)    (LOCATION_LOCUS (LOC) < RESERVED_LOCATION_COUNT)
 

Functions

const charspecial_fname_builtin ()
 
 STATIC_ASSERT (BUILTINS_LOCATION< RESERVED_LOCATION_COUNT)
 
bool is_location_from_builtin_token (location_t)
 
expanded_location expand_location (location_t)
 
int location_compute_display_column (file_cache &fc, expanded_location exploc, const cpp_char_column_policy &policy)
 
charget_source_text_between (file_cache &, location_t, location_t)
 
expanded_location expand_location_to_spelling_point (location_t, enum location_aspect aspect=LOCATION_ASPECT_CARET)
 
location_t expansion_point_location_if_in_system_header (location_t)
 
location_t expansion_point_location (location_t)
 
location_t location_with_discriminator (location_t, int)
 
bool has_discriminator (location_t)
 
int get_discriminator_from_loc (location_t)
 
int in_system_header_at (location_t loc)
 
bool from_macro_expansion_at (location_t loc)
 
bool from_macro_definition_at (location_t loc)
 
location_t get_pure_location (location_t loc)
 
location_t get_start (location_t loc)
 
location_t get_finish (location_t loc)
 
location_t make_location (location_t caret, location_t start, location_t finish)
 
location_t make_location (location_t caret, source_range src_range)
 
void dump_line_table_statistics (void)
 
void dump_location_info (FILE *stream)
 

Variables

class line_mapsline_table
 
class line_mapssaved_line_table
 
location_t input_location
 

Macro Definition Documentation

◆ BUILTINS_LOCATION

◆ LOCATION_BLOCK

◆ LOCATION_COLUMN

◆ LOCATION_FILE

◆ location_hash

#define location_hash   int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION>
Hasher for 'location_t' values satisfying '!RESERVED_LOCATION_P', thus able
to use 'UNKNOWN_LOCATION'/'BUILTINS_LOCATION' as spare values for
'Empty'/'Deleted'.   
Per PR103157 "'gengtype': 'typedef' causing infinite-recursion code to be
  generated", don't use
      typedef int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION>
        location_hash;
  here.

  It works for a single-use case, but when using a 'struct'-based variant
      struct location_hash
        : int_hash<location_t, UNKNOWN_LOCATION, BUILTINS_LOCATION> {};
  in more than one place, 'gengtype' generates duplicate functions (thus:
  "error: redefinition of 'void gt_ggc_mx(location_hash&)'" etc.).
  Attempting to mark that one up with GTY options, we run into a 'gengtype'
  "parse error: expected '{', have '<'", which probably falls into category
  "understanding of C++ is limited", as documented in 'gcc/doc/gty.texi'.

  Thus, use a plain ol' '#define':

Referenced by output_line_directive().

◆ LOCATION_LINE

◆ LOCATION_LOCUS

◆ RESERVED_LOCATION_P

◆ UNKNOWN_LOCATION

#define UNKNOWN_LOCATION   ((location_t) 0)
A value which will never be used to represent a real location.   

Referenced by simple_diagnostic_path::add_event(), add_exit_phi(), add_field_for_name(), add_linkage_name(), add_successor_phi_arg(), add_taskreg_looptemp_clauses(), simple_diagnostic_path::add_thread_event(), add_type_duplicate(), adjust_assumption_stmt_r(), analyze_access_subtree(), analyze_functions(), and_comparisons_1(), asan_add_global(), asan_finish_file(), asan_global_struct(), assign_discriminator(), assign_discriminators(), dump_context::begin_scope(), build_and_jump(), build_asan_poison_call_expr(), build_call_expr(), build_cltz_expr(), build_complex_type(), build_constant_desc(), build_cxa_dtor_registrations(), build_dso_handle_decl(), build_instrumentation_call(), build_libfunc_function_visibility(), build_personality_function(), build_popcount_expr(), build_translation_unit_decl(), can_assign_to_reg_without_clobbers_p(), cfg_layout_merge_blocks(), rt_bb_visited::check(), check_offload_target_name(), diagnostic_option_classifier::classify_diagnostic(), clear_padding_flush(), clear_type_padding_in_mask(), collect_fallthrough_labels(), ipa_param_body_adjustments::common_initialization(), connect_loop_phis(), const_ok_for_output_1(), const_unop(), construct_exit_block(), convert_if_conditions_to_switch(), convert_nl_goto_reference(), function_reader::create_function(), create_ifn_alias_checks(), create_iv(), create_new_ivs(), create_odr_indicator(), create_tailcall_accumulator(), debug(), debug(), decl_value_expr_insert(), default_emutls_var_fields(), default_external_stack_protect_fail(), default_hidden_stack_protect_fail(), default_stack_protect_guard(), ana::exploded_graph::detect_infinite_loops(), diag_returned_locals(), do_self_spec(), do_spec_1(), driver::do_spec_on_infiles(), dot_slp_tree(), driver_handle_option(), dump_final_callee_vcg(), dump_gimple_bb_header(), dump_implicit_edges(), dump_scope_block(), dw2_output_indirect_constant_1(), edge_before_returns_twice_call(), elim_create(), elim_graph_remove_succ_edge(), eliminate_build(), dump_pretty_printer::emit_any_pending_textual_chunks(), emit_library_call_value_1(), emit_post_landing_pad(), format_string_diagnostic_t::emit_warning_n_va(), enable_disable_pass(), execute_fixup_cfg(), execute_oacc_device_lower(), execute_sm_if_changed(), expand_asm_memory_blockage(), expand_asm_reg_clobber_mem_blockage(), expand_builtin_strnlen(), expand_call_inline(), expand_complex_multiplication(), expand_doubleword_mod(), expand_expr_real_gassign(), expand_FALLTHROUGH(), expand_FALLTHROUGH_r(), expand_gimple_basic_block(), expand_gimple_cond(), expand_location_1(), expand_omp_for_generic(), expand_omp_for_static_chunk(), expand_omp_for_static_nochunk(), expand_omp_simd(), expand_omp_target(), expand_parallel_call(), expand_teams_call(), expr_expected_value_1(), expr_location_or(), finish_options(), tree_switch_conversion::switch_conversion::fix_phi_nodes(), tree_switch_conversion::switch_decision_tree::fix_phi_operands_for_edges(), fixup_reorder_chain(), fold_builtin_strlen(), force_gimple_operand_1(), tree_switch_conversion::switch_conversion::gen_inbound_check(), gen_parallel_loop(), general_init(), get_base_for_alignment_1(), get_emutls_object_type(), autofdo::get_inline_stack(), get_lineno(), get_location(), get_location(), text_info::get_location(), get_or_alloc_expr_for_constant(), get_or_alloc_expr_for_name(), autofdo::get_relative_location_for_stmt(), get_substring_ranges_for_loc(), gimple_block_label(), gimple_build(), gimple_build(), gimple_build(), gimple_build_round_up(), gimple_build_vector(), gimple_build_vector_from_val(), gimple_can_merge_blocks_p(), gimple_convert(), gimple_convert_to_ptrofftype(), gimple_has_location(), gimple_ic(), gimple_init_gcov_profiler(), gimple_location_safe(), gimple_lower_bitint(), gimple_make_forwarder_block(), gimple_or_expr_nonartificial_location(), gimple_phi_arg_has_location(), gimple_set_location(), gimple_simplify_phiopt(), gimple_stringop_fixed_value(), gimplify_adjust_omp_clauses(), gimplify_cond_expr(), gimplify_expr(), gimplify_init_ctor_eval_range(), gimplify_loop_expr(), gimplify_omp_depend(), gimplify_omp_for(), gimplify_omp_loop(), gimplify_switch_expr(), handle_abnormal_edges(), strlen_pass::handle_builtin_stxncpy_strncat(), has_location(), hash_memrefs_baserefs_and_store_DRs_read_written_info(), hoist_guard(), access_ref::inform_access(), init_asm_output(), init_ic_make_global_vars(), diagnostic_context::initialize(), initialize_root_vars(), initialize_root_vars_lm(), initialize_root_vars_store_elim_2(), inline_read_section(), inlined_function_outer_scope_p(), optrecord_json_writer::inlining_chain_to_json(), input_offload_tables(), input_phi(), rt_bb_visited::insert_exit_check_on_edge(), insert_into_preds_of_block(), insert_phi_nodes_for(), INSN_HAS_LOCATION(), insn_locations_finalize(), insn_locations_init(), instrument_derefs(), instrument_nonnull_arg(), instrument_nonnull_return(), instrument_object_size(), ipa_read_jump_function(), ipa_write_jump_function(), json_from_location_range(), optrecord_json_writer::location_to_json(), location_with_discriminator(), lower_builtin_posix_memalign(), lower_catch(), lower_depend_clauses(), lower_eh_filter(), lower_function_body(), lower_gimple_return(), lower_lastprivate_clauses(), lower_lastprivate_conditional_clauses(), lower_omp_1(), lower_omp_for(), lower_omp_for_scan(), lower_omp_ordered(), lower_omp_scope(), lower_omp_sections(), lower_omp_target(), lower_omp_task_reductions(), lower_rec_input_clauses(), lower_reduction_clauses(), lower_transaction(), lower_try_finally_dup_block(), lower_try_finally_onedest(), lto_end_uncompression(), lto_input_mode_table(), lto_input_ts_function_decl_tree_pointers(), toplev::main(), make_forwarders_with_degenerate_phis(), make_item_for_dump_dec(), make_item_for_dump_generic_expr(), make_phi_node(), maybe_add_implicit_barrier_cancel(), maybe_move_debug_stmts_to_successors(), maybe_wrap_with_location(), move_block_to_fn(), new_label_mapper(), notice_source_line(), oacc_do_neutering(), oacc_entry_exit_single_gang(), oacc_parse_default_dims(), odr_types_equivalent_p(), omp_finish_file(), optimize_mask_stores(), optrecord_json_writer::optinfo_to_json(), or_comparisons_1(), output_comp_unit(), output_node_opt_summary(), pack_ts_block_value_fields(), function_reader::parse_mem_expr(), parse_N_M(), partition_alloc(), prepare_call_address(), print_ignored_options(), print_lto_docs_link(), rtx_writer::print_rtx_operand_code_i(), process_command(), process_options(), prune_expr_location(), push_dummy_function(), autofdo::autofdo_source_profile::read(), reemit_insn_block_notes(), remap_location(), remove_unused_scope_block_p(), replace_block_by(), reserve_phi_args_for_new_edge(), rewrite_add_phi_arguments(), rewrite_update_phi_arguments(), rexpr_has_location(), rtl_merge_blocks(), toplev::run_self_tests(), scan_omp_parallel(), scan_omp_simd(), scan_omp_simd_scan(), self_referential_size(), separate_decls_in_region(), sese_add_exit_phis_edge(), set_stack_check_libfunc(), simd_clone_adjust(), simd_clone_adjust_argument_types(), simplify_using_ranges::simplify(), simplify_vector_constructor(), sink_common_stores_to_bb(), sjlj_emit_dispatch_table(), slpeel_tree_duplicate_loop_to_edge_cfg(), split_function(), starts_infinite_loop_p(), streamer_alloc_tree(), ter_is_replaceable_p(), transform_to_exit_first_loop(), transform_to_exit_first_loop_alt(), tree_forwarder_block_p(), tree_function_versioning(), tree_inlined_location(), tree_ssa_iv_optimize_loop(), tree_transform_and_unroll_loop(), try_forward_edges(), try_transform_to_exit_first_loop_alt(), try_vectorize_loop_1(), ubsan_create_data(), ubsan_expand_vptr_ifn(), ubsan_get_source_location_type(), ubsan_get_type_descriptor_type(), ubsan_instrument_float_cast(), ubsan_type_descriptor(), ubsan_use_new_style_p(), unique_locus_on_edge_between_p(), use_new_line(), binary_op_rich_location::use_operator_loc_p(), vect_create_epilog_for_reduction(), vect_do_peeling(), vect_get_main_loop_result(), vect_loop_versioning(), vect_set_loop_condition_normal(), vect_set_loop_condition_partial_vectors_avx512(), vect_set_loop_control(), vect_setup_realignment(), vect_slp_bbs(), vect_transform_cycle_phi(), vectorizable_induction(), vectorizable_lc_phi(), vectorizable_load(), vectorizable_nonlinear_induction(), vectorizable_phi(), vectorizable_recurr(), vectorizable_simd_clone_call(), verify_gimple_in_cfg(), warn_implicit_fallthrough_r(), warn_types_mismatch(), warn_uninit(), warn_uninit_phi_uses(), warn_uninitialized_phi(), worker_single_copy(), worker_single_simple(), and optrecord_json_writer::write().

Function Documentation

◆ dump_line_table_statistics()

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.   

References ggc_alloc(), line_table, PRsa, and SIZE_AMOUNT.

Referenced by dump_memory_report().

◆ dump_location_info()

void dump_location_info ( FILE * stream)
Write a visualization of the locations in the line_table to STREAM.   

References dump_labelled_location_range(), dump_location_range(), gcc_assert, get_end_location(), ggc_alloc(), i, inform(), line_table, map, num_digits(), UINT_MAX, write_digit_row(), and y.

Referenced by compile_file().

◆ expand_location()

◆ expand_location_to_spelling_point()

expanded_location expand_location_to_spelling_point ( location_t loc,
enum location_aspect aspect )
extern
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 expand_location_1(), ggc_alloc(), and line_table.

Referenced by get_source_text_between(), get_substring_ranges_for_loc(), and maybe_unwind_expanded_macro_loc().

◆ expansion_point_location()

location_t expansion_point_location ( location_t location)
extern
If LOCATION is a virtual location for a token coming from the expansion
of a macro, unwind to the location of the expansion point of the macro.   

References ggc_alloc(), line_table, and NULL.

◆ expansion_point_location_if_in_system_header()

location_t expansion_point_location_if_in_system_header ( location_t location)
extern
If LOCATION is in a system header and if it is a virtual location
for a token coming from the expansion of a macro, unwind it to
the location of the expansion point of the macro.  If the expansion
point is also in a system header return the original LOCATION.
Otherwise, return the location of the expansion point.

This is used for instance when we want to emit diagnostics about a
token that may be located in a macro that is itself defined in a
system header, for example, for the NULL macro.  In such a case, if
LOCATION were passed directly to diagnostic functions such as
warning_at, the diagnostic would be suppressed (unless
-Wsystem-headers).   

References ggc_alloc(), in_system_header_at(), line_table, and NULL.

Referenced by pass_walloca::execute(), gimple_or_expr_nonartificial_location(), gimplify_va_arg_expr(), set_inlining_locations(), tree_inlined_location(), and warn_string_no_nul().

◆ from_macro_definition_at()

bool from_macro_definition_at ( location_t loc)
inline
Return true if LOCATION is the locus of a token that comes from
a macro definition, false otherwise.  This differs from from_macro_expansion_at
in its treatment of macro arguments, for which this returns false.   

References ggc_alloc(), and line_table.

◆ from_macro_expansion_at()

bool from_macro_expansion_at ( location_t loc)
inline
Return true if LOCATION is the locus of a token that
comes from a macro expansion, false otherwise.   

References ggc_alloc(), and line_table.

◆ get_discriminator_from_loc()

int get_discriminator_from_loc ( location_t locus)
extern

◆ get_finish()

location_t get_finish ( location_t loc)
inline

◆ get_pure_location()

◆ get_source_text_between()

char * get_source_text_between ( file_cache & fc,
location_t start,
location_t end )
extern
Return a NUL-terminated copy of the source text between two locations, or
NULL if the arguments are invalid.  The caller is responsible for freeing
the return value.   

References end(), expand_location_to_spelling_point(), char_span::get_buffer(), ggc_alloc(), char_span::length(), NULL, obstack, char_span::subspan(), and char_span::xstrdup().

◆ get_start()

◆ has_discriminator()

bool has_discriminator ( location_t locus)
extern
Return TRUE if LOCUS represents a location with a discriminator.   

References get_discriminator_from_loc().

Referenced by assign_discriminators().

◆ in_system_header_at()

int in_system_header_at ( location_t loc)
inline
Return a positive value if LOCATION is the locus of a token that is
located in a system header, O otherwise. It returns 1 if LOCATION
is the locus of a token that is located in a system header, and 2
if LOCATION is the locus of a token located in a C system header
that therefore needs to be extern "C" protected in C++.

Note that this function returns 1 if LOCATION belongs to a token
that is part of a macro replacement-list defined in a system
header, but expanded in a non-system file.   

References ggc_alloc(), and line_table.

Referenced by expansion_point_location_if_in_system_header(), diagnostic_context::get_any_inlining_info(), and set_inlining_locations().

◆ is_location_from_builtin_token()

bool is_location_from_builtin_token ( location_t loc)
extern
Test if the location originates from the spelling location of a
builtin-tokens.  That is, return TRUE if LOC is a (possibly
virtual) location of a built-in token that appears in the expansion
list of a macro.  Please note that this function also works on
tokens that result from built-in tokens.  For instance, the
function would return true if passed a token "4" that is the result
of the expansion of the built-in __LINE__ macro.   

References BUILTINS_LOCATION, ggc_alloc(), line_table, map, and NULL.

◆ location_compute_display_column()

int location_compute_display_column ( file_cache & fc,
expanded_location exploc,
const cpp_char_column_policy & policy )
extern
An expanded_location stores the column in byte units.  This function
converts that column to display units.  That requires reading the associated
source line in order to calculate the display width.  If that cannot be done
for any reason, then returns the byte column as a fallback.   

References char_span::get_buffer(), ggc_alloc(), and char_span::length().

Referenced by convert_column_unit(), and sarif_builder::get_sarif_column().

◆ location_with_discriminator()

location_t location_with_discriminator ( location_t locus,
int discriminator )
extern
Associate the DISCRIMINATOR with LOCUS, and return a new locus.  

References get_pure_location(), ggc_alloc(), line_table, LOCATION_BLOCK, and UNKNOWN_LOCATION.

Referenced by lto_location_cache::apply_location_cache(), assign_discriminator(), and assign_discriminators().

◆ make_location() [1/2]

location_t make_location ( location_t caret,
location_t start,
location_t finish )
extern
Construct a location with caret at CARET, ranging from START to
FINISH.

For example, consider:

              11111111112
     12345678901234567890
  522
  523   return foo + bar;
               ~~~~^~~~~
  524

The location's caret is at the "+", line 523 column 15, but starts
earlier, at the "f" of "foo" at column 11.  The finish is at the "r"
of "bar" at column 19.   

References ggc_alloc(), and line_table.

Referenced by get_location_within_string().

◆ make_location() [2/2]

location_t make_location ( location_t caret,
source_range src_range )
extern
Same as above, but taking a source range rather than two locations.   

References get_pure_location(), ggc_alloc(), and line_table.

◆ special_fname_builtin()

const char * special_fname_builtin ( )
Returns the translated string referring to the special location.   

References _.

Referenced by expand_location_1(), and diagnostic_context::get_location_text().

◆ STATIC_ASSERT()

STATIC_ASSERT ( )
line-map.cc reserves RESERVED_LOCATION_COUNT to the user.  Ensure
both UNKNOWN_LOCATION and BUILTINS_LOCATION fit into that.   

Variable Documentation

◆ input_location

location_t input_location
extern
Current position in real source file.   

Referenced by add_new_plugin(), add_sysrooted_hdrs_prefix(), add_sysrooted_prefix(), cgraph_node::analyze(), analyze_functions(), asan_global_struct(), asm_clobber_reg_is_valid(), assign_assembler_name_if_needed(), build_cxa_dtor_registrations(), build_fn_decl(), c_strlen(), cgraph_build_static_cdtor_1(), check_global_declaration(), close_at_file(), collect_execute(), collect_wait(), compare_debug_dump_opt_spec_function(), compare_debug_self_opt_spec_function(), compare_version_strings(), compile_images_for_offload_targets(), compile_offload_image(), compute_branch_probabilities(), construct_exit_block(), copy_file(), copy_phis_for_bb(), create_tmp_var_raw(), cgraph_node::create_version_clone_with_body(), debug_level_greater_than_spec_func(), decl_attributes(), default_plugin_dir_name(), do_merge(), do_merge_stream(), do_rewrite(), do_self_spec(), do_spec_1(), do_wait(), driver_handle_option(), dumps_spec_func(), dwarf_version_greater_than_spec_func(), dynamic_object_sizes_execute_one(), error(), eval_spec_function(), execute(), cgraph_node::expand(), expand_asm_stmt(), expand_call_inline(), expand_function_end(), expand_gimple_stmt(), expand_ifn_va_arg_1(), expand_omp(), expand_thunk(), finalize(), finalize_record_size(), find_crtoffloadtable(), fixup_call_stmt_edges_1(), fold_builtin_next_arg(), fold_builtin_strlen(), fold_undefer_overflow_warnings(), force_gimple_operand_1(), gcov_output_files(), general_init(), varpool_node::get_constructor(), get_coverage_counts(), get_file_function_name(), cgraph_node::get_untransformed_body(), getenv_spec_function(), ggc_pch_finish(), ggc_pch_read(), ggc_pch_write_object(), gimplify_adjust_omp_clauses_1(), gimplify_asm_expr(), gimplify_body(), gimplify_call_expr(), gimplify_expr(), gimplify_omp_for(), gimplify_omp_taskloop_expr(), driver::global_initializations(), gt_pch_restore(), gt_pch_save(), handle_braces(), handle_ignored_attributes_option(), handle_spec_function(), input_offload_tables(), input_symtab(), instrument_object_size(), internal_error(), internal_error_no_backtrace(), internal_get_tmp_var(), ipa_fn_summary_read(), ipa_reference_read_optimization_summary(), lang_dependent_init(), load_specs(), location_for_asm(), lookup_compiler(), lower_omp(), lower_omp_1(), lto_check_version(), lto_section_overrun(), lto_value_range_error(), main(), main(), make_node(), driver::maybe_print_and_exit(), driver::maybe_run_linker(), maybe_run_lto_and_relink(), maybe_unlink(), merge_and_complain(), merge_profile_summaries(), new_omp_context(), open_at_file(), open_auxiliary_file(), open_graph_file(), used_arg_t::operator()(), parse_options_from_collect_gcc_options(), place_field(), driver::prepare_infiles(), print_multilib_info(), process_brace_body(), process_command(), process_options(), read_specs(), gcc::pass_manager::register_pass(), remap_gimple_stmt(), run_attempt(), run_gcc(), toplev::run_self_tests(), scan_omp(), scan_omp_1_stmt(), scan_prog_file(), self_referential_size(), set_multilib_dir(), setup_core_dumping(), shortcut_cond_expr(), size_in_bytes(), sorry(), std_gimplify_va_arg_expr(), thunk_adjust(), tree_function_versioning(), ubsan_create_data(), ubsan_get_source_location_type(), ubsan_get_type_descriptor_type(), ubsan_instrument_float_cast(), unpack_ts_function_decl_value_fields(), version_compare_spec_function(), walk_gimple_stmt(), warning(), and write_pch_globals().

◆ line_table

◆ saved_line_table

class line_maps* saved_line_table
extern
A stashed copy of "line_table" for use by selftest::line_table_test.
This needs to be a global so that it can be a GC root, and thus
prevent the stashed copy from being garbage-collected if the GC runs
during a line_table_test.