Historically GCC used location_t, while libcpp used source_location.
This inconsistency has been annoying me for a while, so this patch
removes source_location in favor of location_t throughout
(as the latter is shorter).
gcc/ChangeLog:
* builtins.c: Replace "source_location" with "location_t".
* diagnostic-show-locus.c: Likewise.
* diagnostic.c: Likewise.
* dumpfile.c: Likewise.
* gcc-rich-location.h: Likewise.
* genmatch.c: Likewise.
* gimple.h: Likewise.
* gimplify.c: Likewise.
* input.c: Likewise.
* input.h: Likewise. Eliminate the typedef.
* omp-expand.c: Likewise.
* selftest.h: Likewise.
* substring-locations.h (get_source_location_for_substring):
Rename to..
(get_location_within_string): ...this.
* tree-cfg.c: Replace "source_location" with "location_t".
* tree-cfgcleanup.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-into-ssa.c: Likewise.
* tree-outof-ssa.c: Likewise.
* tree-parloops.c: Likewise.
* tree-phinodes.c: Likewise.
* tree-phinodes.h: Likewise.
* tree-ssa-loop-ivopts.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-phiprop.c: Likewise.
* tree-ssa-threadupdate.c: Likewise.
* tree-ssa.c: Likewise.
* tree-ssa.h: Likewise.
* tree-vect-loop-manip.c: Likewise.
gcc/c-family/ChangeLog:
* c-common.c (c_get_substring_location): Update for renaming of
get_source_location_for_substring to get_location_within_string.
* c-lex.c: Replace "source_location" with "location_t".
* c-opts.c: Likewise.
* c-ppoutput.c: Likewise.
gcc/c/ChangeLog:
* c-decl.c: Replace "source_location" with "location_t".
* c-tree.h: Likewise.
* c-typeck.c: Likewise.
* gimple-parser.c: Likewise.
gcc/cp/ChangeLog:
* call.c: Replace "source_location" with "location_t".
* cp-tree.h: Likewise.
* cvt.c: Likewise.
* name-lookup.c: Likewise.
* parser.c: Likewise.
* typeck.c: Likewise.
gcc/fortran/ChangeLog:
* cpp.c: Replace "source_location" with "location_t".
* gfortran.h: Likewise.
gcc/go/ChangeLog:
* go-gcc-diagnostics.cc: Replace "source_location" with "location_t".
* go-gcc.cc: Likewise.
* go-linemap.cc: Likewise.
* go-location.h: Likewise.
* gofrontend/README: Likewise.
gcc/jit/ChangeLog:
* jit-playback.c: Replace "source_location" with "location_t".
gcc/testsuite/ChangeLog:
* g++.dg/plugin/comment_plugin.c: Replace "source_location" with
"location_t".
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise.
libcc1/ChangeLog:
* libcc1plugin.cc: Replace "source_location" with "location_t".
(plugin_context::get_source_location): Rename to...
(plugin_context::get_location_t): ...this.
* libcp1plugin.cc: Likewise.
libcpp/ChangeLog:
* charset.c: Replace "source_location" with "location_t".
* directives-only.c: Likewise.
* directives.c: Likewise.
* errors.c: Likewise.
* expr.c: Likewise.
* files.c: Likewise.
* include/cpplib.h: Likewise. Rename MAX_SOURCE_LOCATION to
MAX_LOCATION_T.
* include/line-map.h: Likewise.
* init.c: Likewise.
* internal.h: Likewise.
* lex.c: Likewise.
* line-map.c: Likewise.
* location-example.txt: Likewise.
* macro.c: Likewise.
* pch.c: Likewise.
* traditional.c: Likewise.
From-SVN: r266085
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * builtins.c: Replace "source_location" with "location_t".
+ * diagnostic-show-locus.c: Likewise.
+ * diagnostic.c: Likewise.
+ * dumpfile.c: Likewise.
+ * gcc-rich-location.h: Likewise.
+ * genmatch.c: Likewise.
+ * gimple.h: Likewise.
+ * gimplify.c: Likewise.
+ * input.c: Likewise.
+ * input.h: Likewise. Eliminate the typedef.
+ * omp-expand.c: Likewise.
+ * selftest.h: Likewise.
+ * substring-locations.h (get_source_location_for_substring):
+ Rename to..
+ (get_location_within_string): ...this.
+ * tree-cfg.c: Replace "source_location" with "location_t".
+ * tree-cfgcleanup.c: Likewise.
+ * tree-diagnostic.c: Likewise.
+ * tree-into-ssa.c: Likewise.
+ * tree-outof-ssa.c: Likewise.
+ * tree-parloops.c: Likewise.
+ * tree-phinodes.c: Likewise.
+ * tree-phinodes.h: Likewise.
+ * tree-ssa-loop-ivopts.c: Likewise.
+ * tree-ssa-loop-manip.c: Likewise.
+ * tree-ssa-phiopt.c: Likewise.
+ * tree-ssa-phiprop.c: Likewise.
+ * tree-ssa-threadupdate.c: Likewise.
+ * tree-ssa.c: Likewise.
+ * tree-ssa.h: Likewise.
+ * tree-vect-loop-manip.c: Likewise.
+
2018-11-13 Michael Ploujnikov <michael.ploujnikov@oracle.com>
* doc/extend.texi: Fix typo in the weakref description.
{
rtx op;
unsigned HOST_WIDE_INT val;
- source_location loc
+ location_t loc
= expansion_point_location_if_in_system_header (input_location);
/* If the parameter is not a constant, it's a run time value so we'll just
enum memmodel success, failure;
tree weak;
bool is_weak;
- source_location loc
+ location_t loc
= expansion_point_location_if_in_system_header (input_location);
success = get_memmodel (CALL_EXPR_ARG (exp, 4));
enum memmodel success, failure;
tree lhs;
bool is_weak;
- source_location loc
+ location_t loc
= expansion_point_location_if_in_system_header (gimple_location (call));
success = get_memmodel (gimple_call_arg (call, 4));
model = get_memmodel (CALL_EXPR_ARG (exp, 1));
if (is_mm_release (model) || is_mm_acq_rel (model))
{
- source_location loc
+ location_t loc
= expansion_point_location_if_in_system_header (input_location);
warning_at (loc, OPT_Winvalid_memory_model,
"invalid memory model for %<__atomic_load%>");
if (!(is_mm_relaxed (model) || is_mm_seq_cst (model)
|| is_mm_release (model)))
{
- source_location loc
+ location_t loc
= expansion_point_location_if_in_system_header (input_location);
warning_at (loc, OPT_Winvalid_memory_model,
"invalid memory model for %<__atomic_store%>");
if (is_mm_consume (model) || is_mm_acquire (model) || is_mm_acq_rel (model))
{
- source_location loc
+ location_t loc
= expansion_point_location_if_in_system_header (input_location);
warning_at (loc, OPT_Winvalid_memory_model,
"invalid memory model for %<__atomic_store%>");
definition of the va_start macro (perhaps on the token for
builtin) in a system header, so warnings will not be emitted.
Use the location in real source code. */
- source_location current_location =
+ location_t current_location =
linemap_unwind_to_first_non_reserved_loc (line_table, input_location,
NULL);
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * c-common.c (c_get_substring_location): Update for renaming of
+ get_source_location_for_substring to get_location_within_string.
+ * c-lex.c: Replace "source_location" with "location_t".
+ * c-opts.c: Likewise.
+ * c-ppoutput.c: Likewise.
+
2018-11-13 Martin Sebor <msebor@redhat.com>
PR middle-end/81824
if (tok_type == CPP_OTHER)
return "unrecognized string type";
- return get_source_location_for_substring (parse_in, g_string_concat_db,
- substr_loc.get_fmt_string_loc (),
- tok_type,
- substr_loc.get_caret_idx (),
- substr_loc.get_start_idx (),
- substr_loc.get_end_idx (),
- out_loc);
+ return get_location_within_string (parse_in, g_string_concat_db,
+ substr_loc.get_fmt_string_loc (),
+ tok_type,
+ substr_loc.get_caret_idx (),
+ substr_loc.get_start_idx (),
+ substr_loc.get_end_idx (),
+ out_loc);
}
\f
}
static void
-cb_def_pragma (cpp_reader *pfile, source_location loc)
+cb_def_pragma (cpp_reader *pfile, location_t loc)
{
/* Issue a warning message if we have been asked to do so. Ignore
unknown pragmas in system headers unless an explicit
/* #define callback for DWARF and DWARF2 debug info. */
static void
-cb_define (cpp_reader *pfile, source_location loc, cpp_hashnode *node)
+cb_define (cpp_reader *pfile, location_t loc, cpp_hashnode *node)
{
const struct line_map *map = linemap_lookup (line_table, loc);
(*debug_hooks->define) (SOURCE_LINE (linemap_check_ordinary (map), loc),
/* #undef callback for DWARF and DWARF2 debug info. */
static void
-cb_undef (cpp_reader * ARG_UNUSED (pfile), source_location loc,
+cb_undef (cpp_reader * ARG_UNUSED (pfile), location_t loc,
cpp_hashnode *node)
{
const struct line_map *map = linemap_lookup (line_table, loc);
cb_file_change (parse_in, bltin_map);
/* Make sure all of the builtins about to be declared have
- BUILTINS_LOCATION has their source_location. */
+ BUILTINS_LOCATION has their location_t. */
cpp_force_token_locations (parse_in, BUILTINS_LOCATION);
cpp_init_builtins (parse_in, flag_hosted);
static int dump_macro (cpp_reader *, cpp_hashnode *, void *);
static void dump_queued_macros (cpp_reader *);
-static bool print_line_1 (source_location, const char*, FILE *);
-static bool print_line (source_location, const char *);
-static bool maybe_print_line_1 (source_location, FILE *);
-static bool maybe_print_line (source_location);
+static bool print_line_1 (location_t, const char*, FILE *);
+static bool print_line (location_t, const char *);
+static bool maybe_print_line_1 (location_t, FILE *);
+static bool maybe_print_line (location_t);
static bool do_line_change (cpp_reader *, const cpp_token *,
- source_location, int);
+ location_t, int);
/* Callback routines for the parser. Most of these are active only
in specific modes. */
static void cb_line_change (cpp_reader *, const cpp_token *, int);
-static void cb_define (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_undef (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_used_define (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_used_undef (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_include (cpp_reader *, source_location, const unsigned char *,
+static void cb_define (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_undef (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_used_define (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_used_undef (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_include (cpp_reader *, location_t, const unsigned char *,
const char *, int, const cpp_token **);
-static void cb_ident (cpp_reader *, source_location, const cpp_string *);
-static void cb_def_pragma (cpp_reader *, source_location);
+static void cb_ident (cpp_reader *, location_t, const cpp_string *);
+static void cb_def_pragma (cpp_reader *, location_t);
static void cb_read_pch (cpp_reader *pfile, const char *name,
int fd, const char *orig_name);
print.source = NULL;
for (;;)
{
- source_location loc;
+ location_t loc;
const cpp_token *token = cpp_get_token_with_location (pfile, &loc);
if (token->type == CPP_PADDING)
return FALSE. */
static bool
-maybe_print_line_1 (source_location src_loc, FILE *stream)
+maybe_print_line_1 (location_t src_loc, FILE *stream)
{
bool emitted_line_marker = false;
int src_line = LOCATION_LINE (src_loc);
return FALSE. */
static bool
-maybe_print_line (source_location src_loc)
+maybe_print_line (location_t src_loc)
{
if (cpp_get_options (parse_in)->debug)
linemap_dump_location (line_table, src_loc,
was effectively emitted, return TRUE otherwise return FALSE. */
static bool
-print_line_1 (source_location src_loc, const char *special_flags, FILE *stream)
+print_line_1 (location_t src_loc, const char *special_flags, FILE *stream)
{
bool emitted_line_marker = false;
line marker was effectively emitted, FALSE otherwise. */
static bool
-print_line (source_location src_loc, const char *special_flags)
+print_line (location_t src_loc, const char *special_flags)
{
if (cpp_get_options (parse_in)->debug)
linemap_dump_location (line_table, src_loc,
Return TRUE if a line marker is emitted, FALSE otherwise. */
static bool
do_line_change (cpp_reader *pfile, const cpp_token *token,
- source_location src_loc, int parsing_args)
+ location_t src_loc, int parsing_args)
{
bool emitted_line_marker = false;
if (define_queue || undef_queue)
}
static void
-cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
const cpp_string *str)
{
maybe_print_line (line);
}
static void
-cb_define (cpp_reader *pfile, source_location line, cpp_hashnode *node)
+cb_define (cpp_reader *pfile, location_t line, cpp_hashnode *node)
{
const line_map_ordinary *map;
}
static void
-cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
cpp_hashnode *node)
{
maybe_print_line (line);
}
static void
-cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED,
+cb_used_define (cpp_reader *pfile, location_t line ATTRIBUTE_UNUSED,
cpp_hashnode *node)
{
if (cpp_user_macro_p (node))
static void
cb_used_undef (cpp_reader *pfile ATTRIBUTE_UNUSED,
- source_location line ATTRIBUTE_UNUSED,
+ location_t line ATTRIBUTE_UNUSED,
cpp_hashnode *node)
{
macro_queue *q;
}
static void
-cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
const unsigned char *dir, const char *header, int angle_brackets,
const cpp_token **comments)
{
/* Copy a #pragma directive to the preprocessed output. */
static void
-cb_def_pragma (cpp_reader *pfile, source_location line)
+cb_def_pragma (cpp_reader *pfile, location_t line)
{
maybe_print_line (line);
fputs ("#pragma ", print.outf);
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * c-decl.c: Replace "source_location" with "location_t".
+ * c-tree.h: Likewise.
+ * c-typeck.c: Likewise.
+ * gimple-parser.c: Likewise.
+
2018-11-09 Jakub Jelinek <jakub@redhat.com>
* c-parser.c (c_parser_omp_clause_final): Use
SPECS, returning SPECS. */
struct c_declspecs *
-declspecs_add_addrspace (source_location location,
+declspecs_add_addrspace (location_t location,
struct c_declspecs *specs, addr_space_t as)
{
specs->non_sc_seen_p = true;
returning SPECS. */
struct c_declspecs *
-declspecs_add_qual (source_location loc,
+declspecs_add_qual (location_t loc,
struct c_declspecs *specs, tree qual)
{
enum rid i;
declaration specifiers SPECS, returning SPECS. */
struct c_declspecs *
-declspecs_add_scspec (source_location loc,
+declspecs_add_scspec (location_t loc,
struct c_declspecs *specs,
tree scspec)
{
returning SPECS. */
struct c_declspecs *
-declspecs_add_attrs (source_location loc, struct c_declspecs *specs, tree attrs)
+declspecs_add_attrs (location_t loc, struct c_declspecs *specs, tree attrs)
{
specs->attrs = chainon (attrs, specs->attrs);
specs->locations[cdw_attributes] = loc;
alignment is ALIGN) to the declaration specifiers SPECS, returning
SPECS. */
struct c_declspecs *
-declspecs_add_alignas (source_location loc,
+declspecs_add_alignas (location_t loc,
struct c_declspecs *specs, tree align)
{
int align_log;
specifier is added, please update the enum c_declspec_word above
accordingly. */
struct c_declspecs {
- source_location locations[cdw_number_of_elements];
+ location_t locations[cdw_number_of_elements];
/* The type specified, if a single type specifier such as a struct,
union or enum specifier, typedef name or typeof specifies the
whole type, or NULL_TREE if none or a keyword such as "void" or
extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
struct c_declarator *);
extern struct c_declspecs *build_null_declspecs (void);
-extern struct c_declspecs *declspecs_add_qual (source_location,
+extern struct c_declspecs *declspecs_add_qual (location_t,
struct c_declspecs *, tree);
extern struct c_declspecs *declspecs_add_type (location_t,
struct c_declspecs *,
struct c_typespec);
-extern struct c_declspecs *declspecs_add_scspec (source_location,
+extern struct c_declspecs *declspecs_add_scspec (location_t,
struct c_declspecs *, tree);
-extern struct c_declspecs *declspecs_add_attrs (source_location,
+extern struct c_declspecs *declspecs_add_attrs (location_t,
struct c_declspecs *, tree);
-extern struct c_declspecs *declspecs_add_addrspace (source_location,
+extern struct c_declspecs *declspecs_add_addrspace (location_t,
struct c_declspecs *,
addr_space_t);
-extern struct c_declspecs *declspecs_add_alignas (source_location,
+extern struct c_declspecs *declspecs_add_alignas (location_t,
struct c_declspecs *, tree);
extern struct c_declspecs *finish_declspecs (struct c_declspecs *);
/* Use the location where a macro was expanded rather than where
it was defined to make sure macros defined in system headers
but used incorrectly elsewhere are diagnosed. */
- source_location exploc = expansion_point_location_if_in_system_header (loc);
+ location_t exploc = expansion_point_location_if_in_system_header (loc);
auto_diagnostic_group d;
va_list ap;
va_start (ap, gmsgid);
/* Use the location where a macro was expanded rather than where
it was defined to make sure macros defined in system headers
but used incorrectly elsewhere are diagnosed. */
- source_location exploc = expansion_point_location_if_in_system_header (loc);
+ location_t exploc = expansion_point_location_if_in_system_header (loc);
/* The gmsgid may be a format string with %< and %>. */
warned = warning_at (exploc, opt, gmsgid);
/* Use the expansion point to handle cases such as returning NULL
in a function returning void. */
- source_location xloc = expansion_point_location_if_in_system_header (loc);
+ location_t xloc = expansion_point_location_if_in_system_header (loc);
if (TREE_THIS_VOLATILE (current_function_decl))
warning_at (xloc, 0,
/* Use the expansion point to handle cases such as returning NULL
in a function returning void. */
- source_location xloc = expansion_point_location_if_in_system_header (loc);
+ location_t xloc = expansion_point_location_if_in_system_header (loc);
if (TREE_THIS_VOLATILE (current_function_decl))
warning_at (xloc, 0,
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * call.c: Replace "source_location" with "location_t".
+ * cp-tree.h: Likewise.
+ * cvt.c: Likewise.
+ * name-lookup.c: Likewise.
+ * parser.c: Likewise.
+ * typeck.c: Likewise.
+
2018-11-12 Jason Merrill <jason@redhat.com>
Implement P0315R4, Lambdas in unevaluated contexts.
if (null_node_p (expr) && TREE_CODE (totype) != BOOLEAN_TYPE
&& ARITHMETIC_TYPE_P (totype))
{
- source_location loc =
+ location_t loc =
expansion_point_location_if_in_system_header (input_location);
if (fn)
else if (null_ptr_cst_p (expr) &&
(TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype)))
{
- source_location loc =
+ location_t loc =
expansion_point_location_if_in_system_header (input_location);
maybe_warn_zero_as_null_pointer_constant (expr, loc);
}
/* va_arg (EXPR, TYPE) is a builtin. Make sure it is not abused. */
tree
-build_x_va_arg (source_location loc, tree expr, tree type)
+build_x_va_arg (location_t loc, tree expr, tree type)
{
if (processing_template_decl)
{
struct cp_decl_specifier_seq {
/* An array of locations for the declaration sepecifiers, indexed by
enum cp_decl_spec_word. */
- source_location locations[ds_last];
+ location_t locations[ds_last];
/* The primary type, if any, given by the decl-specifier-seq.
Modifiers, like "short", "const", and "unsigned" are not
reflected here. This field will be a TYPE, unless a typedef-name
extern tree convert_default_arg (tree, tree, tree, int,
tsubst_flags_t);
extern tree convert_arg_to_ellipsis (tree, tsubst_flags_t);
-extern tree build_x_va_arg (source_location, tree, tree);
+extern tree build_x_va_arg (location_t, tree, tree);
extern tree cxx_type_promotes_to (tree);
extern tree type_passed_as (tree);
extern tree convert_for_arg_passing (tree, tree, tsubst_flags_t);
extern tree push_library_fn (tree, tree, tree, int);
extern tree push_void_library_fn (tree, tree, int);
extern tree push_throw_library_fn (tree, tree);
-extern void warn_misplaced_attr_for_class_type (source_location location,
+extern void warn_misplaced_attr_for_class_type (location_t location,
tree class_type);
extern tree check_tag_decl (cp_decl_specifier_seq *, bool);
extern tree shadow_tag (cp_decl_specifier_seq *);
&& (desires & WANT_INT)
&& !(desires & WANT_NULL))
{
- source_location loc =
+ location_t loc =
expansion_point_location_if_in_system_header (input_location);
warning_at (loc, OPT_Wconversion_null,
class-key, in it class-specifier. */
void
-warn_misplaced_attr_for_class_type (source_location location,
+warn_misplaced_attr_for_class_type (location_t location,
tree class_type)
{
gcc_assert (OVERLOAD_TYPE_P (class_type));
bool constexpr_p = decl_spec_seq_has_spec_p (declspecs, ds_constexpr);
bool late_return_type_p = false;
bool array_parameter_p = false;
- source_location saved_loc = input_location;
+ location_t saved_loc = input_location;
tree reqs = NULL_TREE;
signed_p = decl_spec_seq_has_spec_p (declspecs, ds_signed);
static macro_use_before_def *
maybe_make (location_t use_loc, cpp_hashnode *macro)
{
- source_location def_loc = cpp_macro_definition_location (macro);
+ location_t def_loc = cpp_macro_definition_location (macro);
if (def_loc == UNKNOWN_LOCATION)
return NULL;
{
tree expression;
tree type;
- source_location type_location;
+ location_t type_location;
location_t start_loc
= cp_lexer_peek_token (parser->lexer)->location;
/* The `__builtin_va_arg' construct is used to handle
if (decl_specs == NULL)
return;
- source_location location = token->location;
+ location_t location = token->location;
if (decl_specs->locations[ds] == 0)
{
&& !TYPE_PTR_OR_PTRMEM_P (type1)))
&& (complain & tf_warning))
{
- source_location loc =
+ location_t loc =
expansion_point_location_if_in_system_header (input_location);
warning_at (loc, OPT_Wpointer_arith, "NULL used in arithmetic");
/* Expand each location towards the spelling location, and
recurse. */
const line_map_macro *macro_map = linemap_check_macro (map_a);
- source_location loc_a_toward_spelling
+ location_t loc_a_toward_spelling
= linemap_macro_map_loc_unwind_toward_spelling (line_table,
macro_map,
loc_a);
- source_location loc_b_toward_spelling
+ location_t loc_b_toward_spelling
= linemap_macro_map_loc_unwind_toward_spelling (line_table,
macro_map,
loc_b);
for (unsigned i = 0; i < richloc->get_num_fixit_hints (); i++)
{
const fixit_hint *hint = richloc->get_fixit_hint (i);
- source_location start_loc = hint->get_start_loc ();
+ location_t start_loc = hint->get_start_loc ();
expanded_location start_exploc = expand_location (start_loc);
pp_string (pp, "fix-it:");
print_escaped_string (pp, start_exploc.file);
/* For compatibility with clang, print as a half-open range. */
- source_location next_loc = hint->get_next_loc ();
+ location_t next_loc = hint->get_next_loc ();
expanded_location next_exploc = expand_location (next_loc);
pp_printf (pp, ":{%i:%i-%i:%i}:",
start_exploc.line, start_exploc.column,
static dump_flags_t pflags; /* current dump_flags */
-static void dump_loc (dump_flags_t, FILE *, source_location);
+static void dump_loc (dump_flags_t, FILE *, location_t);
/* Current -fopt-info output stream, if any, and flags. */
static FILE *alt_dump_file = NULL;
/* Print source location on DFILE if enabled. */
static void
-dump_loc (dump_flags_t dump_kind, FILE *dfile, source_location loc)
+dump_loc (dump_flags_t dump_kind, FILE *dfile, location_t loc)
{
if (dump_kind)
{
/* Print source location to PP if enabled. */
static void
-dump_loc (dump_flags_t dump_kind, pretty_printer *pp, source_location loc)
+dump_loc (dump_flags_t dump_kind, pretty_printer *pp, location_t loc)
{
if (dump_kind)
{
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * cpp.c: Replace "source_location" with "location_t".
+ * gfortran.h: Likewise.
+
2018-11-08 Jakub Jelinek <jakub@redhat.com>
* trans-openmp.c (gfc_trans_omp_clauses): Use
in specific modes. */
static void cb_file_change (cpp_reader *, const line_map_ordinary *);
static void cb_line_change (cpp_reader *, const cpp_token *, int);
-static void cb_define (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_undef (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_def_pragma (cpp_reader *, source_location);
-static void cb_include (cpp_reader *, source_location, const unsigned char *,
+static void cb_define (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_undef (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_def_pragma (cpp_reader *, location_t);
+static void cb_include (cpp_reader *, location_t, const unsigned char *,
const char *, int, const cpp_token **);
-static void cb_ident (cpp_reader *, source_location, const cpp_string *);
-static void cb_used_define (cpp_reader *, source_location, cpp_hashnode *);
-static void cb_used_undef (cpp_reader *, source_location, cpp_hashnode *);
+static void cb_ident (cpp_reader *, location_t, const cpp_string *);
+static void cb_used_define (cpp_reader *, location_t, cpp_hashnode *);
+static void cb_used_undef (cpp_reader *, location_t, cpp_hashnode *);
static bool cb_cpp_diagnostic (cpp_reader *, enum cpp_diagnostic_level,
enum cpp_warning_reason, rich_location *,
const char *, va_list *)
if (!gfc_cpp_option.no_predefined)
{
/* Make sure all of the builtins about to be declared have
- BUILTINS_LOCATION has their source_location. */
+ BUILTINS_LOCATION has their location_t. */
cpp_force_token_locations (cpp_in, BUILTINS_LOCATION);
cpp_define_builtins (cpp_in);
static void account_for_newlines (const unsigned char *, size_t);
static int dump_macro (cpp_reader *, cpp_hashnode *, void *);
-static void print_line (source_location, const char *);
-static void maybe_print_line (source_location);
+static void print_line (location_t, const char *);
+static void maybe_print_line (location_t);
/* Writes out the preprocessed file, handling spacing and paste
different line to the current one, output the required newlines or
a line marker. */
static void
-maybe_print_line (source_location src_loc)
+maybe_print_line (location_t src_loc)
{
const line_map_ordinary *map
= linemap_check_ordinary (linemap_lookup (line_table, src_loc));
/* Output a line marker for logical line LINE. Special flags are "1"
or "2" indicating entering or leaving a file. */
static void
-print_line (source_location src_loc, const char *special_flags)
+print_line (location_t src_loc, const char *special_flags)
{
/* End any previous line of text. */
if (print.printed)
cb_line_change (cpp_reader *pfile, const cpp_token *token,
int parsing_args)
{
- source_location src_loc = token->src_loc;
+ location_t src_loc = token->src_loc;
if (token->type == CPP_EOF || parsing_args)
return;
}
static void
-cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
const cpp_string *str)
{
maybe_print_line (line);
}
static void
-cb_define (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_define (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
cpp_hashnode *node ATTRIBUTE_UNUSED)
{
maybe_print_line (line);
}
static void
-cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
cpp_hashnode *node)
{
maybe_print_line (line);
}
static void
-cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
+cb_include (cpp_reader *pfile ATTRIBUTE_UNUSED, location_t line,
const unsigned char *dir, const char *header, int angle_brackets,
const cpp_token **comments)
{
}
static void
-cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED,
+cb_used_define (cpp_reader *pfile, location_t line ATTRIBUTE_UNUSED,
cpp_hashnode *node)
{
gfc_cpp_macro_queue *q;
/* Copy a #pragma directive to the preprocessed output. */
static void
-cb_def_pragma (cpp_reader *pfile, source_location line)
+cb_def_pragma (cpp_reader *pfile, location_t line)
{
maybe_print_line (line);
fputs ("#pragma ", print.outf);
static void
cb_used_undef (cpp_reader *pfile ATTRIBUTE_UNUSED,
- source_location line ATTRIBUTE_UNUSED,
+ location_t line ATTRIBUTE_UNUSED,
cpp_hashnode *node)
{
gfc_cpp_macro_queue *q;
typedef struct gfc_linebuf
{
- source_location location;
+ location_t location;
struct gfc_file *file;
struct gfc_linebuf *next;
/* Constructors. */
/* Constructing from a location. */
- gcc_rich_location (source_location loc, const range_label *label = NULL)
+ gcc_rich_location (location_t loc, const range_label *label = NULL)
: rich_location (line_table, loc, label)
{
}
static struct line_maps *line_table;
/* The rich_location class within libcpp requires a way to expand
- source_location instances, and relies on the client code
+ location_t instances, and relies on the client code
providing a symbol named
linemap_client_expand_location_to_spelling_point
to do this.
This is the implementation for genmatch. */
expanded_location
-linemap_client_expand_location_to_spelling_point (source_location loc,
+linemap_client_expand_location_to_spelling_point (location_t loc,
enum location_aspect)
{
const struct line_map_ordinary *map;
const char *msg, va_list *ap)
{
const line_map_ordinary *map;
- source_location location = richloc->get_loc ();
+ location_t location = richloc->get_loc ();
linemap_resolve_location (line_table, location, LRK_SPELLING_LOCATION, &map);
expanded_location loc = linemap_expand_location (line_table, map, location);
fprintf (stderr, "%s:%d:%d %s: ", loc.file, loc.line, loc.column,
#if GCC_VERSION >= 4001
__attribute__((format (printf, 2, 3)))
#endif
-fatal_at (source_location loc, const char *msg, ...)
+fatal_at (location_t loc, const char *msg, ...)
{
rich_location richloc (line_table, loc);
va_list ap;
#if GCC_VERSION >= 4001
__attribute__((format (printf, 2, 3)))
#endif
-warning_at (source_location loc, const char *msg, ...)
+warning_at (location_t loc, const char *msg, ...)
{
rich_location richloc (line_table, loc);
va_list ap;
}
static void
-output_line_directive (FILE *f, source_location location,
+output_line_directive (FILE *f, location_t location,
bool dumpfile = false, bool fnargs = false)
{
const line_map_ordinary *map;
struct operand {
enum op_type { OP_PREDICATE, OP_EXPR, OP_CAPTURE, OP_C_EXPR, OP_IF, OP_WITH };
- operand (enum op_type type_, source_location loc_)
+ operand (enum op_type type_, location_t loc_)
: type (type_), location (loc_) {}
enum op_type type;
- source_location location;
+ location_t location;
virtual void gen_transform (FILE *, int, const char *, bool, int,
const char *, capture_info *,
dt_operand ** = 0,
struct predicate : public operand
{
- predicate (predicate_id *p_, source_location loc)
+ predicate (predicate_id *p_, location_t loc)
: operand (OP_PREDICATE, loc), p (p_) {}
predicate_id *p;
};
struct expr : public operand
{
- expr (id_base *operation_, source_location loc, bool is_commutative_ = false)
+ expr (id_base *operation_, location_t loc, bool is_commutative_ = false)
: operand (OP_EXPR, loc), operation (operation_),
ops (vNULL), expr_type (NULL), is_commutative (is_commutative_),
is_generic (false), force_single_use (false) {}
id_tab (const char *id_, const char *oper_): id (id_), oper (oper_) {}
};
- c_expr (cpp_reader *r_, source_location loc,
+ c_expr (cpp_reader *r_, location_t loc,
vec<cpp_token> code_, unsigned nr_stmts_,
vec<id_tab> ids_, cid_map_t *capture_ids_)
: operand (OP_C_EXPR, loc), r (r_), code (code_),
struct capture : public operand
{
- capture (source_location loc, unsigned where_, operand *what_, bool value_)
+ capture (location_t loc, unsigned where_, operand *what_, bool value_)
: operand (OP_CAPTURE, loc), where (where_), value_match (value_),
what (what_) {}
/* Identifier index for the value. */
struct if_expr : public operand
{
- if_expr (source_location loc)
+ if_expr (location_t loc)
: operand (OP_IF, loc), cond (NULL), trueexpr (NULL), falseexpr (NULL) {}
c_expr *cond;
operand *trueexpr;
struct with_expr : public operand
{
- with_expr (source_location loc)
+ with_expr (location_t loc)
: operand (OP_WITH, loc), with (NULL), subexpr (NULL) {}
c_expr *with;
operand *subexpr;
{
if (verbose >= 1)
{
- source_location p_loc = 0;
+ location_t p_loc = 0;
if (p->type == dt_node::DT_OPERAND)
p_loc = as_a <dt_operand *> (p)->op->location;
- source_location op_loc = 0;
+ location_t op_loc = 0;
if (ops[i]->type == dt_node::DT_OPERAND)
op_loc = as_a <dt_operand *> (ops[i])->op->location;
- source_location true_loc = 0;
+ location_t true_loc = 0;
true_loc = true_node->op->location;
warning_at (p_loc,
"failed to merge decision tree node");
c_expr *parse_c_expr (cpp_ttype);
operand *parse_op ();
- void record_operlist (source_location, user_id *);
+ void record_operlist (location_t, user_id *);
void parse_pattern ();
operand *parse_result (operand *, predicate_id *);
vec<simplify *>&, operand *, operand *);
void parse_simplify (simplify::simplify_kind,
vec<simplify *>&, predicate_id *, operand *);
- void parse_for (source_location);
- void parse_if (source_location);
- void parse_predicates (source_location);
- void parse_operator_list (source_location);
+ void parse_for (location_t);
+ void parse_if (location_t);
+ void parse_predicates (location_t);
+ void parse_operator_list (location_t);
void finish_match_operand (operand *);
/* Record an operator-list use for transparent for handling. */
void
-parser::record_operlist (source_location loc, user_id *p)
+parser::record_operlist (location_t loc, user_id *p)
{
if (!oper_lists_set->add (p))
{
struct operand *
parser::parse_capture (operand *op, bool require_existing)
{
- source_location src_loc = eat_token (CPP_ATSIGN)->src_loc;
+ location_t src_loc = eat_token (CPP_ATSIGN)->src_loc;
const cpp_token *token = peek ();
const char *id = NULL;
bool value_match = false;
unsigned opencnt;
vec<cpp_token> code = vNULL;
unsigned nr_stmts = 0;
- source_location loc = eat_token (start)->src_loc;
+ location_t loc = eat_token (start)->src_loc;
if (start == CPP_OPEN_PAREN)
end = CPP_CLOSE_PAREN;
else if (start == CPP_OPEN_BRACE)
else if (peek_ident ("switch"))
{
token = eat_ident ("switch");
- source_location ifloc = eat_token (CPP_OPEN_PAREN)->src_loc;
+ location_t ifloc = eat_token (CPP_OPEN_PAREN)->src_loc;
eat_ident ("if");
if_expr *ife = new if_expr (ifloc);
operand *res = ife;
subst = <ident> '(' <ident>... ')' */
void
-parser::parse_for (source_location)
+parser::parse_for (location_t)
{
auto_vec<const cpp_token *> user_id_tokens;
vec<user_id *> user_ids = vNULL;
oprs = '(' 'define_operator_list' <ident> <ident>... ')' */
void
-parser::parse_operator_list (source_location)
+parser::parse_operator_list (location_t)
{
const cpp_token *token = peek ();
const char *id = get_ident ();
if = '(' 'if' '(' <c-expr> ')' <pattern> ')' */
void
-parser::parse_if (source_location)
+parser::parse_if (location_t)
{
c_expr *ifexpr = parse_c_expr (CPP_OPEN_PAREN);
preds = '(' 'define_predicates' <ident>... ')' */
void
-parser::parse_predicates (source_location)
+parser::parse_predicates (location_t)
{
do
{
else if (strcmp (id, "match") == 0)
{
bool with_args = false;
- source_location e_loc = peek ()->src_loc;
+ location_t e_loc = peek ()->src_loc;
if (peek ()->type == CPP_OPEN_PAREN)
{
eat_token (CPP_OPEN_PAREN);
/* Return the source location of gimple argument I of phi node PHI. */
-static inline source_location
+static inline location_t
gimple_phi_arg_location (gphi *phi, size_t i)
{
return gimple_phi_arg (phi, i)->locus;
/* Return the source location of the argument on edge E of phi node PHI. */
-static inline source_location
+static inline location_t
gimple_phi_arg_location_from_edge (gphi *phi, edge e)
{
return gimple_phi_arg (phi, e->dest_idx)->locus;
/* Set the source location of gimple argument I of phi node PHI to LOC. */
static inline void
-gimple_phi_arg_set_location (gphi *phi, size_t i, source_location loc)
+gimple_phi_arg_set_location (gphi *phi, size_t i, location_t loc)
{
gimple_phi_arg (phi, i)->locus = loc;
}
bool warned;
/* Use the expansion point to handle cases such as passing bool (defined
in a system header) through `...'. */
- source_location xloc
+ location_t xloc
= expansion_point_location_if_in_system_header (loc);
/* Unfortunately, this is merely undefined, rather than a constraint
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * go-gcc-diagnostics.cc: Replace "source_location" with "location_t".
+ * go-gcc.cc: Likewise.
+ * go-linemap.cc: Likewise.
+ * go-location.h: Likewise.
+ * gofrontend/README: Likewise.
+
2018-10-31 Ian Lance Taylor <iant@golang.org>
* go-gcc.cc (Gcc_backend::write_global_definitions): Don't call
void
go_be_error_at(const Location location, const std::string& errmsg)
{
- source_location gcc_loc = location.gcc_location();
+ location_t gcc_loc = location.gcc_location();
error_at(gcc_loc, "%s", errmsg.c_str());
}
go_be_warning_at(const Location location,
int opt, const std::string& warningmsg)
{
- source_location gcc_loc = location.gcc_location();
+ location_t gcc_loc = location.gcc_location();
warning_at(gcc_loc, opt, "%s", warningmsg.c_str());
}
go_be_fatal_error(const Location location,
const std::string& fatalmsg)
{
- source_location gcc_loc = location.gcc_location();
+ location_t gcc_loc = location.gcc_location();
fatal_error(gcc_loc, "%s", fatalmsg.c_str());
}
go_be_inform(const Location location,
const std::string& infomsg)
{
- source_location gcc_loc = location.gcc_location();
+ location_t gcc_loc = location.gcc_location();
inform(gcc_loc, "%s", infomsg.c_str());
}
{
if (pc->empty())
{
- source_location loc = (*ps != NULL
- ? EXPR_LOCATION((*ps)->get_tree())
- : UNKNOWN_LOCATION);
+ location_t loc = (*ps != NULL
+ ? EXPR_LOCATION((*ps)->get_tree())
+ : UNKNOWN_LOCATION);
tree label = create_artificial_label(loc);
tree c = build_case_label(NULL_TREE, NULL_TREE, label);
append_to_statement_list(c, &stmt_list);
tree t = (*pcv)->get_tree();
if (t == error_mark_node)
return this->error_statement();
- source_location loc = EXPR_LOCATION(t);
+ location_t loc = EXPR_LOCATION(t);
tree label = create_artificial_label(loc);
tree c = build_case_label((*pcv)->get_tree(), NULL_TREE, label);
append_to_statement_list(c, &stmt_list);
Gcc_linemap::to_string(Location location)
{
const line_map_ordinary *lmo;
- source_location resolved_location;
+ location_t resolved_location;
// Screen out unknown and predeclared locations; produce output
// only for simple file:line locations.
: gcc_loc_(UNKNOWN_LOCATION)
{ }
- explicit Location(source_location loc)
+ explicit Location(location_t loc)
: gcc_loc_(loc)
{ }
- source_location
+ location_t
gcc_location() const
{ return this->gcc_loc_; }
private:
- source_location gcc_loc_;
+ location_t gcc_loc_;
};
// The Go frontend requires the ability to compare Locations.
Issues to be faced in this transition:
* Representation of source locations.
- + Currently the frontend uses gcc's source_location codes, using the
+ + Currently the frontend uses gcc's location_t codes, using the
interface in libcpp/line-map.h.
* Handling of error messages.
ASPECT controls which part of the location to use. */
static expanded_location
-expand_location_1 (source_location loc,
+expand_location_1 (location_t loc,
bool expansion_point_p,
enum location_aspect aspect)
{
break;
case LOCATION_ASPECT_START:
{
- source_location start = get_start (loc);
+ location_t start = get_start (loc);
if (start != loc)
return expand_location_1 (start, expansion_point_p, aspect);
}
break;
case LOCATION_ASPECT_FINISH:
{
- source_location finish = get_finish (loc);
+ location_t finish = get_finish (loc);
if (finish != loc)
return expand_location_1 (finish, expansion_point_p, aspect);
}
total_lines_num (const char *file_path)
{
size_t r = 0;
- source_location l = 0;
+ location_t l = 0;
if (linemap_get_file_highest_location (line_table, file_path, &l))
{
gcc_assert (l >= RESERVED_LOCATION_COUNT);
function would return true if passed a token "4" that is the result
of the expansion of the built-in __LINE__ macro. */
bool
-is_location_from_builtin_token (source_location loc)
+is_location_from_builtin_token (location_t loc)
{
const line_map_ordinary *map = NULL;
loc = linemap_resolve_location (line_table, loc,
readable location is set to the string "<built-in>". */
expanded_location
-expand_location (source_location loc)
+expand_location (location_t loc)
{
return expand_location_1 (loc, /*expansion_point_p=*/true,
LOCATION_ASPECT_CARET);
"<built-in>". */
expanded_location
-expand_location_to_spelling_point (source_location loc,
+expand_location_to_spelling_point (location_t loc,
enum location_aspect aspect)
{
return expand_location_1 (loc, /*expansion_point_p=*/false, aspect);
}
/* The rich_location class within libcpp requires a way to expand
- source_location instances, and relies on the client code
+ location_t instances, and relies on the client code
providing a symbol named
linemap_client_expand_location_to_spelling_point
to do this.
which simply calls into expand_location_1. */
expanded_location
-linemap_client_expand_location_to_spelling_point (source_location loc,
+linemap_client_expand_location_to_spelling_point (location_t loc,
enum location_aspect aspect)
{
return expand_location_1 (loc, /*expansion_point_p=*/false, aspect);
warning_at, the diagnostic would be suppressed (unless
-Wsystem-headers). */
-source_location
-expansion_point_location_if_in_system_header (source_location location)
+location_t
+expansion_point_location_if_in_system_header (location_t location)
{
if (in_system_header_at (location))
location = linemap_resolve_location (line_table, location,
/* 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. */
-source_location
-expansion_point_location (source_location location)
+location_t
+expansion_point_location (location_t location)
{
return linemap_resolve_location (line_table, location,
LRK_MACRO_EXPANSION_POINT, NULL);
/* Get location one beyond the final location in ordinary map IDX. */
-static source_location
+static location_t
get_end_location (struct line_maps *set, unsigned int idx)
{
if (idx == LINEMAPS_ORDINARY_USED (set) - 1)
static void
write_digit_row (FILE *stream, int indent,
const line_map_ordinary *map,
- source_location loc, int max_col, int divisor)
+ location_t loc, int max_col, int divisor)
{
fprintf (stream, "%*c", indent, ' ');
fprintf (stream, "|");
for (int column = 1; column < max_col; column++)
{
- source_location column_loc = loc + (column << map->m_range_bits);
+ location_t column_loc = loc + (column << map->m_range_bits);
write_digit (stream, column_loc / divisor);
}
fprintf (stream, "\n");
}
/* Write a half-closed (START) / half-open (END) interval of
- source_location to STREAM. */
+ location_t to STREAM. */
static void
dump_location_range (FILE *stream,
- source_location start, source_location end)
+ location_t start, location_t end)
{
fprintf (stream,
- " source_location interval: %u <= loc < %u\n",
+ " location_t interval: %u <= loc < %u\n",
start, end);
}
/* Write a labelled description of a half-closed (START) / half-open (END)
- interval of source_location to STREAM. */
+ interval of location_t to STREAM. */
static void
dump_labelled_location_range (FILE *stream,
const char *name,
- source_location start, source_location end)
+ location_t start, location_t end)
{
fprintf (stream, "%s\n", name);
dump_location_range (stream, start, end);
/* Visualize the ordinary line_map instances, rendering the sources. */
for (unsigned int idx = 0; idx < LINEMAPS_ORDINARY_USED (line_table); idx++)
{
- source_location end_location = get_end_location (line_table, idx);
+ location_t end_location = get_end_location (line_table, idx);
/* half-closed: doesn't include this one. */
const line_map_ordinary *map
map->m_range_bits);
/* Render the span of source lines that this "map" covers. */
- for (source_location loc = MAP_START_LOCATION (map);
+ for (location_t loc = MAP_START_LOCATION (map);
loc < end_location;
loc += (1 << map->m_range_bits) )
{
/* "loc" is at column 0, which means "the whole line".
Render the locations *within* the line, by underlining
- it, showing the source_location numeric values
+ it, showing the location_t numeric values
at each column. */
size_t max_col = (1 << map->m_column_and_range_bits) - 1;
if (max_col > line_text.length ())
/* Visualize the macro line_map instances, rendering the sources. */
for (unsigned int i = 0; i < LINEMAPS_MACRO_USED (line_table); i++)
{
- /* Each macro map that is allocated owns source_location values
+ /* Each macro map that is allocated owns location_t values
that are *lower* that the one before them.
Hence it's meaningful to view them either in order of ascending
source locations, or in order of ascending macro map index. */
- const bool ascending_source_locations = true;
- unsigned int idx = (ascending_source_locations
+ const bool ascending_location_ts = true;
+ unsigned int idx = (ascending_location_ts
? (LINEMAPS_MACRO_USED (line_table) - (i + 1))
: i);
const line_map_macro *map = LINEMAPS_MACRO_MAP_AT (line_table, idx);
fprintf (stream, " macro_locations:\n");
for (unsigned int i = 0; i < MACRO_MAP_NUM_MACRO_TOKENS (map); i++)
{
- source_location x = MACRO_MAP_LOCATIONS (map)[2 * i];
- source_location y = MACRO_MAP_LOCATIONS (map)[(2 * i) + 1];
+ location_t x = MACRO_MAP_LOCATIONS (map)[2 * i];
+ location_t y = MACRO_MAP_LOCATIONS (map)[(2 * i) + 1];
/* linemap_add_macro_token encodes token numbers in an expansion
by putting them after MAP_START_LOCATION. */
adding 2 extra args for padding tokens; presumably there may
be a leading and/or trailing padding token injected,
each for 2 more location slots.
- This would explain there being up to 4 source_locations slots
+ This would explain there being up to 4 location_ts slots
that may be uninitialized. */
fprintf (stream, " %u: %u, %u\n",
fprintf (stream, "\n");
}
- /* It appears that MAX_SOURCE_LOCATION itself is never assigned to a
+ /* It appears that MAX_LOCATION_T itself is never assigned to a
macro map, presumably due to an off-by-one error somewhere
between the logic in linemap_enter_macro and
LINEMAPS_MACRO_LOWEST_LOCATION. */
- dump_labelled_location_range (stream, "MAX_SOURCE_LOCATION",
- MAX_SOURCE_LOCATION,
- MAX_SOURCE_LOCATION + 1);
+ dump_labelled_location_range (stream, "MAX_LOCATION_T",
+ MAX_LOCATION_T,
+ MAX_LOCATION_T + 1);
/* Visualize ad-hoc values. */
dump_labelled_location_range (stream, "AD-HOC LOCATIONS",
- MAX_SOURCE_LOCATION + 1, UINT_MAX);
+ MAX_LOCATION_T + 1, UINT_MAX);
}
/* string_concat's constructor. */
than for end-users. */
const char *
-get_source_location_for_substring (cpp_reader *pfile,
- string_concat_db *concats,
- location_t strloc,
- enum cpp_ttype type,
- int caret_idx, int start_idx, int end_idx,
- source_location *out_loc)
+get_location_within_string (cpp_reader *pfile,
+ string_concat_db *concats,
+ location_t strloc,
+ enum cpp_ttype type,
+ int caret_idx, int start_idx, int end_idx,
+ location_t *out_loc)
{
gcc_checking_assert (caret_idx >= 0);
gcc_checking_assert (start_idx >= 0);
- line_table->default_range_bits: some frontends use a non-zero value
and others use zero
- the fallback modes within line-map.c: there are various threshold
- values for source_location/location_t beyond line-map.c changes
+ values for location_t beyond line-map.c changes
behavior (disabling of the range-packing optimization, disabling
of column-tracking). We can exercise these by starting the line_table
at interesting values at or near these thresholds.
extern GTY(()) struct line_maps *saved_line_table;
/* A value which will never be used to represent a real location. */
-#define UNKNOWN_LOCATION ((source_location) 0)
+#define UNKNOWN_LOCATION ((location_t) 0)
/* The location for declarations in "<built-in>" */
-#define BUILTINS_LOCATION ((source_location) 1)
+#define BUILTINS_LOCATION ((location_t) 1)
/* line-map.c reserves RESERVED_LOCATION_COUNT to the user. Ensure
both UNKNOWN_LOCATION and BUILTINS_LOCATION fit into that. */
STATIC_ASSERT (BUILTINS_LOCATION < RESERVED_LOCATION_COUNT);
-extern bool is_location_from_builtin_token (source_location);
-extern expanded_location expand_location (source_location);
+extern bool is_location_from_builtin_token (location_t);
+extern expanded_location expand_location (location_t);
/* A class capturing the bounds of a buffer, to allow for run-time
bounds-checking in a checked build. */
extern bool location_missing_trailing_newline (const char *file_path);
extern expanded_location
-expand_location_to_spelling_point (source_location,
+expand_location_to_spelling_point (location_t,
enum location_aspect aspect
= LOCATION_ASPECT_CARET);
-extern source_location expansion_point_location_if_in_system_header (source_location);
-extern source_location expansion_point_location (source_location);
-
-/* Historically GCC used location_t, while cpp used source_location.
- This could be removed but it hardly seems worth the effort. */
-typedef source_location location_t;
+extern location_t expansion_point_location_if_in_system_header (location_t);
+extern location_t expansion_point_location (location_t);
extern location_t input_location;
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * jit-playback.c: Replace "source_location" with "location_t".
+
2018-10-17 David Malcolm <dmalcolm@redhat.com>
* Make-lang.in (selftest-jit): New.
FOR_EACH_VEC_ELT (m_cached_locations, i, cached_location)
{
tree t = cached_location->first;
- source_location srcloc = cached_location->second->m_srcloc;
+ location_t srcloc = cached_location->second->m_srcloc;
/* This covers expressions: */
if (CAN_HAVE_LOCATION_P (t))
/* Deferred setting of the location for a given tree, by adding the
(tree, playback::location) pair to a list of deferred associations.
We will actually set the location on the tree later on once
- the source_location for the playback::location exists. */
+ the location_t for the playback::location exists. */
void
playback::context::
recording::location *get_recording_loc () const { return m_recording_loc; }
- source_location m_srcloc;
+ location_t m_srcloc;
private:
recording::location *m_recording_loc;
gphi_iterator psi;
for (psi = gsi_start_phis (l3_bb); !gsi_end_p (psi); gsi_next (&psi))
{
- source_location locus;
+ location_t locus;
gphi *nphi;
gphi *exit_phi = psi.phi ();
gsi_next (&psi), ++i)
{
gphi *nphi;
- source_location locus;
+ location_t locus;
phi = psi.phi ();
if (operand_equal_p (gimple_phi_arg_def (phi, 0),
- line_table->default_range_bits: some frontends use a non-zero value
and others use zero
- the fallback modes within line-map.c: there are various threshold
- values for source_location/location_t beyond line-map.c changes
+ values for location_t beyond line-map.c changes
behavior (disabling of the range-packing optimization, disabling
of column-tracking). We can exercise these by starting the line_table
at interesting values at or near these thresholds.
/* Implementation detail, for use when implementing
LANG_HOOKS_GET_SUBSTRING_LOCATION. */
-extern const char *get_source_location_for_substring (cpp_reader *pfile,
- string_concat_db *concats,
- location_t strloc,
- enum cpp_ttype type,
- int caret_idx,
- int start_idx, int end_idx,
- location_t *out_loc);
+extern const char *get_location_within_string (cpp_reader *pfile,
+ string_concat_db *concats,
+ location_t strloc,
+ enum cpp_ttype type,
+ int caret_idx,
+ int start_idx, int end_idx,
+ location_t *out_loc);
#endif /* ! GCC_SUBSTRING_LOCATIONS_H */
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * g++.dg/plugin/comment_plugin.c: Replace "source_location" with
+ "location_t".
+ * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise.
+
2018-11-13 Martin Sebor <msebor@redhat.com>
PR middle-end/81824
/* Test callback for cpp_callbacks::comments. */
void
-my_comment_cb (cpp_reader *, source_location loc,
+my_comment_cb (cpp_reader *, location_t loc,
const unsigned char *content, size_t len)
{
if (in_system_header_at (loc))
hard-coded locations relative to the top of each function.
The plugin uses a function "get_loc" below to map from line/column
- numbers to source_location, and this relies on input_location being in
+ numbers to location_t, and this relies on input_location being in
the same ordinary line_map as the locations in question. The plugin
runs after parsing, so input_location will be at the end of the file.
}; // class pass_test_show_locus
-/* Given LINE_NUM and COL_NUM, generate a source_location in the
+/* Given LINE_NUM and COL_NUM, generate a location_t in the
current file, relative to input_location. This relies on the
location being expressible in the same ordinary line_map as
input_location (which is typically at the end of the source file
COL_NUM uses the Emacs convention of 0-based column numbers. */
-static source_location
+static location_t
get_loc (unsigned int line_num, unsigned int col_num)
{
/* Use input_location to get the relevant line_map */
input_location));
/* Convert from 0-based column numbers to 1-based column numbers. */
- source_location loc
+ location_t loc
= linemap_position_for_line_and_column (line_table,
line_map,
line_num, col_num + 1);
unsigned int
pass_warn_function_return::execute (function *fun)
{
- source_location location;
+ location_t location;
gimple *last;
edge e;
edge_iterator ei;
gsi_next (&psi))
{
gphi *phi = psi.phi ();
- source_location l = gimple_phi_arg_location_from_edge (phi, succ);
+ location_t l = gimple_phi_arg_location_from_edge (phi, succ);
tree def = gimple_phi_arg_def (phi, succ->dest_idx);
add_phi_arg (phi, unshare_expr (def), s, l);
}
{
gphi *phi = gsi.phi ();
tree def = gimple_phi_arg_def (phi, succ->dest_idx);
- source_location locus = gimple_phi_arg_location_from_edge (phi, succ);
+ location_t locus = gimple_phi_arg_location_from_edge (phi, succ);
if (TREE_CODE (def) == SSA_NAME)
{
struct loc_map_pair
{
const line_map_macro *map;
- source_location where;
+ location_t where;
};
static void
maybe_unwind_expanded_macro_loc (diagnostic_context *context,
const diagnostic_info *diagnostic,
- source_location where)
+ location_t where)
{
const struct line_map *map;
auto_vec<loc_map_pair> loc_vec;
/* Resolve the location iter->where into the locus 1/ of the
comment above. */
- source_location resolved_def_loc =
+ location_t resolved_def_loc =
linemap_resolve_location (line_table, iter->where,
LRK_MACRO_DEFINITION_LOCATION, NULL);
/* Don't print trace for locations that are reserved or from
within a system header. */
const line_map_ordinary *m = NULL;
- source_location l =
+ location_t l =
linemap_resolve_location (line_table, resolved_def_loc,
LRK_SPELLING_LOCATION, &m);
if (l < RESERVED_LOCATION_COUNT || LINEMAP_SYSP (m))
/* Resolve the location of the expansion point of the macro
which expansion gave the token represented by def_loc.
This is the locus 2/ of the earlier comment. */
- source_location resolved_exp_loc =
+ location_t resolved_exp_loc =
linemap_resolve_location (line_table,
MACRO_MAP_EXPANSION_POINT_LOCATION (iter->map),
LRK_MACRO_DEFINITION_LOCATION, NULL);
/* Update the argument if there is a reaching def. */
if (reaching_def)
{
- source_location locus;
+ location_t locus;
int arg_i = PHI_ARG_INDEX_FROM_USE (arg_p);
SET_USE (arg_p, reaching_def);
auto_vec<int> edge_list;
/* Source locus on each edge */
- auto_vec<source_location> edge_locus;
+ auto_vec<location_t> edge_locus;
/* Visited vector. */
auto_sbitmap visited;
auto_vec<tree> const_copies;
/* Source locations for any constant copies. */
- auto_vec<source_location> copy_locus;
+ auto_vec<location_t> copy_locus;
};
/* Insert a copy instruction from partition SRC to DEST onto edge E. */
static void
-insert_partition_copy_on_edge (edge e, int dest, int src, source_location locus)
+insert_partition_copy_on_edge (edge e, int dest, int src, location_t locus)
{
tree var;
if (dump_file && (dump_flags & TDF_DETAILS))
onto edge E. */
static void
-insert_value_copy_on_edge (edge e, int dest, tree src, source_location locus)
+insert_value_copy_on_edge (edge e, int dest, tree src, location_t locus)
{
rtx dest_rtx, seq, x;
machine_mode dest_mode, src_mode;
static void
insert_rtx_to_part_on_edge (edge e, int dest, rtx src, int unsignedsrcp,
- source_location locus)
+ location_t locus)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
onto edge E. */
static void
-insert_part_to_rtx_on_edge (edge e, rtx dest, int src, source_location locus)
+insert_part_to_rtx_on_edge (edge e, rtx dest, int src, location_t locus)
{
tree var;
if (dump_file && (dump_flags & TDF_DETAILS))
/* Add the edge PRED->SUCC to graph G. */
static inline void
-elim_graph_add_edge (elim_graph *g, int pred, int succ, source_location locus)
+elim_graph_add_edge (elim_graph *g, int pred, int succ, location_t locus)
{
g->edge_list.safe_push (pred);
g->edge_list.safe_push (succ);
return the successor node. -1 is returned if there is no such edge. */
static inline int
-elim_graph_remove_succ_edge (elim_graph *g, int node, source_location *locus)
+elim_graph_remove_succ_edge (elim_graph *g, int node, location_t *locus)
{
int y;
unsigned x;
for (gsi = gsi_start_phis (g->e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
{
gphi *phi = gsi.phi ();
- source_location locus;
+ location_t locus;
p0 = var_to_partition (g->map, gimple_phi_result (phi));
/* Ignore results which are not in partitions. */
elim_forward (elim_graph *g, int T)
{
int S;
- source_location locus;
+ location_t locus;
bitmap_set_bit (g->visited, T);
FOR_EACH_ELIM_GRAPH_SUCC (g, T, S, locus,
elim_unvisited_predecessor (elim_graph *g, int T)
{
int P;
- source_location locus;
+ location_t locus;
FOR_EACH_ELIM_GRAPH_PRED (g, T, P, locus,
{
elim_backward (elim_graph *g, int T)
{
int P;
- source_location locus;
+ location_t locus;
bitmap_set_bit (g->visited, T);
FOR_EACH_ELIM_GRAPH_PRED (g, T, P, locus,
elim_create (elim_graph *g, int T)
{
int P, S;
- source_location locus;
+ location_t locus;
if (elim_unvisited_predecessor (g, T))
{
{
int dest;
tree src;
- source_location locus;
+ location_t locus;
src = g->const_copies.pop ();
dest = g->const_dests.pop ();
gphi *new_phi;
basic_block store_bb, continue_bb;
tree local_res;
- source_location locus;
+ location_t locus;
/* STORE_BB is the block where the phi
should be stored. It is the destination of the loop exit.
for (gphi_iterator gpi = gsi_start_phis (ex_bb);
!gsi_end_p (gpi); gsi_next (&gpi))
{
- source_location locus;
+ location_t locus;
gphi *phi = gpi.phi ();
tree def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
gimple *def_stmt = SSA_NAME_DEF_STMT (def);
PHI points to the reallocated phi node when we return. */
void
-add_phi_arg (gphi *phi, tree def, edge e, source_location locus)
+add_phi_arg (gphi *phi, tree def, edge e, location_t locus)
{
basic_block bb = e->dest;
extern void reserve_phi_args_for_new_edge (basic_block);
extern void add_phi_node_to_bb (gphi *phi, basic_block bb);
extern gphi *create_phi_node (tree, basic_block);
-extern void add_phi_arg (gphi *, tree, edge, source_location);
+extern void add_phi_arg (gphi *, tree, edge, location_t);
extern void remove_phi_args (edge);
extern void remove_phi_node (gimple_stmt_iterator *, bool);
extern void remove_phi_nodes (basic_block);
{
/* The currently optimized loop. */
struct loop *current_loop;
- source_location loop_loc;
+ location_t loop_loc;
/* Numbers of iterations for all exits of the current loop. */
hash_map<edge, tree_niter_desc *> *niters;
tree new_name, name;
use_operand_p op_p;
gphi_iterator psi;
- source_location locus;
+ location_t locus;
for (psi = gsi_start_phis (dest); !gsi_end_p (psi); gsi_next (&psi))
{
tree temp, result;
gphi *newphi;
gimple_stmt_iterator gsi, gsi_for_def;
- source_location locus = gimple_location (phi);
+ location_t locus = gimple_location (phi);
enum tree_code convert_code;
/* Handle only PHI statements with two arguments. TODO: If all
if (!useless_type_conversion_p (TREE_TYPE (result), TREE_TYPE (new_var)))
{
- source_location locus_0, locus_1;
+ location_t locus_0, locus_1;
new_var2 = make_ssa_name (TREE_TYPE (result));
new_stmt = gimple_build_assign (new_var2, CONVERT_EXPR, new_var);
gphi *newphi;
gassign *new_stmt;
gimple_stmt_iterator gsi;
- source_location locus;
+ location_t locus;
/* Check if middle_bb contains of only one store. */
if (!assign
gimple *else_assign)
{
tree lhs_base, lhs, then_rhs, else_rhs, name;
- source_location then_locus, else_locus;
+ location_t then_locus, else_locus;
gimple_stmt_iterator gsi;
gphi *newphi;
gassign *new_stmt;
{
tree old_arg, new_var;
gassign *tmp;
- source_location locus;
+ location_t locus;
old_arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
locus = gimple_phi_arg_location_from_edge (phi, e);
gphi *src_phi = gsi.phi ();
gphi *dest_phi = gsi2.phi ();
tree val = gimple_phi_arg_def (src_phi, src_idx);
- source_location locus = gimple_phi_arg_location (src_phi, src_idx);
+ location_t locus = gimple_phi_arg_location (src_phi, src_idx);
SET_PHI_ARG_DEF (dest_phi, tgt_idx, val);
gimple_phi_arg_set_location (dest_phi, tgt_idx, locus);
static tree
get_value_locus_in_path (tree def, vec<jump_thread_edge *> *path,
- basic_block bb, int idx, source_location *locus)
+ basic_block bb, int idx, location_t *locus)
{
tree arg;
gphi *def_phi;
{
gphi *phi = gsi.phi ();
tree def = gimple_phi_arg_def (phi, src_indx);
- source_location locus = gimple_phi_arg_location (phi, src_indx);
+ location_t locus = gimple_phi_arg_location (phi, src_indx);
if (TREE_CODE (def) == SSA_NAME
&& !virtual_operand_p (gimple_phi_result (phi)))
/* Add a mapping with PHI RESULT and PHI DEF associated with edge E. */
void
-redirect_edge_var_map_add (edge e, tree result, tree def, source_location locus)
+redirect_edge_var_map_add (edge e, tree result, tree def, location_t locus)
{
edge_var_map new_node;
for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
{
tree def;
- source_location locus ;
+ location_t locus;
phi = gsi.phi ();
def = gimple_phi_arg_def (phi, e->dest_idx);
struct edge_var_map {
tree result; /* PHI result. */
tree def; /* PHI arg definition. */
- source_location locus; /* PHI arg location. */
+ location_t locus; /* PHI arg location. */
};
/* A vector of var maps. */
typedef vec<edge_var_map, va_heap, vl_embed> edge_var_map_vector;
-extern void redirect_edge_var_map_add (edge, tree, tree, source_location);
+extern void redirect_edge_var_map_add (edge, tree, tree, location_t);
extern void redirect_edge_var_map_clear (edge);
extern void redirect_edge_var_map_dup (edge, edge);
extern vec<edge_var_map> *redirect_edge_var_map_vector (edge);
/* Given an edge_var_map V, return the PHI arg location. */
-static inline source_location
+static inline location_t
redirect_edge_var_map_location (edge_var_map *v)
{
return v->locus;
struct loop *update_loop,
edge guard_edge, edge merge_edge)
{
- source_location merge_loc, guard_loc;
+ location_t merge_loc, guard_loc;
edge orig_e = loop_preheader_edge (skip_loop);
edge update_e = loop_preheader_edge (update_loop);
gphi_iterator gsi_orig, gsi_update;
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * libcc1plugin.cc: Replace "source_location" with "location_t".
+ (plugin_context::get_source_location): Rename to...
+ (plugin_context::get_location_t): ...this.
+ * libcp1plugin.cc: Likewise.
+
2018-10-31 Joseph Myers <joseph@codesourcery.com>
PR bootstrap/82856
return t;
}
- source_location get_source_location (const char *filename,
- unsigned int line_number)
+ location_t get_location_t (const char *filename,
+ unsigned int line_number)
{
if (filename == NULL)
return UNKNOWN_LOCATION;
filename = intern_filename (filename);
linemap_add (line_table, LC_ENTER, false, filename, line_number);
- source_location loc = linemap_line_start (line_table, line_number, 0);
+ location_t loc = linemap_line_start (line_table, line_number, 0);
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
return loc;
}
abort ();
}
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
decl = build_decl (loc, code, identifier, sym_type);
TREE_USED (decl) = 1;
{
plugin_context *ctx = static_cast<plugin_context *> (self);
tree t = convert_in (tagged_type), x;
- c_pushtag (ctx->get_source_location (filename, line_number),
+ c_pushtag (ctx->get_location_t (filename, line_number),
get_identifier (name), t);
/* Propagate the newly-added type name so that previously-created
tree type = convert_in (type_in);
cst = build_int_cst (type, value);
- decl = build_decl (ctx->get_source_location (filename, line_number),
+ decl = build_decl (ctx->get_location_t (filename, line_number),
CONST_DECL, get_identifier (name), type);
DECL_INITIAL (decl) = cst;
pushdecl_safe (decl);
return t;
}
- source_location get_source_location (const char *filename,
- unsigned int line_number)
+ location_t get_location_t (const char *filename,
+ unsigned int line_number)
{
if (filename == NULL)
return UNKNOWN_LOCATION;
filename = intern_filename (filename);
linemap_add (line_table, LC_ENTER, false, filename, line_number);
- source_location loc = linemap_line_start (line_table, line_number, 0);
+ location_t loc = linemap_line_start (line_table, line_number, 0);
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
return loc;
}
static tree
build_named_class_type (enum tree_code code,
tree id,
- source_location loc)
+ location_t loc)
{
/* See at_fake_function_scope_p. */
gcc_assert (!at_function_scope_p ());
gcc_assert (!substitution_name);
}
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
bool class_member_p = at_class_scope_p ();
bool ctor = false, dtor = false, assop = false;
tree_code opcode = ERROR_MARK;
unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
tree typedecl = convert_in (typedecl_in);
tree type = TREE_TYPE (typedecl);
tree lambda_expr = build_lambda_expr ();
- LAMBDA_EXPR_LOCATION (lambda_expr) = ctx->get_source_location (filename,
- line_number);
+ LAMBDA_EXPR_LOCATION (lambda_expr) = ctx->get_location_t (filename,
+ line_number);
tree type = begin_lambda_type (lambda_expr);
gcc_assert (is_new_type);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
tree type_decl = TYPE_NAME (type);
DECL_SOURCE_LOCATION (type_decl) = loc;
SET_OPAQUE_ENUM_P (type, false);
unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
gcc_assert (template_parm_scope_p ());
unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
gcc_assert (template_parm_scope_p ());
unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
gcc_assert (template_parm_scope_p ());
unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
tree name = convert_in (template_decl);
tree targsl = targlist (targs);
unsigned int line_number)
{
plugin_context *ctx = static_cast<plugin_context *> (self);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
tree name = convert_in (template_decl);
tree tdecl = finish_template_type (name, targlist (args), false);;
cst = build_int_cst (type, value);
if (!TYPE_READONLY (type))
type = build_qualified_type (type, TYPE_QUAL_CONST);
- decl = build_decl (ctx->get_source_location (filename, line_number),
+ decl = build_decl (ctx->get_location_t (filename, line_number),
VAR_DECL, get_identifier (name), type);
TREE_STATIC (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_TYPE (message) = char_array_type_node;
fix_string_type (message);
- source_location loc = ctx->get_source_location (filename, line_number);
+ location_t loc = ctx->get_location_t (filename, line_number);
bool member_p = at_class_scope_p ();
+2018-11-13 David Malcolm <dmalcolm@redhat.com>
+
+ * charset.c: Replace "source_location" with "location_t".
+ * directives-only.c: Likewise.
+ * directives.c: Likewise.
+ * errors.c: Likewise.
+ * expr.c: Likewise.
+ * files.c: Likewise.
+ * include/cpplib.h: Likewise. Rename MAX_SOURCE_LOCATION to
+ MAX_LOCATION_T.
+ * include/line-map.h: Likewise.
+ * init.c: Likewise.
+ * internal.h: Likewise.
+ * lex.c: Likewise.
+ * line-map.c: Likewise.
+ * location-example.txt: Likewise.
+ * macro.c: Likewise.
+ * pch.c: Likewise.
+ * traditional.c: Likewise.
+
2018-11-07 Hafiz Abid Qadeer <abidh@codesourcery.com>
* configure: Regenerated.
/* Constructor for cpp_string_location_reader. */
cpp_string_location_reader::
-cpp_string_location_reader (source_location src_loc,
+cpp_string_location_reader (location_t src_loc,
line_maps *line_table)
: m_line_table (line_table)
{
unsigned flags;
linenum_type lines;
int col;
- source_location loc;
+ location_t loc;
restart:
/* Buffer initialization ala _cpp_clean_line(). */
struct if_stack
{
struct if_stack *next;
- source_location line; /* Line where condition started. */
+ location_t line; /* Line where condition started. */
const cpp_hashnode *mi_cmacro;/* macro name for #ifndef around entire file */
bool skip_elses; /* Can future #else / #elif be skipped? */
bool was_skipping; /* If were skipping on entry. */
static void run_directive (cpp_reader *, int, const char *, size_t);
static char *glue_header_name (cpp_reader *);
static const char *parse_include (cpp_reader *, int *, const cpp_token ***,
- source_location *);
+ location_t *);
static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *);
static unsigned int read_flag (cpp_reader *, unsigned int);
static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *);
static const cpp_token *get_token_no_padding (cpp_reader *);
static const cpp_token *get__Pragma_string (cpp_reader *);
static void destringize_and_run (cpp_reader *, const cpp_string *,
- source_location);
-static bool parse_answer (cpp_reader *, int, source_location, cpp_macro **);
+ location_t);
+static bool parse_answer (cpp_reader *, int, location_t, cpp_macro **);
static cpp_hashnode *parse_assertion (cpp_reader *, int, cpp_macro **);
static cpp_macro **find_answer (cpp_hashnode *, const cpp_macro *);
static void handle_assertion (cpp_reader *, const char *, int);
static const char *
parse_include (cpp_reader *pfile, int *pangle_brackets,
- const cpp_token ***buf, source_location *location)
+ const cpp_token ***buf, location_t *location)
{
char *fname;
const cpp_token *header;
const char *fname;
int angle_brackets;
const cpp_token **buf = NULL;
- source_location location;
+ location_t location;
/* Re-enable saving of comments if requested, so that the include
callback can dump comments which follow #include. */
}
/* Compensate for the increment in linemap_add that occurs in
_cpp_do_file_change. We're currently at the start of the line
- *following* the #line directive. A separate source_location for this
+ *following* the #line directive. A separate location_t for this
location makes no sense (until we do the LC_LEAVE), and
complicates LAST_SOURCE_LINE_LOCATION. */
pfile->line_table->highest_location--;
{
const unsigned char *dir_name;
unsigned char *line;
- source_location src_loc = pfile->cur_token[-1].src_loc;
+ location_t src_loc = pfile->cur_token[-1].src_loc;
if (print_dir)
dir_name = pfile->directive->name;
{
const struct pragma_entry *p = NULL;
const cpp_token *token, *pragma_token;
- source_location pragma_token_virt_loc = 0;
+ location_t pragma_token_virt_loc = 0;
cpp_token ns_token;
unsigned int count = 1;
txt = get__Pragma_string (pfile);
if (!txt)
{
- source_location src_loc = pfile->cur_token[-1].src_loc;
+ location_t src_loc = pfile->cur_token[-1].src_loc;
cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0,
"invalid #pragma push_macro directive");
check_eol (pfile, false);
txt = get__Pragma_string (pfile);
if (!txt)
{
- source_location src_loc = pfile->cur_token[-1].src_loc;
+ location_t src_loc = pfile->cur_token[-1].src_loc;
cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0,
"invalid #pragma pop_macro directive");
check_eol (pfile, false);
{
const char *fname;
int angle_brackets, ordering;
- source_location location;
+ location_t location;
fname = parse_include (pfile, &angle_brackets, NULL, &location);
if (!fname)
\" and \\ sequences, and process the result as a #pragma directive. */
static void
destringize_and_run (cpp_reader *pfile, const cpp_string *in,
- source_location expansion_loc)
+ location_t expansion_loc)
{
const unsigned char *src, *limit;
char *dest, *result;
/* Handle the _Pragma operator. Return 0 on error, 1 if ok. */
int
-_cpp_do__Pragma (cpp_reader *pfile, source_location expansion_loc)
+_cpp_do__Pragma (cpp_reader *pfile, location_t expansion_loc)
{
const cpp_token *string = get__Pragma_string (pfile);
pfile->directive_result.type = CPP_PADDING;
ANSWERP to point to the answer. PRED_LOC is the location of the
predicate. */
static bool
-parse_answer (cpp_reader *pfile, int type, source_location pred_loc,
+parse_answer (cpp_reader *pfile, int type, location_t pred_loc,
cpp_macro **answer_ptr)
{
/* In a conditional, it is legal to not have an open paren. We
enum cpp_warning_reason reason,
const char *msgid, va_list *ap)
{
- source_location src_loc;
+ location_t src_loc;
if (CPP_OPTION (pfile, traditional))
{
static bool
cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level,
enum cpp_warning_reason reason,
- source_location src_loc, unsigned int column,
+ location_t src_loc, unsigned int column,
const char *msgid, va_list *ap)
{
bool ret;
bool
cpp_error_with_line (cpp_reader *pfile, enum cpp_diagnostic_level level,
- source_location src_loc, unsigned int column,
+ location_t src_loc, unsigned int column,
const char *msgid, ...)
{
va_list ap;
bool
cpp_warning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
- source_location src_loc, unsigned int column,
+ location_t src_loc, unsigned int column,
const char *msgid, ...)
{
va_list ap;
bool
cpp_pedwarning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
- source_location src_loc, unsigned int column,
+ location_t src_loc, unsigned int column,
const char *msgid, ...)
{
va_list ap;
bool
cpp_warning_with_line_syshdr (cpp_reader *pfile, enum cpp_warning_reason reason,
- source_location src_loc, unsigned int column,
+ location_t src_loc, unsigned int column,
const char *msgid, ...)
{
va_list ap;
bool
cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
- source_location src_loc, const char *msgid, ...)
+ location_t src_loc, const char *msgid, ...)
{
va_list ap;
bool ret;
bool
cpp_errno_filename (cpp_reader *pfile, enum cpp_diagnostic_level level,
const char *filename,
- source_location loc)
+ location_t loc)
{
if (filename[0] == '\0')
filename = _("stdout");
{
const cpp_token *token; /* The token forming op (for diagnostics). */
cpp_num value; /* The value logically "right" of op. */
- source_location loc; /* The location of this value. */
+ location_t loc; /* The location of this value. */
enum cpp_ttype op;
};
enum cpp_ttype);
static cpp_num num_mul (cpp_reader *, cpp_num, cpp_num);
static cpp_num num_div_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype,
- source_location);
+ location_t);
static cpp_num num_lshift (cpp_num, size_t, size_t);
static cpp_num num_rshift (cpp_num, size_t, size_t);
static cpp_num append_digit (cpp_num, int, int, size_t);
static cpp_num parse_defined (cpp_reader *);
-static cpp_num eval_token (cpp_reader *, const cpp_token *, source_location);
+static cpp_num eval_token (cpp_reader *, const cpp_token *, location_t);
static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype);
static unsigned int interpret_float_suffix (cpp_reader *, const uchar *, size_t);
static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
VIRTUAL_LOCATION is the virtual location for TOKEN. */
unsigned int
cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
- const char **ud_suffix, source_location virtual_location)
+ const char **ud_suffix, location_t virtual_location)
{
const uchar *str = token->val.str.text;
const uchar *limit;
operators). */
static cpp_num
eval_token (cpp_reader *pfile, const cpp_token *token,
- source_location virtual_location)
+ location_t virtual_location)
{
cpp_num result;
unsigned int temp;
struct op *top = pfile->op_stack;
unsigned int lex_count;
bool saw_leading_not, want_value = true;
- source_location virtual_location = 0;
+ location_t virtual_location = 0;
pfile->state.skip_eval = 0;
static cpp_num
num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op,
- source_location location)
+ location_t location)
{
cpp_num result, sub;
cpp_num_part mask;
{
struct cpp_file_hash_entry *next;
cpp_dir *start_dir;
- source_location location;
+ location_t location;
union
{
_cpp_file *file;
static bool pch_open_file (cpp_reader *pfile, _cpp_file *file,
bool *invalid_pch);
static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
- bool *invalid_pch, source_location loc);
+ bool *invalid_pch, location_t loc);
static bool read_file_guts (cpp_reader *pfile, _cpp_file *file,
- source_location loc);
+ location_t loc);
static bool read_file (cpp_reader *pfile, _cpp_file *file,
- source_location loc);
+ location_t loc);
static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import,
- source_location loc);
+ location_t loc);
static struct cpp_dir *search_path_head (cpp_reader *, const char *fname,
int angle_brackets, enum include_type);
static const char *dir_name_of_file (_cpp_file *file);
static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int,
- source_location);
+ location_t);
static struct cpp_file_hash_entry *search_cache (struct cpp_file_hash_entry *head,
const cpp_dir *start_dir);
static _cpp_file *make_cpp_file (cpp_reader *, cpp_dir *, const char *fname);
static bool
find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch,
- source_location loc)
+ location_t loc)
{
char *path;
_cpp_file *
_cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir,
bool fake, int angle_brackets, bool implicit_preinclude,
- source_location loc)
+ location_t loc)
{
struct cpp_file_hash_entry *entry;
void **hash_slot;
FIXME: Flush file cache and try again if we run out of memory. */
static bool
-read_file_guts (cpp_reader *pfile, _cpp_file *file, source_location loc)
+read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc)
{
ssize_t size, total, count;
uchar *buf;
have been passed through find_file() at some stage. Use LOC for
any diagnostics. */
static bool
-read_file (cpp_reader *pfile, _cpp_file *file, source_location loc)
+read_file (cpp_reader *pfile, _cpp_file *file, location_t loc)
{
/* If we already have its contents in memory, succeed immediately. */
if (file->buffer_valid)
Use LOC for any diagnostics. */
static bool
should_stack_file (cpp_reader *pfile, _cpp_file *file, bool import,
- source_location loc)
+ location_t loc)
{
_cpp_file *f;
stacked. Use LOC for any diagnostics. */
bool
_cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import,
- source_location loc)
+ location_t loc)
{
cpp_buffer *buffer;
int sysp;
Returns true if a buffer was stacked. */
bool
_cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets,
- enum include_type type, source_location loc)
+ enum include_type type, location_t loc)
{
struct cpp_dir *dir;
_cpp_file *file;
/* Compensate for the increment in linemap_add that occurs if
_cpp_stack_file actually stacks the file. In the case of a
normal #include, we're currently at the start of the line
- *following* the #include. A separate source_location for this
+ *following* the #include. A separate location_t for this
location makes no sense (until we do the LC_LEAVE), and
complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we
found a PCH file (in which case linemap_add is not called) or we
/* Could not open FILE. The complication is dependency output. */
static void
open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets,
- source_location loc)
+ location_t loc)
{
int sysp = pfile->line_table->highest_line > 1 && pfile->buffer ? pfile->buffer->sysp : 0;
bool print_dep = CPP_OPTION (pfile, deps.style) > (angle_brackets || !!sysp);
filenames aliased by links or redundant . or .. traversals etc. */
bool
cpp_included_before (cpp_reader *pfile, const char *fname,
- source_location location)
+ location_t location)
{
struct cpp_file_hash_entry *entry
= (struct cpp_file_hash_entry *)
/* A preprocessing token. This has been carefully packed and should
occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */
struct GTY(()) cpp_token {
- source_location src_loc; /* Location of first char of token,
- together with range of full token. */
+
+ /* Location of first char of token, together with range of full token. */
+ location_t src_loc;
+
ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */
unsigned short flags; /* flags - see above */
void (*file_change) (cpp_reader *, const line_map_ordinary *);
void (*dir_change) (cpp_reader *, const char *);
- void (*include) (cpp_reader *, source_location, const unsigned char *,
+ void (*include) (cpp_reader *, location_t, const unsigned char *,
const char *, int, const cpp_token **);
- void (*define) (cpp_reader *, source_location, cpp_hashnode *);
- void (*undef) (cpp_reader *, source_location, cpp_hashnode *);
- void (*ident) (cpp_reader *, source_location, const cpp_string *);
- void (*def_pragma) (cpp_reader *, source_location);
+ void (*define) (cpp_reader *, location_t, cpp_hashnode *);
+ void (*undef) (cpp_reader *, location_t, cpp_hashnode *);
+ void (*ident) (cpp_reader *, location_t, const cpp_string *);
+ void (*def_pragma) (cpp_reader *, location_t);
int (*valid_pch) (cpp_reader *, const char *, int);
void (*read_pch) (cpp_reader *, const char *, int, const char *);
missing_header_cb missing_header;
/* Callbacks for when a macro is expanded, or tested (whether
defined or not at the time) in #ifdef, #ifndef or "defined". */
- void (*used_define) (cpp_reader *, source_location, cpp_hashnode *);
- void (*used_undef) (cpp_reader *, source_location, cpp_hashnode *);
+ void (*used_define) (cpp_reader *, location_t, cpp_hashnode *);
+ void (*used_undef) (cpp_reader *, location_t, cpp_hashnode *);
/* Called before #define and #undef or other macro definition
changes are processed. */
void (*before_define) (cpp_reader *);
/* Called whenever a macro is expanded or tested.
Second argument is the location of the start of the current expansion. */
- void (*used) (cpp_reader *, source_location, cpp_hashnode *);
+ void (*used) (cpp_reader *, location_t, cpp_hashnode *);
/* Callback to identify whether an attribute exists. */
int (*has_attribute) (cpp_reader *);
The content contains the opening slash-star (or slash-slash),
and for C-style comments contains the closing star-slash. For
C++-style comments it does not include the terminating newline. */
- void (*comment) (cpp_reader *, source_location, const unsigned char *,
+ void (*comment) (cpp_reader *, location_t, const unsigned char *,
size_t);
/* Callback for filename remapping in __FILE__ and __BASE_FILE__ macro
} GTY ((desc ("%1.kind == cmk_assert"))) parm;
/* Definition line number. */
- source_location line;
+ location_t line;
/* Number of tokens in body, or bytes for traditional macros. */
/* Do we really need 2^32-1 range here? */
class cpp_string_location_reader {
public:
- cpp_string_location_reader (source_location src_loc,
+ cpp_string_location_reader (location_t src_loc,
line_maps *line_table);
source_range get_next ();
private:
- source_location m_loc;
+ location_t m_loc;
int m_offset_per_column;
line_maps *m_line_table;
};
const cpp_token *);
extern const cpp_token *cpp_get_token (cpp_reader *);
extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
- source_location *);
+ location_t *);
inline bool cpp_user_macro_p (const cpp_hashnode *node)
{
return node->type == NT_USER_MACRO;
extern const unsigned char *cpp_macro_definition (cpp_reader *,
cpp_hashnode *);
-inline source_location cpp_macro_definition_location (cpp_hashnode *node)
+inline location_t cpp_macro_definition_location (cpp_hashnode *node)
{
return node->value.macro->line;
}
/* Classify a CPP_NUMBER token. The return value is a combination of
the flags from the above sets. */
extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *,
- const char **, source_location);
+ const char **, location_t);
/* Return the classification flags for a float suffix. */
extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
/* Similarly, but with "FILENAME: " instead of "MSGID: ", where
the filename is not localized. */
extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level,
- const char *filename, source_location loc);
+ const char *filename, location_t loc);
/* Same as cpp_error, except additionally specifies a position as a
(translation unit) physical line and physical column. If the line is
zero, then no location is printed. */
extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level,
- source_location, unsigned,
+ location_t, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason,
- source_location, unsigned,
+ location_t, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason,
- source_location, unsigned,
+ location_t, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason,
- source_location, unsigned,
+ location_t, unsigned,
const char *msgid, ...)
ATTRIBUTE_PRINTF_5;
extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
- source_location src_loc, const char *msgid, ...)
+ location_t src_loc, const char *msgid, ...)
ATTRIBUTE_PRINTF_4;
extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
char *comment;
/* source location for the given comment. */
- source_location sloc;
+ location_t sloc;
} cpp_comment;
/* Structure holding all comments for a given cpp_reader. */
/* In files.c */
extern bool cpp_included (cpp_reader *, const char *);
-extern bool cpp_included_before (cpp_reader *, const char *, source_location);
+extern bool cpp_included_before (cpp_reader *, const char *, location_t);
extern void cpp_make_system_header (cpp_reader *, int, int);
extern bool cpp_push_include (cpp_reader *, const char *);
extern bool cpp_push_default_include (cpp_reader *, const char *);
struct save_macro_data *);
/* In lex.c */
-extern void cpp_force_token_locations (cpp_reader *, source_location);
+extern void cpp_force_token_locations (cpp_reader *, location_t);
extern void cpp_stop_forcing_token_locations (cpp_reader *);
/* In expr.c */
LC_HWM /* High Water Mark. */
};
-/* The typedef "source_location" is a key within the location database,
+/* The typedef "location_t" is a key within the location database,
identifying a source location or macro expansion, along with range
information, and (optionally) a pointer for use by gcc.
| macromap[1]->start_location | Start of macro map 1
-----------+-------------------------------+-------------------------------
| macromap[0]->start_location | Start of macro map 0
- 0x7fffffff | MAX_SOURCE_LOCATION | Also used as a mask for
+ 0x7fffffff | MAX_LOCATION_T | Also used as a mask for
| | accessing the ad-hoc data table
-----------+-------------------------------+-------------------------------
0x80000000 | Start of ad-hoc values; the lower 31 bits are used as an index
finish == ordmap->start + (23 << 12) + (19 << 5)
== ordmap->start + 0x17260
- To further see how source_location works in practice, see the
+ To further see how location_t works in practice, see the
worked example in libcpp/location-example.txt. */
-typedef unsigned int source_location;
+typedef unsigned int location_t;
/* Do not track column numbers higher than this one. As a result, the
range of column_bits is [12, 18] (or 0 if column numbers are
/* Do not pack ranges if locations get higher than this.
If you change this, update:
gcc.dg/plugin/location-overflow-test-*.c. */
-const source_location LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000;
+const location_t LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000;
/* Do not track column numbers if locations get higher than this.
If you change this, update:
gcc.dg/plugin/location-overflow-test-*.c. */
-const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000;
+const location_t LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000;
/* Highest possible source location encoded within an ordinary map. */
-const source_location LINE_MAP_MAX_LOCATION = 0x70000000;
+const location_t LINE_MAP_MAX_LOCATION = 0x70000000;
/* A range of source locations.
let's do it the simple way, as a pair. */
struct GTY(()) source_range
{
- source_location m_start;
- source_location m_finish;
+ location_t m_start;
+ location_t m_finish;
/* We avoid using constructors, since various structs that
don't yet have constructors will embed instances of
source_range. */
- /* Make a source_range from a source_location. */
- static source_range from_location (source_location loc)
+ /* Make a source_range from a location_t. */
+ static source_range from_location (location_t loc)
{
source_range result;
result.m_start = loc;
return result;
}
- /* Make a source_range from a pair of source_location. */
- static source_range from_locations (source_location start,
- source_location finish)
+ /* Make a source_range from a pair of location_t. */
+ static source_range from_locations (location_t start,
+ location_t finish)
{
source_range result;
result.m_start = start;
/* This contains GTY mark-up to support precompiled headers.
line_map is an abstract class, only derived objects exist. */
struct GTY((tag ("0"), desc ("MAP_ORDINARY_P (&%h) ? 1 : 2"))) line_map {
- source_location start_location;
+ location_t start_location;
/* Size and alignment is (usually) 4 bytes. */
};
(The top line is line 1 and the leftmost column is column 1; line/column 0
means "entire file/line" or "unknown line/column" or "not applicable".)
- The highest possible source location is MAX_SOURCE_LOCATION. */
+ The highest possible source location is MAX_LOCATION_T. */
struct GTY((tag ("1"))) line_map_ordinary : public line_map {
/* Base class is 4 bytes. */
cpp_buffer. */
unsigned char sysp;
- /* Number of the low-order source_location bits used for column numbers
+ /* Number of the low-order location_t bits used for column numbers
and ranges. */
unsigned int m_column_and_range_bits : 8;
/* Location from whence this line map was included. For regular
#includes, this location will be the last location of a map. For
outermost file, this is 0. */
- source_location included_from;
+ location_t included_from;
/* Size is 20 or 24 bytes, no padding */
};
/* This is the highest possible source location encoded within an
ordinary or macro map. */
-const source_location MAX_SOURCE_LOCATION = 0x7FFFFFFF;
+const location_t MAX_LOCATION_T = 0x7FFFFFFF;
struct cpp_hashnode;
In the example above x1 (for token "+") is going to be the same
as y1. x0 is the spelling location for the argument token "1",
and x2 is the spelling location for the argument token "2". */
- source_location * GTY((atomic)) macro_locations;
+ location_t * GTY((atomic)) macro_locations;
/* This is the location of the expansion point of the current macro
map. It's the location of the macro name. That location is held
by the map that was current right before the current one. It
could have been either a macro or an ordinary map, depending on
if we are in a nested expansion context not. */
- source_location expansion;
+ location_t expansion;
/* Size is 20 or 32 (4 bytes padding on 64-bit). */
};
/* Get whether location LOC is an ad-hoc, ordinary or macro location. */
inline bool
-IS_ORDINARY_LOC (source_location loc)
+IS_ORDINARY_LOC (location_t loc)
{
return loc < LINE_MAP_MAX_LOCATION;
}
inline bool
-IS_ADHOC_LOC (source_location loc)
+IS_ADHOC_LOC (location_t loc)
{
- return loc > MAX_SOURCE_LOCATION;
+ return loc > MAX_LOCATION_T;
}
inline bool
-IS_MACRO_LOC (source_location loc)
+IS_MACRO_LOC (location_t loc)
{
return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
}
/* Read the start location of MAP. */
-inline source_location
+inline location_t
MAP_START_LOCATION (const line_map *map)
{
return map->start_location;
/* Get the array of pairs of locations within macro map MAP.
See the declaration of line_map_macro for more information. */
-inline source_location *
+inline location_t *
MACRO_MAP_LOCATIONS (const line_map_macro *macro_map)
{
return macro_map->macro_locations;
/* Get the location of the expansion point of the macro map MAP. */
-inline source_location
+inline location_t
MACRO_MAP_EXPANSION_POINT_LOCATION (const line_map_macro *macro_map)
{
return macro_map->expansion;
/* Data structure to associate a source_range together with an arbitrary
data pointer with a source location. */
struct GTY(()) location_adhoc_data {
- source_location locus;
+ location_t locus;
source_range src_range;
void * GTY((skip)) data;
};
struct GTY(()) location_adhoc_data_map {
struct htab * GTY((skip)) htab;
- source_location curr_loc;
+ location_t curr_loc;
unsigned int allocated;
struct location_adhoc_data GTY((length ("%h.allocated"))) *data;
};
/* If true, prints an include trace a la -H. */
bool trace_includes;
- /* Highest source_location "given out". */
- source_location highest_location;
+ /* Highest location_t "given out". */
+ location_t highest_location;
- /* Start of line of highest source_location "given out". */
- source_location highest_line;
+ /* Start of line of highest location_t "given out". */
+ location_t highest_line;
/* The maximum column number we can quickly allocate. Higher numbers
may require allocating a new line_map. */
/* The special location value that is used as spelling location for
built-in tokens. */
- source_location builtin_location;
+ location_t builtin_location;
/* True if we've seen a #line or # 44 "file" directive. */
bool seen_line_directive;
/* Returns the lowest location [of a token resulting from macro
expansion] encoded in this line table. */
-inline source_location
+inline location_t
LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set)
{
return LINEMAPS_MACRO_USED (set)
? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set))
- : MAX_SOURCE_LOCATION + 1;
+ : MAX_LOCATION_T + 1;
}
/* Returns the last macro map allocated in the line table SET. */
return (line_map_macro *)LINEMAPS_LAST_ALLOCATED_MAP (set, true);
}
-extern source_location get_combined_adhoc_loc (struct line_maps *,
- source_location,
+extern location_t get_combined_adhoc_loc (struct line_maps *,
+ location_t,
source_range,
void *);
-extern void *get_data_from_adhoc_loc (struct line_maps *, source_location);
-extern source_location get_location_from_adhoc_loc (struct line_maps *,
- source_location);
+extern void *get_data_from_adhoc_loc (struct line_maps *, location_t);
+extern location_t get_location_from_adhoc_loc (struct line_maps *,
+ location_t);
-extern source_range get_range_from_loc (line_maps *set, source_location loc);
+extern source_range get_range_from_loc (line_maps *set, location_t loc);
/* Get whether location LOC is a "pure" location, or
whether it is an ad-hoc location, or embeds range information. */
bool
-pure_location_p (line_maps *set, source_location loc);
+pure_location_p (line_maps *set, location_t loc);
/* Given location LOC within SET, strip away any packed range information
or ad-hoc information. */
-extern source_location get_pure_location (line_maps *set,
- source_location loc);
+extern location_t get_pure_location (line_maps *set,
+ location_t loc);
/* Combine LOC and BLOCK, giving a combined adhoc location. */
-inline source_location
+inline location_t
COMBINE_LOCATION_DATA (struct line_maps *set,
- source_location loc,
+ location_t loc,
source_range src_range,
void *block)
{
spelling location for built-in tokens. This BUILTIN_LOCATION has
to be strictly less than RESERVED_LOCATION_COUNT. */
extern void linemap_init (struct line_maps *set,
- source_location builtin_location);
+ location_t builtin_location);
/* Check for and warn about line_maps entered but not exited. */
extern void linemap_check_files_exited (struct line_maps *);
-/* Return a source_location for the start (i.e. column==0) of
+/* Return a location_t for the start (i.e. column==0) of
(physical) line TO_LINE in the current source file (as in the
most recent linemap_add). MAX_COLUMN_HINT is the highest column
number we expect to use in this line (but it does not change
the highest_location). */
-extern source_location linemap_line_start
+extern location_t linemap_line_start
(struct line_maps *set, linenum_type to_line, unsigned int max_column_hint);
/* Add a mapping of logical source line to physical source file and
binary search. If no line map have been allocated yet, this
function returns NULL. */
extern const struct line_map *linemap_lookup
- (struct line_maps *, source_location);
+ (struct line_maps *, location_t);
/* Returns TRUE if the line table set tracks token locations across
macro expansion, FALSE otherwise. */
that is part of a macro replacement-list defined in a system
header, but expanded in a non-system file. */
int linemap_location_in_system_header_p (struct line_maps *,
- source_location);
+ location_t);
/* Return TRUE if LOCATION is a source code location of a token that is part of
a macro expansion, FALSE otherwise. */
bool linemap_location_from_macro_expansion_p (const struct line_maps *,
- source_location);
+ location_t);
/* TRUE if LOCATION is a source code location of a token that is part of the
definition of a macro, FALSE otherwise. */
bool linemap_location_from_macro_definition_p (struct line_maps *,
- source_location);
+ location_t);
/* With the precondition that LOCATION is the locus of a token that is
an argument of a function-like macro MACRO_MAP and appears in the
expansion of MACRO_MAP, return the locus of that argument in the
context of the caller of MACRO_MAP. */
-extern source_location linemap_macro_map_loc_unwind_toward_spelling
- (line_maps *set, const line_map_macro *macro_map, source_location location);
+extern location_t linemap_macro_map_loc_unwind_toward_spelling
+ (line_maps *set, const line_map_macro *macro_map, location_t location);
-/* source_location values from 0 to RESERVED_LOCATION_COUNT-1 will
+/* location_t values from 0 to RESERVED_LOCATION_COUNT-1 will
be reserved for libcpp user as special values, no token from libcpp
will contain any of those locations. */
-const source_location RESERVED_LOCATION_COUNT = 2;
+const location_t RESERVED_LOCATION_COUNT = 2;
-/* Converts a map and a source_location to source line. */
+/* Converts a map and a location_t to source line. */
inline linenum_type
-SOURCE_LINE (const line_map_ordinary *ord_map, source_location loc)
+SOURCE_LINE (const line_map_ordinary *ord_map, location_t loc)
{
return ((loc - ord_map->start_location)
>> ord_map->m_column_and_range_bits) + ord_map->to_line;
}
-/* Convert a map and source_location to source column number. */
+/* Convert a map and location_t to source column number. */
inline linenum_type
-SOURCE_COLUMN (const line_map_ordinary *ord_map, source_location loc)
+SOURCE_COLUMN (const line_map_ordinary *ord_map, location_t loc)
{
return ((loc - ord_map->start_location)
& ((1 << ord_map->m_column_and_range_bits) - 1)) >> ord_map->m_range_bits;
}
-inline source_location
+inline location_t
linemap_included_from (const line_map_ordinary *ord_map)
{
return ord_map->included_from;
return ord_map->included_from == 0;
}
-/* Encode and return a source_location from a column number. The
+/* Encode and return a location_t from a column number. The
source line considered is the last source line used to call
linemap_line_start, i.e, the last source line which a location was
encoded from. */
-extern source_location
+extern location_t
linemap_position_for_column (struct line_maps *, unsigned int);
/* Encode and return a source location from a given line and
column. */
-source_location
+location_t
linemap_position_for_line_and_column (line_maps *set,
const line_map_ordinary *,
linenum_type, unsigned int);
-/* Encode and return a source_location starting from location LOC and
+/* Encode and return a location_t starting from location LOC and
shifting it by OFFSET columns. This function does not support
virtual locations. */
-source_location
+location_t
linemap_position_for_loc_and_offset (struct line_maps *set,
- source_location loc,
+ location_t loc,
unsigned int offset);
/* Return the file this map is for. */
the same token as the token for POST, and a negative value
otherwise. */
int linemap_compare_locations (struct line_maps *set,
- source_location pre,
- source_location post);
+ location_t pre,
+ location_t post);
/* Return TRUE if LOC_A denotes the location a token that comes
topogically before the token denoted by location LOC_B, or if they
are equal. */
inline bool
linemap_location_before_p (struct line_maps *set,
- source_location loc_a,
- source_location loc_b)
+ location_t loc_a,
+ location_t loc_b)
{
return linemap_compare_locations (set, loc_a, loc_b) >= 0;
}
struct location_range
{
- source_location m_loc;
+ location_t m_loc;
enum range_display_kind m_range_display_kind;
Adding a fix-it hint can fail: for example, attempts to insert content
at the transition between two line maps may fail due to there being no
- source_location (aka location_t) value to express the new location.
+ location_t value to express the new location.
Attempts to add a fix-it hint within a macro expansion will fail.
/* Constructors. */
/* Constructing from a location. */
- rich_location (line_maps *set, source_location loc,
+ rich_location (line_maps *set, location_t loc,
const range_label *label = NULL);
/* Destructor. */
~rich_location ();
/* Accessors. */
- source_location get_loc () const { return get_loc (0); }
- source_location get_loc (unsigned int idx) const;
+ location_t get_loc () const { return get_loc (0); }
+ location_t get_loc (unsigned int idx) const;
void
- add_range (source_location loc,
+ add_range (location_t loc,
enum range_display_kind range_display_kind
= SHOW_RANGE_WITHOUT_CARET,
const range_label *label = NULL);
void
- set_range (unsigned int idx, source_location loc,
+ set_range (unsigned int idx, location_t loc,
enum range_display_kind range_display_kind);
unsigned int get_num_locations () const { return m_ranges.count (); }
/* Suggest inserting NEW_CONTENT immediately before the start of WHERE. */
void
- add_fixit_insert_before (source_location where,
+ add_fixit_insert_before (location_t where,
const char *new_content);
/* Suggest inserting NEW_CONTENT immediately after the end of the primary
/* Suggest inserting NEW_CONTENT immediately after the end of WHERE. */
void
- add_fixit_insert_after (source_location where,
+ add_fixit_insert_after (location_t where,
const char *new_content);
/* Methods for adding removal fix-it hints. */
/* Suggest removing the content covered between the start and finish
of WHERE. */
void
- add_fixit_remove (source_location where);
+ add_fixit_remove (location_t where);
/* Suggest removing the content covered by SRC_RANGE. */
void
/* Suggest replacing the content between the start and finish of
WHERE with NEW_CONTENT. */
void
- add_fixit_replace (source_location where,
+ add_fixit_replace (location_t where,
const char *new_content);
/* Suggest replacing the content covered by SRC_RANGE with
}
private:
- bool reject_impossible_fixit (source_location where);
+ bool reject_impossible_fixit (location_t where);
void stop_supporting_fixits ();
- void maybe_add_fixit (source_location start,
- source_location next_loc,
+ void maybe_add_fixit (location_t start,
+ location_t next_loc,
const char *new_content);
public:
class fixit_hint
{
public:
- fixit_hint (source_location start,
- source_location next_loc,
+ fixit_hint (location_t start,
+ location_t next_loc,
const char *new_content);
~fixit_hint () { free (m_bytes); }
bool affects_line_p (const char *file, int line) const;
- source_location get_start_loc () const { return m_start; }
- source_location get_next_loc () const { return m_next_loc; }
- bool maybe_append (source_location start,
- source_location next_loc,
+ location_t get_start_loc () const { return m_start; }
+ location_t get_next_loc () const { return m_next_loc; }
+ bool maybe_append (location_t start,
+ location_t next_loc,
const char *new_content);
const char *get_string () const { return m_bytes; }
this is a half-open/half-closed range:
[start, next_loc)
so that we can support insertion via start == next_loc. */
- source_location m_start;
- source_location m_next_loc;
+ location_t m_start;
+ location_t m_next_loc;
char *m_bytes;
size_t m_len;
};
resolves to a location reserved for the client code, like
UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */
-source_location linemap_resolve_location (struct line_maps *,
- source_location loc,
- enum location_resolution_kind lrk,
- const line_map_ordinary **loc_map);
+location_t linemap_resolve_location (struct line_maps *,
+ location_t loc,
+ enum location_resolution_kind lrk,
+ const line_map_ordinary **loc_map);
/* Suppose that LOC is the virtual location of a token coming from the
expansion of a macro M. This function then steps up to get the
the point where M' was expanded. LOC_MAP is an output parameter.
When non-NULL, *LOC_MAP is set to the map of the returned
location. */
-source_location linemap_unwind_toward_expansion (struct line_maps *,
- source_location loc,
- const struct line_map **loc_map);
+location_t linemap_unwind_toward_expansion (struct line_maps *,
+ location_t loc,
+ const struct line_map **loc_map);
/* If LOC is the virtual location of a token coming from the expansion
of a macro M and if its spelling location is reserved (e.g, a
*MAP is set to the map of the returned location if the later is
different from LOC. */
-source_location linemap_unwind_to_first_non_reserved_loc (struct line_maps *,
- source_location loc,
- const struct line_map **map);
+location_t linemap_unwind_to_first_non_reserved_loc (struct line_maps *,
+ location_t loc,
+ const struct line_map **map);
/* Expand source code location LOC and return a user readable source
code location. LOC must be a spelling (non-virtual) location. If
location is returned. */
expanded_location linemap_expand_location (struct line_maps *,
const struct line_map *,
- source_location loc);
+ location_t loc);
/* Statistics about maps allocation and usage as returned by
linemap_get_statistics. */
location emitted for that file. */
bool linemap_get_file_highest_location (struct line_maps * set,
const char *file_name,
- source_location *loc);
+ location_t *loc);
/* Compute and return statistics about the memory consumption of some
parts of the line table SET. */
/* Dump debugging information about source location LOC into the file
stream STREAM. SET is the line map set LOC comes from. */
-void linemap_dump_location (struct line_maps *, source_location, FILE *);
+void linemap_dump_location (struct line_maps *, location_t, FILE *);
/* Dump line map at index IX in line table SET to STREAM. If STREAM
is NULL, use stderr. IS_MACRO is true if the caller wants to
specifies how many macro maps to dump. */
void line_table_dump (FILE *, struct line_maps *, unsigned int, unsigned int);
-/* An enum for distinguishing the various parts within a source_location. */
+/* An enum for distinguishing the various parts within a location_t. */
enum location_aspect
{
LOCATION_ASPECT_FINISH
};
-/* The rich_location class requires a way to expand source_location instances.
+/* The rich_location class requires a way to expand location_t instances.
We would directly use expand_location_to_spelling_point, which is
implemented in gcc/input.c, but we also need to use it for rich_location
within genmatch.c.
Hence we require client code of libcpp to implement the following
symbol. */
extern expanded_location
-linemap_client_expand_location_to_spelling_point (source_location,
+linemap_client_expand_location_to_spelling_point (location_t,
enum location_aspect);
#endif /* !LIBCPP_LINE_MAP_H */
const char *
cpp_read_main_file (cpp_reader *pfile, const char *fname)
{
- const source_location loc = 0;
+ const location_t loc = 0;
if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
{
location at index 0 is the virtual location of the token at index
0 in the current instance of cpp_context; similarly for all the
other virtual locations. */
- source_location *virt_locs;
+ location_t *virt_locs;
/* This is a pointer to the current virtual location. This is used
to iterate over the virtual locations while we iterate over the
tokens they belong to. */
- source_location *cur_virt_loc;
+ location_t *cur_virt_loc;
} macro_context;
/* The kind of tokens carried by a cpp_context. */
unsigned char *definition;
/* Definition line number. */
- source_location line;
+ location_t line;
/* If macro defined in system header. */
unsigned int syshdr : 1;
/* Nonzero if it has been expanded or had its existence tested. */
struct line_maps *line_table;
/* The line of the '#' of the current directive. */
- source_location directive_line;
+ location_t directive_line;
/* Memory buffers. */
_cpp_buff *a_buff; /* Aligned permanent storage. */
/* When expanding a macro at top-level, this is the location of the
macro invocation. */
- source_location invocation_location;
+ location_t invocation_location;
/* This is the node representing the macro being expanded at
top-level. The value of this data member is valid iff
unsigned char *base;
unsigned char *limit;
unsigned char *cur;
- source_location first_line;
+ location_t first_line;
} out;
/* Used for buffer overlays by traditional.c. */
/* If non-zero, the lexer will use this location for the next token
instead of getting a location from the linemap. */
- source_location forced_token_location;
+ location_t forced_token_location;
};
/* Character classes. Based on the more primitive macros in safe-ctype.h.
unsigned int);
extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *,
cpp_hashnode *,
- source_location = 0);
+ location_t = 0);
extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *);
extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *,
const cpp_token *, unsigned int);
/* In files.c */
typedef struct _cpp_file _cpp_file;
extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *,
- bool, int, bool, source_location);
+ bool, int, bool, location_t);
extern bool _cpp_find_failed (_cpp_file *);
extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *);
extern void _cpp_fake_include (cpp_reader *, const char *);
extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, bool,
- source_location);
+ location_t);
extern bool _cpp_stack_include (cpp_reader *, const char *, int,
- enum include_type, source_location);
+ enum include_type, location_t);
extern int _cpp_compare_file_date (cpp_reader *, const char *, int);
extern void _cpp_report_missing_guards (cpp_reader *);
extern void _cpp_init_files (cpp_reader *);
extern void _cpp_define_builtin (cpp_reader *, const char *);
extern char ** _cpp_save_pragma_names (cpp_reader *);
extern void _cpp_restore_pragma_names (cpp_reader *, char **);
-extern int _cpp_do__Pragma (cpp_reader *, source_location);
+extern int _cpp_do__Pragma (cpp_reader *, location_t);
extern void _cpp_init_directives (cpp_reader *);
extern void _cpp_init_internal_pragmas (cpp_reader *);
extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
{
/* Called to print a block of lines. */
void (*print_lines) (int, const void *, size_t);
- bool (*maybe_print_line) (source_location);
+ bool (*maybe_print_line) (location_t);
};
extern void _cpp_preprocess_dir_only (cpp_reader *,
the replacement-list of MACRO. */
const line_map_macro *linemap_enter_macro (struct line_maps *,
struct cpp_hashnode*,
- source_location,
+ location_t,
unsigned int);
/* Create and return a virtual location for a token that is part of a
MACRO_DEFINITION_LOC is the location in the macro definition,
either of the token itself or of a macro parameter that it
replaces. */
-source_location linemap_add_macro_token (const line_map_macro *,
- unsigned int,
- source_location,
- source_location);
+location_t linemap_add_macro_token (const line_map_macro *,
+ unsigned int,
+ location_t,
+ location_t);
/* Return the source line number corresponding to source location
LOCATION. SET is the line map set LOCATION comes from. If
expansion-list of a macro expansion return the line number of the
macro expansion point. */
int linemap_get_expansion_line (struct line_maps *,
- source_location);
+ location_t);
/* Return the path of the file corresponding to source code location
LOCATION.
SET is the line map set LOCATION comes from. */
const char* linemap_get_expansion_filename (struct line_maps *,
- source_location);
+ location_t);
#ifdef __cplusplus
}
skip_line_comment (cpp_reader *pfile)
{
cpp_buffer *buffer = pfile->buffer;
- source_location orig_line = pfile->line_table->highest_line;
+ location_t orig_line = pfile->line_table->highest_line;
while (*buffer->cur != '\n')
buffer->cur++;
_cpp_process_line_notes (pfile, false);
if (!_cpp_get_fresh_line (pfile))
{
- source_location src_loc = token->src_loc;
+ location_t src_loc = token->src_loc;
token->type = CPP_EOF;
/* Tell the compiler the line number of the EOF token. */
token->src_loc = pfile->line_table->highest_line;
}
/* All tokens lexed in R after calling this function will be forced to
- have their source_location to be P, until
+ have their location_t to be P, until
cpp_stop_forcing_token_locations is called for R. */
void
-cpp_force_token_locations (cpp_reader *r, source_location loc)
+cpp_force_token_locations (cpp_reader *r, location_t loc)
{
r->forced_token_location = loc;
}
static void trace_include (const struct line_maps *, const line_map_ordinary *);
static const line_map_ordinary * linemap_ordinary_map_lookup (struct line_maps *,
- source_location);
+ location_t);
static const line_map_macro* linemap_macro_map_lookup (struct line_maps *,
- source_location);
-static source_location linemap_macro_map_loc_to_def_point
-(const line_map_macro *, source_location);
-static source_location linemap_macro_map_loc_to_exp_point
-(const line_map_macro *, source_location);
-static source_location linemap_macro_loc_to_spelling_point
-(struct line_maps *, source_location, const line_map_ordinary **);
-static source_location linemap_macro_loc_to_def_point (struct line_maps *,
- source_location,
- const line_map_ordinary **);
-static source_location linemap_macro_loc_to_exp_point (struct line_maps *,
- source_location,
- const line_map_ordinary **);
+ location_t);
+static location_t linemap_macro_map_loc_to_def_point
+(const line_map_macro *, location_t);
+static location_t linemap_macro_map_loc_to_exp_point
+(const line_map_macro *, location_t);
+static location_t linemap_macro_loc_to_spelling_point
+(struct line_maps *, location_t, const line_map_ordinary **);
+static location_t linemap_macro_loc_to_def_point (line_maps *,
+ location_t,
+ const line_map_ordinary **);
+static location_t linemap_macro_loc_to_exp_point (line_maps *,
+ location_t,
+ const line_map_ordinary **);
/* Counters defined in macro.c. */
extern unsigned num_expanded_macros_counter;
/* Helper function for get_combined_adhoc_loc.
Can the given LOCUS + SRC_RANGE and DATA pointer be stored compactly
- within a source_location, without needing to use an ad-hoc location. */
+ within a location_t, without needing to use an ad-hoc location. */
static bool
can_be_stored_compactly_p (struct line_maps *set,
- source_location locus,
+ location_t locus,
source_range src_range,
void *data)
{
/* If there's an ad-hoc pointer, we can't store it directly in the
- source_location, we need the lookaside. */
+ location_t, we need the lookaside. */
if (data)
return false;
/* All 3 locations must be within ordinary maps, typically, the same
ordinary map. */
- source_location lowest_macro_loc = LINEMAPS_MACRO_LOWEST_LOCATION (set);
+ location_t lowest_macro_loc = LINEMAPS_MACRO_LOWEST_LOCATION (set);
if (locus >= lowest_macro_loc)
return false;
if (src_range.m_start >= lowest_macro_loc)
/* Combine LOCUS and DATA to a combined adhoc loc. */
-source_location
+location_t
get_combined_adhoc_loc (struct line_maps *set,
- source_location locus,
+ location_t locus,
source_range src_range,
void *data)
{
if (IS_ADHOC_LOC (locus))
locus
- = set->location_adhoc_data_map.data[locus & MAX_SOURCE_LOCATION].locus;
+ = set->location_adhoc_data_map.data[locus & MAX_LOCATION_T].locus;
if (locus == 0 && data == NULL)
return 0;
unsigned int col_diff = (int_diff >> ordmap->m_range_bits);
if (col_diff < (1U << ordmap->m_range_bits))
{
- source_location packed = locus | col_diff;
+ location_t packed = locus | col_diff;
set->num_optimized_ranges++;
return packed;
}
/* Return the data for the adhoc loc. */
void *
-get_data_from_adhoc_loc (struct line_maps *set, source_location loc)
+get_data_from_adhoc_loc (struct line_maps *set, location_t loc)
{
linemap_assert (IS_ADHOC_LOC (loc));
- return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].data;
+ return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data;
}
/* Return the location for the adhoc loc. */
-source_location
-get_location_from_adhoc_loc (struct line_maps *set, source_location loc)
+location_t
+get_location_from_adhoc_loc (struct line_maps *set, location_t loc)
{
linemap_assert (IS_ADHOC_LOC (loc));
- return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
}
/* Return the source_range for adhoc location LOC. */
static source_range
-get_range_from_adhoc_loc (struct line_maps *set, source_location loc)
+get_range_from_adhoc_loc (struct line_maps *set, location_t loc)
{
linemap_assert (IS_ADHOC_LOC (loc));
- return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].src_range;
+ return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].src_range;
}
/* Get the source_range of location LOC, either from the ad-hoc
source_range
get_range_from_loc (struct line_maps *set,
- source_location loc)
+ location_t loc)
{
if (IS_ADHOC_LOC (loc))
return get_range_from_adhoc_loc (set, loc);
whether it is an ad-hoc location, or embeds range information. */
bool
-pure_location_p (line_maps *set, source_location loc)
+pure_location_p (line_maps *set, location_t loc)
{
if (IS_ADHOC_LOC (loc))
return false;
/* Given location LOC within SET, strip away any packed range information
or ad-hoc information. */
-source_location
-get_pure_location (line_maps *set, source_location loc)
+location_t
+get_pure_location (line_maps *set, location_t loc)
{
if (IS_ADHOC_LOC (loc))
loc
- = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (set))
return loc;
void
linemap_init (struct line_maps *set,
- source_location builtin_location)
+ location_t builtin_location)
{
#if __GNUC__ == 4 && __GNUC_MINOR__ == 2 && !defined (__clang__)
/* PR33916, needed to fix PR82939. */
macro maps are allocated in different memory location. */
static struct line_map *
-new_linemap (struct line_maps *set, source_location start_location)
+new_linemap (struct line_maps *set, location_t start_location)
{
bool macro_p = start_location >= LINE_MAP_MAX_LOCATION;
unsigned num_maps_allocated = LINEMAPS_ALLOCATED (set, macro_p);
{
/* Generate a start_location above the current highest_location.
If possible, make the low range bits be zero. */
- source_location start_location;
+ location_t start_location;
if (set->highest_location < LINE_MAP_MAX_LOCATION_WITH_COLS)
{
start_location = set->highest_location + (1 << set->default_range_bits);
const line_map_macro *
linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node,
- source_location expansion, unsigned int num_tokens)
+ location_t expansion, unsigned int num_tokens)
{
- source_location start_location
+ location_t start_location
= LINEMAPS_MACRO_LOWEST_LOCATION (set) - num_tokens;
if (start_location < LINE_MAP_MAX_LOCATION)
map->macro = macro_node;
map->n_tokens = num_tokens;
map->macro_locations
- = (source_location*) set->reallocator (NULL,
+ = (location_t*) set->reallocator (NULL,
2 * num_tokens
- * sizeof (source_location));
+ * sizeof (location_t));
map->expansion = expansion;
memset (MACRO_MAP_LOCATIONS (map), 0,
- 2 * num_tokens * sizeof (source_location));
+ 2 * num_tokens * sizeof (location_t));
LINEMAPS_MACRO_CACHE (set) = LINEMAPS_MACRO_USED (set) - 1;
either of the token itself or of a macro parameter that it
replaces. */
-source_location
+location_t
linemap_add_macro_token (const line_map_macro *map,
unsigned int token_no,
- source_location orig_loc,
- source_location orig_parm_replacement_loc)
+ location_t orig_loc,
+ location_t orig_parm_replacement_loc)
{
- source_location result;
+ location_t result;
linemap_assert (linemap_macro_expansion_map_p (map));
linemap_assert (token_no < MACRO_MAP_NUM_MACRO_TOKENS (map));
return result;
}
-/* Return a source_location for the start (i.e. column==0) of
+/* Return a location_t for the start (i.e. column==0) of
(physical) line TO_LINE in the current source file (as in the
most recent linemap_add). MAX_COLUMN_HINT is the highest column
number we expect to use in this line (but it does not change
the highest_location). */
-source_location
+location_t
linemap_line_start (struct line_maps *set, linenum_type to_line,
unsigned int max_column_hint)
{
line_map_ordinary *map = LINEMAPS_LAST_ORDINARY_MAP (set);
- source_location highest = set->highest_location;
- source_location r;
+ location_t highest = set->highest_location;
+ location_t r;
linenum_type last_line =
SOURCE_LINE (map, set->highest_line);
int line_delta = to_line - last_line;
|| highest > LINE_MAP_MAX_LOCATION_WITH_COLS)
{
/* If the column number is ridiculous or we've allocated a huge
- number of source_locations, give up on column numbers
+ number of location_ts, give up on column numbers
(and on packed ranges). */
max_column_hint = 0;
column_bits = 0;
return r;
}
-/* Encode and return a source_location from a column number. The
+/* Encode and return a location_t from a column number. The
source line considered is the last source line used to call
linemap_line_start, i.e, the last source line which a location was
encoded from. */
-source_location
+location_t
linemap_position_for_column (struct line_maps *set, unsigned int to_column)
{
- source_location r = set->highest_line;
+ location_t r = set->highest_line;
linemap_assert
(!linemap_macro_expansion_map_p (LINEMAPS_LAST_ORDINARY_MAP (set)));
if (r > LINE_MAP_MAX_LOCATION_WITH_COLS
|| to_column > LINE_MAP_MAX_COLUMN_NUMBER)
{
- /* Running low on source_locations - disable column numbers. */
+ /* Running low on location_ts - disable column numbers. */
return r;
}
else
/* Encode and return a source location from a given line and
column. */
-source_location
+location_t
linemap_position_for_line_and_column (line_maps *set,
const line_map_ordinary *ord_map,
linenum_type line,
{
linemap_assert (ORDINARY_MAP_STARTING_LINE_NUMBER (ord_map) <= line);
- source_location r = MAP_START_LOCATION (ord_map);
+ location_t r = MAP_START_LOCATION (ord_map);
r += ((line - ORDINARY_MAP_STARTING_LINE_NUMBER (ord_map))
<< ord_map->m_column_and_range_bits);
if (r <= LINE_MAP_MAX_LOCATION_WITH_COLS)
r += ((column & ((1 << ord_map->m_column_and_range_bits) - 1))
<< ord_map->m_range_bits);
- source_location upper_limit = LINEMAPS_MACRO_LOWEST_LOCATION (set);
+ location_t upper_limit = LINEMAPS_MACRO_LOWEST_LOCATION (set);
if (r >= upper_limit)
r = upper_limit - 1;
if (r > set->highest_location)
return r;
}
-/* Encode and return a source_location starting from location LOC and
+/* Encode and return a location_t starting from location LOC and
shifting it by COLUMN_OFFSET columns. This function does not support
virtual locations. */
-source_location
+location_t
linemap_position_for_loc_and_offset (struct line_maps *set,
- source_location loc,
+ location_t loc,
unsigned int column_offset)
{
const line_map_ordinary * map = NULL;
if (IS_ADHOC_LOC (loc))
- loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
/* This function does not support virtual locations yet. */
if (linemap_location_from_macro_expansion_p (set, loc))
if (column >= (1u << (map->m_column_and_range_bits - map->m_range_bits)))
return loc;
- source_location r =
+ location_t r =
linemap_position_for_line_and_column (set, map, line, column);
if (linemap_assert_fails (r <= set->highest_location)
|| linemap_assert_fails (map == linemap_lookup (set, r)))
ordinary or a macro map), returns that map. */
const struct line_map*
-linemap_lookup (struct line_maps *set, source_location line)
+linemap_lookup (struct line_maps *set, location_t line)
{
if (IS_ADHOC_LOC (line))
- line = set->location_adhoc_data_map.data[line & MAX_SOURCE_LOCATION].locus;
+ line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus;
if (linemap_location_from_macro_expansion_p (set, line))
return linemap_macro_map_lookup (set, line);
return linemap_ordinary_map_lookup (set, line);
binary search. */
static const line_map_ordinary *
-linemap_ordinary_map_lookup (struct line_maps *set, source_location line)
+linemap_ordinary_map_lookup (struct line_maps *set, location_t line)
{
unsigned int md, mn, mx;
const line_map_ordinary *cached, *result;
if (IS_ADHOC_LOC (line))
- line = set->location_adhoc_data_map.data[line & MAX_SOURCE_LOCATION].locus;
+ line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus;
if (set == NULL || line < RESERVED_LOCATION_COUNT)
return NULL;
binary search. */
static const line_map_macro *
-linemap_macro_map_lookup (struct line_maps *set, source_location line)
+linemap_macro_map_lookup (struct line_maps *set, location_t line)
{
unsigned int md, mn, mx;
const struct line_map_macro *cached, *result;
if (IS_ADHOC_LOC (line))
- line = set->location_adhoc_data_map.data[line & MAX_SOURCE_LOCATION].locus;
+ line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus;
linemap_assert (line >= LINEMAPS_MACRO_LOWEST_LOCATION (set));
Read the comments of struct line_map and struct line_map_macro in
line-map.h to understand what a macro expansion point is. */
-static source_location
+static location_t
linemap_macro_map_loc_to_exp_point (const line_map_macro *map,
- source_location location ATTRIBUTE_UNUSED)
+ location_t location ATTRIBUTE_UNUSED)
{
linemap_assert (linemap_macro_expansion_map_p (map)
&& location >= MAP_START_LOCATION (map));
Return the location of the token at the definition point of the
macro. */
-static source_location
+static location_t
linemap_macro_map_loc_to_def_point (const line_map_macro *map,
- source_location location)
+ location_t location)
{
unsigned token_no;
In other words, this returns the xI location presented in the
comments of line_map_macro above. */
-source_location
+location_t
linemap_macro_map_loc_unwind_toward_spelling (line_maps *set,
const line_map_macro* map,
- source_location location)
+ location_t location)
{
unsigned token_no;
int
linemap_get_expansion_line (struct line_maps *set,
- source_location location)
+ location_t location)
{
const line_map_ordinary *map = NULL;
if (IS_ADHOC_LOC (location))
location = set->location_adhoc_data_map.data[location
- & MAX_SOURCE_LOCATION].locus;
+ & MAX_LOCATION_T].locus;
if (location < RESERVED_LOCATION_COUNT)
return 0;
const char*
linemap_get_expansion_filename (struct line_maps *set,
- source_location location)
+ location_t location)
{
const struct line_map_ordinary *map = NULL;
if (IS_ADHOC_LOC (location))
location = set->location_adhoc_data_map.data[location
- & MAX_SOURCE_LOCATION].locus;
+ & MAX_LOCATION_T].locus;
if (location < RESERVED_LOCATION_COUNT)
return NULL;
int
linemap_location_in_system_header_p (struct line_maps *set,
- source_location location)
+ location_t location)
{
const struct line_map *map = NULL;
if (IS_ADHOC_LOC (location))
location = set->location_adhoc_data_map.data[location
- & MAX_SOURCE_LOCATION].locus;
+ & MAX_LOCATION_T].locus;
if (location < RESERVED_LOCATION_COUNT)
return false;
const line_map_macro *macro_map = linemap_check_macro (map);
/* It's a token resulting from a macro expansion. */
- source_location loc =
+ location_t loc =
linemap_macro_map_loc_unwind_toward_spelling (set, macro_map, location);
if (loc < RESERVED_LOCATION_COUNT)
/* This token might come from a built-in macro. Let's
bool
linemap_location_from_macro_expansion_p (const struct line_maps *set,
- source_location location)
+ location_t location)
{
if (IS_ADHOC_LOC (location))
location = set->location_adhoc_data_map.data[location
- & MAX_SOURCE_LOCATION].locus;
+ & MAX_LOCATION_T].locus;
return IS_MACRO_LOC (location);
}
static const struct line_map*
first_map_in_common_1 (struct line_maps *set,
- source_location *loc0,
- source_location *loc1)
+ location_t *loc0,
+ location_t *loc1)
{
- source_location l0 = *loc0, l1 = *loc1;
+ location_t l0 = *loc0, l1 = *loc1;
const struct line_map *map0 = linemap_lookup (set, l0),
*map1 = linemap_lookup (set, l1);
static const struct line_map*
first_map_in_common (struct line_maps *set,
- source_location loc0,
- source_location loc1,
- source_location *res_loc0,
- source_location *res_loc1)
+ location_t loc0,
+ location_t loc1,
+ location_t *res_loc0,
+ location_t *res_loc1)
{
*res_loc0 = loc0;
*res_loc1 = loc1;
int
linemap_compare_locations (struct line_maps *set,
- source_location pre,
- source_location post)
+ location_t pre,
+ location_t post)
{
bool pre_virtual_p, post_virtual_p;
- source_location l0 = pre, l1 = post;
+ location_t l0 = pre, l1 = post;
if (IS_ADHOC_LOC (l0))
l0 = get_location_from_adhoc_loc (set, l0);
This is a subroutine for linemap_resolve_location. */
-static source_location
+static location_t
linemap_macro_loc_to_spelling_point (struct line_maps *set,
- source_location location,
+ location_t location,
const line_map_ordinary **original_map)
{
linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
This is a subroutine of linemap_resolve_location. */
-static source_location
+static location_t
linemap_macro_loc_to_def_point (struct line_maps *set,
- source_location location,
+ location_t location,
const line_map_ordinary **original_map)
{
linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
for (;;)
{
- source_location caret_loc = location;
+ location_t caret_loc = location;
if (IS_ADHOC_LOC (caret_loc))
caret_loc = get_location_from_adhoc_loc (set, caret_loc);
This is a subroutine of linemap_resolve_location. */
-static source_location
+static location_t
linemap_macro_loc_to_exp_point (struct line_maps *set,
- source_location location,
+ location_t location,
const line_map_ordinary **original_map)
{
struct line_map *map;
if (IS_ADHOC_LOC (location))
location = set->location_adhoc_data_map.data[location
- & MAX_SOURCE_LOCATION].locus;
+ & MAX_LOCATION_T].locus;
linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
resolves to a location reserved for the client code, like
UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */
-source_location
+location_t
linemap_resolve_location (struct line_maps *set,
- source_location loc,
+ location_t loc,
enum location_resolution_kind lrk,
const line_map_ordinary **map)
{
- source_location locus = loc;
+ location_t locus = loc;
if (IS_ADHOC_LOC (loc))
- locus = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ locus = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
if (locus < RESERVED_LOCATION_COUNT)
{
bool
linemap_location_from_macro_definition_p (struct line_maps *set,
- source_location loc)
+ location_t loc)
{
if (IS_ADHOC_LOC (loc))
loc = get_location_from_adhoc_loc (set, loc);
const struct line_map_macro *map
= linemap_check_macro (linemap_lookup (set, loc));
- source_location s_loc
+ location_t s_loc
= linemap_macro_map_loc_unwind_toward_spelling (set, map, loc);
if (linemap_location_from_macro_expansion_p (set, s_loc))
loc = s_loc;
else
{
- source_location def_loc
+ location_t def_loc
= linemap_macro_map_loc_to_def_point (map, loc);
return s_loc == def_loc;
}
*LOC_MAP must be set to the map of LOC. This function then sets it
to the map of the returned location. */
-source_location
+location_t
linemap_unwind_toward_expansion (struct line_maps *set,
- source_location loc,
+ location_t loc,
const struct line_map **map)
{
- source_location resolved_location;
+ location_t resolved_location;
const line_map_macro *macro_map = linemap_check_macro (*map);
const struct line_map *resolved_map;
if (IS_ADHOC_LOC (loc))
- loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
resolved_location =
linemap_macro_map_loc_unwind_toward_spelling (set, macro_map, loc);
*MAP is set to the map of the returned location if the later is
different from LOC. */
-source_location
+location_t
linemap_unwind_to_first_non_reserved_loc (struct line_maps *set,
- source_location loc,
+ location_t loc,
const struct line_map **map)
{
- source_location resolved_loc;
+ location_t resolved_loc;
const struct line_map *map0 = NULL;
const line_map_ordinary *map1 = NULL;
if (IS_ADHOC_LOC (loc))
- loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
map0 = linemap_lookup (set, loc);
if (!linemap_macro_expansion_map_p (map0))
expanded_location
linemap_expand_location (struct line_maps *set,
const struct line_map *map,
- source_location loc)
+ location_t loc)
{
expanded_location xloc;
if (IS_ADHOC_LOC (loc))
{
xloc.data
- = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].data;
- loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data;
+ loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
}
if (loc < RESERVED_LOCATION_COUNT)
void
linemap_dump_location (struct line_maps *set,
- source_location loc,
+ location_t loc,
FILE *stream)
{
const line_map_ordinary *map;
- source_location location;
+ location_t location;
const char *path = "", *from = "";
int l = -1, c = -1, s = -1, e = -1;
if (IS_ADHOC_LOC (loc))
- loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
+ loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
if (loc == 0)
return;
bool
linemap_get_file_highest_location (struct line_maps *set,
const char *file_name,
- source_location *loc)
+ location_t *loc)
{
/* If the set is empty or no ordinary map has been created then
there is no file to look for ... */
/* The highest location for a given map is either the starting
location of the next map minus one, or -- if the map is the
latest one -- the highest location of the set. */
- source_location result;
+ location_t result;
if (i == (int) set->info_ordinary.used - 1)
result = set->highest_location;
else
linemap_assert (linemap_macro_expansion_map_p (cur_map));
macro_maps_locations_size +=
- 2 * MACRO_MAP_NUM_MACRO_TOKENS (cur_map) * sizeof (source_location);
+ 2 * MACRO_MAP_NUM_MACRO_TOKENS (cur_map) * sizeof (location_t);
for (i = 0; i < 2 * MACRO_MAP_NUM_MACRO_TOKENS (cur_map); i += 2)
{
if (MACRO_MAP_LOCATIONS (cur_map)[i] ==
MACRO_MAP_LOCATIONS (cur_map)[i + 1])
duplicated_macro_maps_locations_size +=
- sizeof (source_location);
+ sizeof (location_t);
}
}
/* Construct a rich_location with location LOC as its initial range. */
-rich_location::rich_location (line_maps *set, source_location loc,
+rich_location::rich_location (line_maps *set, location_t loc,
const range_label *label) :
m_line_table (set),
m_ranges (),
/* Get location IDX within this rich_location. */
-source_location
+location_t
rich_location::get_loc (unsigned int idx) const
{
const location_range *locrange = get_range (idx);
/* Add the given range. */
void
-rich_location::add_range (source_location loc,
+rich_location::add_range (location_t loc,
enum range_display_kind range_display_kind,
const range_label *label)
{
- the "%C" and "%L" format codes in the Fortran frontend. */
void
-rich_location::set_range (unsigned int idx, source_location loc,
+rich_location::set_range (unsigned int idx, location_t loc,
enum range_display_kind range_display_kind)
{
/* We can either overwrite an existing range, or add one exactly
immediately before the start of WHERE. */
void
-rich_location::add_fixit_insert_before (source_location where,
+rich_location::add_fixit_insert_before (location_t where,
const char *new_content)
{
- source_location start = get_range_from_loc (m_line_table, where).m_start;
+ location_t start = get_range_from_loc (m_line_table, where).m_start;
maybe_add_fixit (start, start, new_content);
}
immediately after the end-point of WHERE. */
void
-rich_location::add_fixit_insert_after (source_location where,
+rich_location::add_fixit_insert_after (location_t where,
const char *new_content)
{
- source_location finish = get_range_from_loc (m_line_table, where).m_finish;
- source_location next_loc
+ location_t finish = get_range_from_loc (m_line_table, where).m_finish;
+ location_t next_loc
= linemap_position_for_loc_and_offset (m_line_table, finish, 1);
/* linemap_position_for_loc_and_offset can fail, if so, it returns
the start and finish of WHERE. */
void
-rich_location::add_fixit_remove (source_location where)
+rich_location::add_fixit_remove (location_t where)
{
source_range range = get_range_from_loc (m_line_table, where);
add_fixit_remove (range);
the start and finish of WHERE with NEW_CONTENT. */
void
-rich_location::add_fixit_replace (source_location where,
+rich_location::add_fixit_replace (location_t where,
const char *new_content)
{
source_range range = get_range_from_loc (m_line_table, where);
rich_location::add_fixit_replace (source_range src_range,
const char *new_content)
{
- source_location start = get_pure_location (m_line_table, src_range.m_start);
- source_location finish = get_pure_location (m_line_table, src_range.m_finish);
+ location_t start = get_pure_location (m_line_table, src_range.m_start);
+ location_t finish = get_pure_location (m_line_table, src_range.m_finish);
/* Fix-it hints use half-closed ranges, so attempt to offset the endpoint. */
- source_location next_loc
+ location_t next_loc
= linemap_position_for_loc_and_offset (m_line_table, finish, 1);
/* linemap_position_for_loc_and_offset can fail, if so, it returns
its input value. */
Otherwise (the common case), return false. */
bool
-rich_location::reject_impossible_fixit (source_location where)
+rich_location::reject_impossible_fixit (location_t where)
{
/* Fix-its within a rich_location should either all be suggested, or
none of them should be suggested.
consolidating into the prior fixit if possible. */
void
-rich_location::maybe_add_fixit (source_location start,
- source_location next_loc,
+rich_location::maybe_add_fixit (location_t start,
+ location_t next_loc,
const char *new_content)
{
if (reject_impossible_fixit (start))
/* class fixit_hint. */
-fixit_hint::fixit_hint (source_location start,
- source_location next_loc,
+fixit_hint::fixit_hint (location_t start,
+ location_t next_loc,
const char *new_content)
: m_start (start),
m_next_loc (next_loc),
Otherwise return false. */
bool
-fixit_hint::maybe_append (source_location start,
- source_location next_loc,
+fixit_hint::maybe_append (location_t start,
+ location_t next_loc,
const char *new_content)
{
/* For consolidation to be possible, START must be at this hint's
The undocumented -fdump-internal-locations option outputs this information
-to stderr, showing what each source_location value means. Source code
-lines are quoted, showing both per-line source_location values and
-per-line&column source_location values (written vertically under the
+to stderr, showing what each location_t value means. Source code
+lines are quoted, showing both per-line location_t values and
+per-line&column location_t values (written vertically under the
corresponding character of source code).
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
RESERVED LOCATIONS
- source_location interval: 0 <= loc < 2
+ location_t interval: 0 <= loc < 2
ORDINARY MAP: 0
- source_location interval: 32 <= loc < 64
+ location_t interval: 32 <= loc < 64
file: test.c
starting at line: 1
column bits: 12
|46802468024680246
ORDINARY MAP: 1
- source_location interval: 64 <= loc < 96
+ location_t interval: 64 <= loc < 96
file: <built-in>
starting at line: 0
column bits: 0
range bits: 0
ORDINARY MAP: 2
- source_location interval: 96 <= loc < 128
+ location_t interval: 96 <= loc < 128
file: <command-line>
starting at line: 0
column bits: 0
range bits: 0
ORDINARY MAP: 3
- source_location interval: 128 <= loc < 160128
+ location_t interval: 128 <= loc < 160128
file: /usr/include/stdc-predef.h
starting at line: 1
column bits: 12
(contents of /usr/include/stdc-predef.h snipped for brevity)
ORDINARY MAP: 4
- source_location interval: 160128 <= loc < 160160
+ location_t interval: 160128 <= loc < 160160
file: <command-line>
starting at line: 32
column bits: 12
range bits: 5
ORDINARY MAP: 5
- source_location interval: 160160 <= loc < 164256
+ location_t interval: 160160 <= loc < 164256
file: test.c
starting at line: 1
column bits: 12
|24680246802468024
ORDINARY MAP: 6
- source_location interval: 164256 <= loc < 173280
+ location_t interval: 164256 <= loc < 173280
file: test.h
starting at line: 1
column bits: 12
|024680246802468024680246
ORDINARY MAP: 7
- source_location interval: 173280 <= loc < 202016
+ location_t interval: 173280 <= loc < 202016
file: test.c
starting at line: 2
column bits: 12
|4
UNALLOCATED LOCATIONS
- source_location interval: 202016 <= loc < 2147483633
+ location_t interval: 202016 <= loc < 2147483633
MACRO 1: PLUS (7 tokens)
- source_location interval: 2147483633 <= loc < 2147483640
+ location_t interval: 2147483633 <= loc < 2147483640
test.c:7:11: note: expansion point is location 194115
int b = PLUS (3,4);
^~~~
x-location == y-location == 2947526575 encodes token # 800042942
MACRO 0: PLUS (7 tokens)
- source_location interval: 2147483640 <= loc < 2147483647
+ location_t interval: 2147483640 <= loc < 2147483647
test.c:6:11: note: expansion point is location 190019
int a = PLUS (1,2);
^~~~
6: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042935
-MAX_SOURCE_LOCATION
- source_location interval: 2147483647 <= loc < 2147483648
+MAX_LOCATION_T
+ location_t interval: 2147483647 <= loc < 2147483648
AD-HOC LOCATIONS
- source_location interval: 2147483648 <= loc < 4294967295
+ location_t interval: 2147483648 <= loc < 4294967295
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
const cpp_token *stringified; /* Stringified argument. */
unsigned int count; /* # of tokens in argument. */
unsigned int expanded_count; /* # of tokens in expanded argument. */
- source_location *virt_locs; /* Where virtual locations for
+ location_t *virt_locs; /* Where virtual locations for
unexpanded tokens are stored. */
- source_location *expanded_virt_locs; /* Where virtual locations for
+ location_t *expanded_virt_locs; /* Where virtual locations for
expanded tokens are
stored. */
};
/* A pointer to the "full" location of the current token. If
-ftrack-macro-expansion is used this location tracks loci across
macro expansion. */
- const source_location *location_ptr;
+ const location_t *location_ptr;
#if CHECKING_P
/* The number of times the iterator went forward. This useful only
when checking is enabled. */
int m_state;
/* The location of the paste token. */
- source_location m_paste_location;
+ location_t m_paste_location;
/* Location of the __VA_OPT__ token. */
- source_location m_location;
+ location_t m_location;
};
/* Macro expansion. */
static int enter_macro_context (cpp_reader *, cpp_hashnode *,
- const cpp_token *, source_location);
+ const cpp_token *, location_t);
static int builtin_macro (cpp_reader *, cpp_hashnode *,
- source_location, source_location);
+ location_t, location_t);
static void push_ptoken_context (cpp_reader *, cpp_hashnode *, _cpp_buff *,
const cpp_token **, unsigned int);
static void push_extended_tokens_context (cpp_reader *, cpp_hashnode *,
- _cpp_buff *, source_location *,
+ _cpp_buff *, location_t *,
const cpp_token **, unsigned int);
static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *,
_cpp_buff **, unsigned *);
static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int);
static const cpp_token *stringify_arg (cpp_reader *, macro_arg *);
static void paste_all_tokens (cpp_reader *, const cpp_token *);
-static bool paste_tokens (cpp_reader *, source_location,
+static bool paste_tokens (cpp_reader *, location_t,
const cpp_token **, const cpp_token *);
static void alloc_expanded_arg_mem (cpp_reader *, macro_arg *, size_t);
static void ensure_expanded_arg_room (cpp_reader *, macro_arg *, size_t, size_t *);
static void delete_macro_args (_cpp_buff*, unsigned num_args);
static void set_arg_token (macro_arg *, const cpp_token *,
- source_location, size_t,
+ location_t, size_t,
enum macro_arg_token_kind,
bool);
-static const source_location *get_arg_token_location (const macro_arg *,
+static const location_t *get_arg_token_location (const macro_arg *,
enum macro_arg_token_kind);
static const cpp_token **arg_token_ptr_at (const macro_arg *,
size_t,
enum macro_arg_token_kind,
- source_location **virt_location);
+ location_t **virt_location);
static void macro_arg_token_iter_init (macro_arg_token_iter *, bool,
enum macro_arg_token_kind,
const cpp_token **);
static const cpp_token *macro_arg_token_iter_get_token
(const macro_arg_token_iter *it);
-static source_location macro_arg_token_iter_get_location
+static location_t macro_arg_token_iter_get_location
(const macro_arg_token_iter *);
static void macro_arg_token_iter_forward (macro_arg_token_iter *);
static _cpp_buff *tokens_buff_new (cpp_reader *, size_t,
- source_location **);
+ location_t **);
static size_t tokens_buff_count (_cpp_buff *);
static const cpp_token **tokens_buff_last_token_ptr (_cpp_buff *);
static inline const cpp_token **tokens_buff_put_token_to (const cpp_token **,
- source_location *,
+ location_t *,
const cpp_token *,
- source_location,
- source_location,
+ location_t,
+ location_t,
const line_map_macro *,
unsigned int);
static const cpp_token **tokens_buff_add_token (_cpp_buff *,
- source_location *,
+ location_t *,
const cpp_token *,
- source_location,
- source_location,
+ location_t,
+ location_t,
const line_map_macro *,
unsigned int);
static inline void tokens_buff_remove_last_token (_cpp_buff *);
static void replace_args (cpp_reader *, cpp_hashnode *, cpp_macro *,
- macro_arg *, source_location);
+ macro_arg *, location_t);
static _cpp_buff *funlike_invocation_p (cpp_reader *, cpp_hashnode *,
_cpp_buff **, unsigned *);
static cpp_macro *create_iso_definition (cpp_reader *);
static bool reached_end_of_context (cpp_context *);
static void consume_next_token_from_context (cpp_reader *pfile,
const cpp_token **,
- source_location *);
-static const cpp_token* cpp_get_token_1 (cpp_reader *, source_location *);
+ location_t *);
+static const cpp_token* cpp_get_token_1 (cpp_reader *, location_t *);
static cpp_hashnode* macro_of_context (cpp_context *context);
a builtin macro. */
const uchar *
_cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
- source_location loc)
+ location_t loc)
{
const uchar *result = NULL;
linenum_type number = 1;
point of the macro. */
static int
builtin_macro (cpp_reader *pfile, cpp_hashnode *node,
- source_location loc, source_location expand_loc)
+ location_t loc, location_t expand_loc)
{
const uchar *buf;
size_t len;
Create a macro line map and generate a virtual location for
the token resulting from the expansion of the built-in
macro. */
- source_location *virt_locs = NULL;
+ location_t *virt_locs = NULL;
_cpp_buff *token_buf = tokens_buff_new (pfile, 1, &virt_locs);
const line_map_macro * map =
linemap_enter_macro (pfile->line_table, node, loc, 1);
guaranteed to not have the PASTE_LEFT flag set. LOCATION is
the virtual location used for error reporting. */
static bool
-paste_tokens (cpp_reader *pfile, source_location location,
+paste_tokens (cpp_reader *pfile, location_t location,
const cpp_token **plhs, const cpp_token *rhs)
{
unsigned char *buf, *end, *lhsend;
lhs = _cpp_lex_direct (pfile);
if (pfile->buffer->cur != pfile->buffer->rlimit)
{
- source_location saved_loc = lhs->src_loc;
+ location_t saved_loc = lhs->src_loc;
_cpp_pop_buffer (pfile);
_cpp_backup_tokens (pfile, 1);
{
const cpp_token *rhs = NULL;
cpp_context *context = pfile->context;
- source_location virt_loc = 0;
+ location_t virt_loc = 0;
/* We are expanding a macro and we must have been called on a token
that appears at the left hand side of a ## operator. */
/* Put the resulting token in its own context. */
if (context->tokens_kind == TOKENS_KIND_EXTENDED)
{
- source_location *virt_locs = NULL;
+ location_t *virt_locs = NULL;
_cpp_buff *token_buf = tokens_buff_new (pfile, 1, &virt_locs);
tokens_buff_add_token (token_buf, virt_locs, lhs,
virt_loc, 0, NULL, 0);
macro_arg *args, *arg;
const cpp_token *token;
unsigned int argc;
- source_location virt_loc;
+ location_t virt_loc;
bool track_macro_expansion_p = CPP_OPTION (pfile, track_macro_expansion);
unsigned num_args_alloced = 0;
if (track_macro_expansion_p)
{
virt_locs_capacity = DEFAULT_NUM_TOKENS_PER_MACRO_ARG;
- arg->virt_locs = XNEWVEC (source_location,
+ arg->virt_locs = XNEWVEC (location_t,
virt_locs_capacity);
}
&& (ntokens + 2 > virt_locs_capacity))
{
virt_locs_capacity += ARG_TOKENS_EXTENT;
- arg->virt_locs = XRESIZEVEC (source_location,
+ arg->virt_locs = XRESIZEVEC (location_t,
arg->virt_locs,
virt_locs_capacity);
}
macro. */
static int
enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
- const cpp_token *result, source_location location)
+ const cpp_token *result, location_t location)
{
/* The presence of a macro invalidates a file's controlling macro. */
pfile->mi_valid = false;
unsigned int i;
const cpp_token *src = macro->exp.tokens;
const line_map_macro *map;
- source_location *virt_locs = NULL;
+ location_t *virt_locs = NULL;
_cpp_buff *macro_tokens
= tokens_buff_new (pfile, tokens_count, &virt_locs);
pfile->about_to_expand_macro_p = false;
/* Handle built-in macros and the _Pragma operator. */
{
- source_location expand_loc;
+ location_t expand_loc;
if (/* The top-level macro invocation that triggered the expansion
we are looking at is with a function-like user macro ... */
tokens, at least. */
static void
set_arg_token (macro_arg *arg, const cpp_token *token,
- source_location location, size_t index,
+ location_t location, size_t index,
enum macro_arg_token_kind kind,
bool track_macro_exp_p)
{
const cpp_token **token_ptr;
- source_location *loc = NULL;
+ location_t *loc = NULL;
token_ptr =
arg_token_ptr_at (arg, index, kind,
/* Get the pointer to the location of the argument token of the
function-like macro argument ARG. This function must be called
only when we -ftrack-macro-expansion is on. */
-static const source_location *
+static const location_t *
get_arg_token_location (const macro_arg *arg,
enum macro_arg_token_kind kind)
{
- const source_location *loc = NULL;
+ const location_t *loc = NULL;
const cpp_token **token_ptr =
- arg_token_ptr_at (arg, 0, kind, (source_location **) &loc);
+ arg_token_ptr_at (arg, 0, kind, (location_t **) &loc);
if (token_ptr == NULL)
return NULL;
static const cpp_token **
arg_token_ptr_at (const macro_arg *arg, size_t index,
enum macro_arg_token_kind kind,
- source_location **virt_location)
+ location_t **virt_location)
{
const cpp_token **tokens_ptr = NULL;
*virt_location = &arg->expanded_virt_locs[index];
else if (kind == MACRO_ARG_TOKEN_STRINGIFIED)
*virt_location =
- (source_location *) &tokens_ptr[index]->src_loc;
+ (location_t *) &tokens_ptr[index]->src_loc;
}
return &tokens_ptr[index];
}
}
/* Return the location of the token pointed to by the iterator.*/
-static source_location
+static location_t
macro_arg_token_iter_get_location (const macro_arg_token_iter *it)
{
#if CHECKING_P
function-like macro invocation. */
static void
replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
- macro_arg *args, source_location expansion_point_loc)
+ macro_arg *args, location_t expansion_point_loc)
{
unsigned int i, total;
const cpp_token *src, *limit;
const cpp_token **first = NULL;
macro_arg *arg;
_cpp_buff *buff = NULL;
- source_location *virt_locs = NULL;
+ location_t *virt_locs = NULL;
unsigned int exp_count;
const line_map_macro *map = NULL;
int track_macro_exp;
As far as tokens are concerned, the memory overhead of
-ftrack-macro-expansion is proportional to the number of
- macros that get expanded multiplied by sizeof (source_location).
+ macros that get expanded multiplied by sizeof (location_t).
The good news is that extra memory gets freed when the macro
context is freed, i.e shortly after the macro got expanded. */
push_extended_tokens_context (cpp_reader *pfile,
cpp_hashnode *macro,
_cpp_buff *token_buff,
- source_location *virt_locs,
+ location_t *virt_locs,
const cpp_token **first,
unsigned int count)
{
expansion. */
static _cpp_buff*
tokens_buff_new (cpp_reader *pfile, size_t len,
- source_location **virt_locs)
+ location_t **virt_locs)
{
size_t tokens_size = len * sizeof (cpp_token *);
- size_t locs_size = len * sizeof (source_location);
+ size_t locs_size = len * sizeof (location_t);
if (virt_locs != NULL)
- *virt_locs = XNEWVEC (source_location, locs_size);
+ *virt_locs = XNEWVEC (location_t, locs_size);
return _cpp_get_buff (pfile, tokens_size);
}
point. */
static inline const cpp_token **
tokens_buff_put_token_to (const cpp_token **dest,
- source_location *virt_loc_dest,
+ location_t *virt_loc_dest,
const cpp_token *token,
- source_location virt_loc,
- source_location parm_def_loc,
+ location_t virt_loc,
+ location_t parm_def_loc,
const line_map_macro *map,
unsigned int macro_token_index)
{
- source_location macro_loc = virt_loc;
+ location_t macro_loc = virt_loc;
const cpp_token **result;
if (virt_loc_dest)
position of the token coming right after the insertion point. */
static const cpp_token **
tokens_buff_add_token (_cpp_buff *buffer,
- source_location *virt_locs,
+ location_t *virt_locs,
const cpp_token *token,
- source_location virt_loc,
- source_location parm_def_loc,
+ location_t virt_loc,
+ location_t parm_def_loc,
const line_map_macro *map,
unsigned int macro_token_index)
{
const cpp_token **result;
- source_location *virt_loc_dest = NULL;
+ location_t *virt_loc_dest = NULL;
unsigned token_index =
(BUFF_FRONT (buffer) - buffer->base) / sizeof (cpp_token *);
arg->expanded = XNEWVEC (const cpp_token *, capacity);
if (CPP_OPTION (pfile, track_macro_expansion))
- arg->expanded_virt_locs = XNEWVEC (source_location, capacity);
+ arg->expanded_virt_locs = XNEWVEC (location_t, capacity);
}
if (CPP_OPTION (pfile, track_macro_expansion))
{
if (arg->expanded_virt_locs == NULL)
- arg->expanded_virt_locs = XNEWVEC (source_location, size);
+ arg->expanded_virt_locs = XNEWVEC (location_t, size);
else
- arg->expanded_virt_locs = XRESIZEVEC (source_location,
+ arg->expanded_virt_locs = XRESIZEVEC (location_t,
arg->expanded_virt_locs,
size);
}
for (;;)
{
const cpp_token *token;
- source_location location;
+ location_t location;
ensure_expanded_arg_room (pfile, arg, arg->expanded_count + 1,
&capacity);
static inline void
consume_next_token_from_context (cpp_reader *pfile,
const cpp_token ** token,
- source_location *location)
+ location_t *location)
{
cpp_context *c = pfile->context;
location if we are in the traditional mode, and just returns
LOCATION otherwise. */
-static inline source_location
-maybe_adjust_loc_for_trad_cpp (cpp_reader *pfile, source_location location)
+static inline location_t
+maybe_adjust_loc_for_trad_cpp (cpp_reader *pfile, location_t location)
{
if (CPP_OPTION (pfile, traditional))
{
cpp_get_token_with_location to learn more about the meaning of this
location. */
static const cpp_token*
-cpp_get_token_1 (cpp_reader *pfile, source_location *location)
+cpp_get_token_1 (cpp_reader *pfile, location_t *location)
{
const cpp_token *result;
/* This token is a virtual token that either encodes a location
related to macro expansion or a spelling location. */
- source_location virt_loc = 0;
+ location_t virt_loc = 0;
/* pfile->about_to_expand_macro_p can be overriden by indirect calls
to functions that push macro contexts. So let's save it so that
we can restore it when we are about to leave this routine. */
location is just the same thing as its spelling location. */
const cpp_token *
-cpp_get_token_with_location (cpp_reader *pfile, source_location *loc)
+cpp_get_token_with_location (cpp_reader *pfile, location_t *loc)
{
return cpp_get_token_1 (pfile, loc);
}
return 0;
p->definition = defn;
- if (fread (&(p->line), sizeof (source_location), 1, f) != 1)
+ if (fread (&(p->line), sizeof (location_t), 1, f) != 1)
return 0;
defnlen = 0;
if (fread (&defnlen, sizeof (defnlen), 1, f) != 1)
if (fwrite (&defnlen, sizeof (size_t), 1, f) != 1
|| fwrite (pp[i]->definition, defnlen, 1, f) != 1)
return 0;
- if (fwrite (&(pp[i]->line), sizeof (source_location), 1, f) != 1)
+ if (fwrite (&(pp[i]->line), sizeof (location_t), 1, f) != 1)
return 0;
defnlen = 0;
defnlen |= (pp[i]->syshdr != 0 ? 1 : 0);
size_t offset;
/* The line the macro name appeared on. */
- source_location line;
+ location_t line;
/* Number of parameters. */
unsigned int paramc;
copy_comment (cpp_reader *pfile, const uchar *cur, int in_define)
{
bool unterminated, copy = false;
- source_location src_loc = pfile->line_table->highest_line;
+ location_t src_loc = pfile->line_table->highest_line;
cpp_buffer *buffer = pfile->buffer;
buffer->cur = cur;