diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-11-13 20:05:03 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-11-13 20:05:03 +0000 |
commit | 620e594be58d2f933902a6619fd20aa618070b4b (patch) | |
tree | 18b833ac960291d05524d5994ae4292048632226 /gcc | |
parent | f9731de3db4c59ff0a241ce2c3d6f80aca5b5c28 (diff) | |
download | gcc-620e594be58d2f933902a6619fd20aa618070b4b.zip gcc-620e594be58d2f933902a6619fd20aa618070b4b.tar.gz gcc-620e594be58d2f933902a6619fd20aa618070b4b.tar.bz2 |
Eliminate source_location in favor of location_t
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
Diffstat (limited to 'gcc')
63 files changed, 339 insertions, 262 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1feb1bd..9f474bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,37 @@ +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. diff --git a/gcc/builtins.c b/gcc/builtins.c index 9f2a90a..ebde2db 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -6151,7 +6151,7 @@ get_memmodel (tree exp) { 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 @@ -6227,7 +6227,7 @@ expand_builtin_atomic_compare_exchange (machine_mode mode, tree exp, 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)); @@ -6354,7 +6354,7 @@ expand_ifn_atomic_compare_exchange (gcall *call) 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)); @@ -6426,7 +6426,7 @@ expand_builtin_atomic_load (machine_mode mode, tree exp, rtx target) 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%>"); @@ -6458,7 +6458,7 @@ expand_builtin_atomic_store (machine_mode mode, tree exp) 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%>"); @@ -6651,7 +6651,7 @@ expand_builtin_atomic_clear (tree exp) 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%>"); @@ -10200,7 +10200,7 @@ fold_builtin_next_arg (tree exp, bool va_start_p) 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); diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 26a2b4e..4b8d822 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +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 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 0adee8b..9c2f186 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -862,13 +862,13 @@ c_get_substring_location (const substring_loc &substr_loc, 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); } diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 28a820a..d979a97 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -237,7 +237,7 @@ fe_file_change (const line_map_ordinary *new_map) } 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 @@ -265,7 +265,7 @@ cb_def_pragma (cpp_reader *pfile, source_location loc) /* #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), @@ -274,7 +274,7 @@ cb_define (cpp_reader *pfile, source_location loc, cpp_hashnode *node) /* #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); diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index fe4d1ff..356bd4c 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1393,7 +1393,7 @@ c_finish_options (void) 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); diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c index 2e5a44e..bb5d996 100644 --- a/gcc/c-family/c-ppoutput.c +++ b/gcc/c-family/c-ppoutput.c @@ -59,24 +59,24 @@ static void account_for_newlines (const unsigned char *, size_t); 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); @@ -179,7 +179,7 @@ scan_translation_unit (cpp_reader *pfile) 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) @@ -336,7 +336,7 @@ scan_translation_unit_trad (cpp_reader *pfile) 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); @@ -373,7 +373,7 @@ maybe_print_line_1 (source_location src_loc, FILE *stream) 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, @@ -386,7 +386,7 @@ maybe_print_line (source_location 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; @@ -435,7 +435,7 @@ print_line_1 (source_location src_loc, const char *special_flags, FILE *stream) 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, @@ -447,7 +447,7 @@ print_line (source_location src_loc, const char *special_flags) 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) @@ -487,7 +487,7 @@ cb_line_change (cpp_reader *pfile, const cpp_token *token, } 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); @@ -496,7 +496,7 @@ cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location 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; @@ -520,7 +520,7 @@ cb_define (cpp_reader *pfile, source_location line, cpp_hashnode *node) } 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); @@ -529,7 +529,7 @@ cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location 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)) @@ -544,7 +544,7 @@ cb_used_define (cpp_reader *pfile, source_location line ATTRIBUTE_UNUSED, 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; @@ -595,7 +595,7 @@ dump_queued_macros (cpp_reader *pfile ATTRIBUTE_UNUSED) } 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) { @@ -676,7 +676,7 @@ pp_file_change (const line_map_ordinary *map) /* 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); diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index df041a7..6620bd0 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +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 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 8de5ffc..4a62b1e 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -9955,7 +9955,7 @@ build_null_declspecs (void) 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; @@ -9978,7 +9978,7 @@ declspecs_add_addrspace (source_location location, 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; @@ -10895,7 +10895,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, 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) { @@ -11014,7 +11014,7 @@ declspecs_add_scspec (source_location loc, 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; @@ -11026,7 +11026,7 @@ declspecs_add_attrs (source_location loc, struct c_declspecs *specs, tree attrs) 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; diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index be63fee..5ed2f48 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -288,7 +288,7 @@ enum c_declspec_word { 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 @@ -592,19 +592,19 @@ extern struct c_declarator *build_id_declarator (tree); 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 *); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 144977e..5d4e973 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -6226,7 +6226,7 @@ pedwarn_init (location_t loc, int opt, const char *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); auto_diagnostic_group d; va_list ap; va_start (ap, gmsgid); @@ -6254,7 +6254,7 @@ warning_init (location_t loc, int opt, const char *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); @@ -10234,7 +10234,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) /* 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, diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index ee2146f..c80a8bb 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1643,7 +1643,7 @@ c_finish_gimple_return (location_t loc, tree retval) /* 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, diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e80c4e..1587b49 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b668e03..ee099cc 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6681,7 +6681,7 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum) 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) @@ -6710,7 +6710,7 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum) 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); } @@ -7386,7 +7386,7 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain) /* 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) { diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c4d79c0..bfb88de 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5783,7 +5783,7 @@ enum cp_decl_spec { 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 @@ -6183,7 +6183,7 @@ extern void pop_defarg_context (void); 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); @@ -6351,7 +6351,7 @@ extern tree build_cp_library_fn_ptr (const char *, tree, int); 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 *); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index b04e9a7..eb16873 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1687,7 +1687,7 @@ build_expr_type_conversion (int desires, tree expr, bool complain) && (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, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4299405..89a1823 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4752,7 +4752,7 @@ fixup_anonymous_aggr (tree t) 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)); @@ -10257,7 +10257,7 @@ grokdeclarator (const cp_declarator *declarator, 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); diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index ad562ba..239bb01 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -6049,7 +6049,7 @@ class macro_use_before_def : public deferred_diagnostic 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; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index db0f033..e9e49b1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5441,7 +5441,7 @@ cp_parser_primary_expression (cp_parser *parser, { 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 @@ -28525,7 +28525,7 @@ set_and_check_decl_spec_loc (cp_decl_specifier_seq *decl_specs, if (decl_specs == NULL) return; - source_location location = token->location; + location_t location = token->location; if (decl_specs->locations[ds] == 0) { diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c921096..7b42d53 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4433,7 +4433,7 @@ cp_build_binary_op (location_t location, && !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"); diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index a42ff81..278e172 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -777,11 +777,11 @@ compatible_locations_p (location_t loc_a, location_t loc_b) /* 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); diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index a572c08..3d86a21 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -794,12 +794,12 @@ print_parseable_fixits (pretty_printer *pp, rich_location *richloc) 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, diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index a1ab205..86651df 100644 --- a/gcc/dumpfile.c +++ b/gcc/dumpfile.c @@ -47,7 +47,7 @@ along with GCC; see the file COPYING3. If not see 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; @@ -466,7 +466,7 @@ kind_as_string (dump_flags_t dump_kind) /* 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) { @@ -487,7 +487,7 @@ dump_loc (dump_flags_t dump_kind, FILE *dfile, source_location loc) /* 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) { diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f5bcec3..8474baa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c index a28421f..95b08a9 100644 --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -134,14 +134,14 @@ static void scan_translation_unit_trad (cpp_reader *); 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 *) @@ -578,7 +578,7 @@ gfc_cpp_init (void) 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); @@ -709,8 +709,8 @@ static void scan_translation_unit_trad (cpp_reader *); 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 @@ -790,7 +790,7 @@ scan_translation_unit_trad (cpp_reader *pfile) 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)); @@ -819,7 +819,7 @@ maybe_print_line (source_location 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) @@ -897,7 +897,7 @@ static void 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; @@ -924,7 +924,7 @@ cb_line_change (cpp_reader *pfile, const cpp_token *token, } 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); @@ -933,7 +933,7 @@ cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location 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); @@ -952,7 +952,7 @@ cb_define (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location 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); @@ -961,7 +961,7 @@ cb_undef (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location 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) { @@ -1003,7 +1003,7 @@ dump_macro (cpp_reader *pfile, cpp_hashnode *node, void *v ATTRIBUTE_UNUSED) } 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; @@ -1086,7 +1086,7 @@ pp_dir_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const char *dir) /* 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); @@ -1096,7 +1096,7 @@ cb_def_pragma (cpp_reader *pfile, source_location line) 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; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index d8ef35d..128f574 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -952,7 +952,7 @@ typedef struct gfc_file typedef struct gfc_linebuf { - source_location location; + location_t location; struct gfc_file *file; struct gfc_linebuf *next; diff --git a/gcc/gcc-rich-location.h b/gcc/gcc-rich-location.h index d282fd4..200bbb5 100644 --- a/gcc/gcc-rich-location.h +++ b/gcc/gcc-rich-location.h @@ -28,7 +28,7 @@ class gcc_rich_location : public rich_location /* 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) { } diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 62a876d..8e3827c 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -53,7 +53,7 @@ unsigned verbose; 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. @@ -61,7 +61,7 @@ static struct line_maps *line_table; 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; @@ -78,7 +78,7 @@ diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level errtype, 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, @@ -131,7 +131,7 @@ static void #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; @@ -157,7 +157,7 @@ static void #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; @@ -184,7 +184,7 @@ fprintf_indent (FILE *f, unsigned int indent, const char *format, ...) } 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; @@ -667,10 +667,10 @@ struct capture_info; 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, @@ -682,7 +682,7 @@ struct operand { 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; }; @@ -692,7 +692,7 @@ struct predicate : public operand 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) {} @@ -733,7 +733,7 @@ struct c_expr : public operand 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_), @@ -755,7 +755,7 @@ struct c_expr : public operand 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. */ @@ -775,7 +775,7 @@ struct capture : public operand 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; @@ -786,7 +786,7 @@ struct if_expr : public operand 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; @@ -1797,13 +1797,13 @@ decision_tree::find_node (vec<dt_node *>& ops, dt_node *p) { 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"); @@ -3925,7 +3925,7 @@ private: 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 *); @@ -3933,10 +3933,10 @@ private: 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 *); @@ -4094,7 +4094,7 @@ parser::get_internal_capture_id () /* 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)) { @@ -4168,7 +4168,7 @@ parser::parse_operation () 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; @@ -4324,7 +4324,7 @@ parser::parse_c_expr (cpp_ttype start) 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) @@ -4513,7 +4513,7 @@ parser::parse_result (operand *result, predicate_id *matcher) 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; @@ -4652,7 +4652,7 @@ parser::parse_simplify (simplify::simplify_kind kind, 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; @@ -4766,7 +4766,7 @@ parser::parse_for (source_location) 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 (); @@ -4818,7 +4818,7 @@ parser::parse_operator_list (source_location) 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); @@ -4842,7 +4842,7 @@ parser::parse_if (source_location) preds = '(' 'define_predicates' <ident>... ')' */ void -parser::parse_predicates (source_location) +parser::parse_predicates (location_t) { do { @@ -4873,7 +4873,7 @@ parser::parse_pattern () 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); diff --git a/gcc/gimple.h b/gcc/gimple.h index 145e9ad..9853521 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -4426,7 +4426,7 @@ gimple_phi_arg_edge (gphi *phi, size_t i) /* 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; @@ -4434,7 +4434,7 @@ gimple_phi_arg_location (gphi *phi, size_t i) /* 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; @@ -4443,7 +4443,7 @@ gimple_phi_arg_location_from_edge (gphi *phi, edge e) /* 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; } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index d7cb784..ad7f824 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -13840,7 +13840,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, 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 diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 45871d7..5f18b80 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,11 @@ +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 diff --git a/gcc/go/go-gcc-diagnostics.cc b/gcc/go/go-gcc-diagnostics.cc index 4d03fa5..6ddf0f4 100644 --- a/gcc/go/go-gcc-diagnostics.cc +++ b/gcc/go/go-gcc-diagnostics.cc @@ -24,7 +24,7 @@ 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()); } @@ -33,7 +33,7 @@ void 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()); } @@ -41,7 +41,7 @@ void 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()); } @@ -49,7 +49,7 @@ void 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()); } diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 092d3e4..be23029 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -2243,9 +2243,9 @@ Gcc_backend::switch_statement( { 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); @@ -2259,7 +2259,7 @@ Gcc_backend::switch_statement( 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); diff --git a/gcc/go/go-linemap.cc b/gcc/go/go-linemap.cc index a4d4b7d..1d72e79 100644 --- a/gcc/go/go-linemap.cc +++ b/gcc/go/go-linemap.cc @@ -77,7 +77,7 @@ std::string 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. diff --git a/gcc/go/go-location.h b/gcc/go/go-location.h index 90258ea..6637b86 100644 --- a/gcc/go/go-location.h +++ b/gcc/go/go-location.h @@ -18,16 +18,16 @@ class Location : 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. diff --git a/gcc/go/gofrontend/README b/gcc/go/gofrontend/README index 6d4d0b0..b139194 100644 --- a/gcc/go/gofrontend/README +++ b/gcc/go/gofrontend/README @@ -14,7 +14,7 @@ header files. 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. diff --git a/gcc/input.c b/gcc/input.c index 9fb6e72..347122e 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -152,7 +152,7 @@ static const size_t fcache_line_record_size = 100; 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) { @@ -201,14 +201,14 @@ expand_location_1 (source_location loc, 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); } @@ -256,7 +256,7 @@ static size_t 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); @@ -786,7 +786,7 @@ location_missing_trailing_newline (const char *file_path) 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, @@ -800,7 +800,7 @@ is_location_from_builtin_token (source_location 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); @@ -813,14 +813,14 @@ expand_location (source_location loc) "<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. @@ -829,7 +829,7 @@ expand_location_to_spelling_point (source_location loc, 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); @@ -848,8 +848,8 @@ linemap_client_expand_location_to_spelling_point (source_location loc, 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, @@ -861,8 +861,8 @@ expansion_point_location_if_in_system_header (source_location 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); @@ -976,7 +976,7 @@ dump_line_table_statistics (void) /* 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) @@ -1001,37 +1001,37 @@ write_digit (FILE *stream, int digit) 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); @@ -1050,7 +1050,7 @@ dump_location_info (FILE *stream) /* 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 @@ -1069,7 +1069,7 @@ dump_location_info (FILE *stream) 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) ) { @@ -1094,7 +1094,7 @@ dump_location_info (FILE *stream) /* "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 ()) @@ -1128,12 +1128,12 @@ dump_location_info (FILE *stream) /* 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); @@ -1154,8 +1154,8 @@ dump_location_info (FILE *stream) 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. */ @@ -1166,7 +1166,7 @@ dump_location_info (FILE *stream) 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", @@ -1191,17 +1191,17 @@ dump_location_info (FILE *stream) 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. */ @@ -1473,12 +1473,12 @@ get_substring_ranges_for_loc (cpp_reader *pfile, 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); @@ -1638,7 +1638,7 @@ assert_loceq (const char *exp_filename, int exp_linenum, int exp_colnum, - 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. diff --git a/gcc/input.h b/gcc/input.h index e5d5a09..1f766f3 100644 --- a/gcc/input.h +++ b/gcc/input.h @@ -27,17 +27,17 @@ extern GTY(()) struct line_maps *line_table; 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. */ @@ -86,15 +86,11 @@ extern char_span location_get_source_line (const char *file_path, int line); 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; diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 4e0c6e4..8451fd5 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,7 @@ +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. diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index f11642b..1bb0fde 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -2827,7 +2827,7 @@ handle_locations () 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)) @@ -2927,7 +2927,7 @@ new_location (recording::location *rloc, /* 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:: diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index a5d34df..2dfb96e 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -686,7 +686,7 @@ public: recording::location *get_recording_loc () const { return m_recording_loc; } - source_location m_srcloc; + location_t m_srcloc; private: recording::location *m_recording_loc; diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index 95b89a6..2361520 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -3333,7 +3333,7 @@ expand_omp_for_generic (struct omp_region *region, 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 (); @@ -4476,7 +4476,7 @@ expand_omp_for_static_chunk (struct omp_region *region, 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), diff --git a/gcc/selftest.h b/gcc/selftest.h index 4e4c755..29ade6b 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -141,7 +141,7 @@ class auto_fix_quotes - 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. diff --git a/gcc/substring-locations.h b/gcc/substring-locations.h index caac537..19047a1 100644 --- a/gcc/substring-locations.h +++ b/gcc/substring-locations.h @@ -115,12 +115,12 @@ class format_string_diagnostic_t /* 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 */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 919c478..9a9cd82 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/testsuite/g++.dg/plugin/comment_plugin.c b/gcc/testsuite/g++.dg/plugin/comment_plugin.c index c3b08e3..3164385 100644 --- a/gcc/testsuite/g++.dg/plugin/comment_plugin.c +++ b/gcc/testsuite/g++.dg/plugin/comment_plugin.c @@ -13,7 +13,7 @@ int plugin_is_GPL_compatible; /* 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)) diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c index a55efaf..7cc90de 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c @@ -22,7 +22,7 @@ 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. @@ -90,7 +90,7 @@ public: }; // 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 @@ -100,7 +100,7 @@ public: 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 */ @@ -109,7 +109,7 @@ get_loc (unsigned int line_num, unsigned int col_num) 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); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 3b646f7..582cf18 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9212,7 +9212,7 @@ public: unsigned int pass_warn_function_return::execute (function *fun) { - source_location location; + location_t location; gimple *last; edge e; edge_iterator ei; diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 7fd0430..3c82b11 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -529,7 +529,7 @@ remove_forwarder_block (basic_block bb) 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); } @@ -1082,7 +1082,7 @@ remove_forwarder_block_with_phi (basic_block bb) { 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) { diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index c4a200f..01eed71 100644 --- a/gcc/tree-diagnostic.c +++ b/gcc/tree-diagnostic.c @@ -56,7 +56,7 @@ default_tree_diagnostic_starter (diagnostic_context *context, struct loc_map_pair { const line_map_macro *map; - source_location where; + location_t where; }; @@ -99,7 +99,7 @@ struct loc_map_pair 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; @@ -178,14 +178,14 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context, /* 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)) @@ -210,7 +210,7 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context, /* 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); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index cdae75d..79259b6 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -2119,7 +2119,7 @@ rewrite_update_phi_arguments (basic_block bb) /* 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); diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index 60f3c40..5d8f9a1 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -143,7 +143,7 @@ struct elim_graph 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; @@ -162,7 +162,7 @@ struct elim_graph auto_vec<tree> const_copies; /* Source locations for any constant copies. */ - auto_vec<source_location> copy_locus; + auto_vec<location_t> copy_locus; }; @@ -238,7 +238,7 @@ emit_partition_copy (rtx dest, rtx src, int unsignedsrcp, tree sizeexp) /* 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)) @@ -272,7 +272,7 @@ insert_partition_copy_on_edge (edge e, int dest, int src, source_location locus) 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; @@ -333,7 +333,7 @@ insert_value_copy_on_edge (edge e, int dest, tree src, source_location locus) 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)) { @@ -367,7 +367,7 @@ insert_rtx_to_part_on_edge (edge e, int dest, rtx src, int unsignedsrcp, 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)) @@ -444,7 +444,7 @@ elim_graph_add_node (elim_graph *g, int node) /* 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); @@ -456,7 +456,7 @@ elim_graph_add_edge (elim_graph *g, int pred, int succ, source_location locus) 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; @@ -556,7 +556,7 @@ eliminate_build (elim_graph *g) 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. */ @@ -597,7 +597,7 @@ static void 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, @@ -615,7 +615,7 @@ static int 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, { @@ -631,7 +631,7 @@ static void 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, @@ -666,7 +666,7 @@ static void elim_create (elim_graph *g, int T) { int P, S; - source_location locus; + location_t locus; if (elim_unvisited_predecessor (g, T)) { @@ -741,7 +741,7 @@ eliminate_phi (edge e, elim_graph *g) { int dest; tree src; - source_location locus; + location_t locus; src = g->const_copies.pop (); dest = g->const_dests.pop (); diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 4e22898..81d7742 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1041,7 +1041,7 @@ create_phi_for_local_result (reduction_info **slot, struct loop *loop) 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. @@ -2131,7 +2131,7 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, 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); diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 48397a1..16dcf67 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -351,7 +351,7 @@ create_phi_node (tree var, basic_block bb) 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; diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h index fc28407..8a06870 100644 --- a/gcc/tree-phinodes.h +++ b/gcc/tree-phinodes.h @@ -24,7 +24,7 @@ extern void phinodes_print_statistics (void); 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); diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index b42f32d..6f56f5a 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -543,7 +543,7 @@ struct ivopts_data { /* 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; diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index 726590a..c05738c 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -786,7 +786,7 @@ split_loop_exit_edge (edge exit, bool copy_constants_p) 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)) { diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 64039e2..e185e9c 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -423,7 +423,7 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi, 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 @@ -669,7 +669,7 @@ conditional_replacement (basic_block cond_bb, basic_block middle_bb, 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); @@ -2049,7 +2049,7 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, 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 @@ -2133,7 +2133,7 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb, 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; diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index bb18f3e..2869b60 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -159,7 +159,7 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_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); diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 8080dff..6630516 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -431,7 +431,7 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_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); @@ -445,7 +445,7 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e) 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; @@ -499,7 +499,7 @@ copy_phi_args (basic_block bb, edge src_e, edge tgt_e, { 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))) diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index f1b322f..bd8b91f8 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -52,7 +52,7 @@ static hash_map<edge, auto_vec<edge_var_map> > *edge_var_maps; /* 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; @@ -151,7 +151,7 @@ ssa_redirect_edge (edge e, basic_block dest) 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); diff --git a/gcc/tree-ssa.h b/gcc/tree-ssa.h index 6ad9c9a..b2d676f 100644 --- a/gcc/tree-ssa.h +++ b/gcc/tree-ssa.h @@ -24,14 +24,14 @@ along with GCC; see the file COPYING3. If not see 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); @@ -74,7 +74,7 @@ redirect_edge_var_map_result (edge_var_map *v) /* 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; diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 857e57b..efaa22f 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -2172,7 +2172,7 @@ slpeel_update_phi_nodes_for_guard1 (struct loop *skip_loop, 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; |