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
This commit is contained in:
David Malcolm
2018-11-13 20:05:03 +00:00
committed by David Malcolm
parent f9731de3db
commit 620e594be5
83 changed files with 840 additions and 734 deletions

View File

@@ -240,8 +240,10 @@ struct GTY(()) cpp_identifier {
/* 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 */
@@ -624,12 +626,12 @@ struct cpp_callbacks
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;
@@ -649,14 +651,14 @@ struct cpp_callbacks
/* 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 *);
@@ -676,7 +678,7 @@ struct cpp_callbacks
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
@@ -753,7 +755,7 @@ struct GTY(()) cpp_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? */
@@ -884,13 +886,13 @@ struct GTY(()) cpp_hashnode {
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;
};
@@ -995,7 +997,7 @@ extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
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;
@@ -1017,7 +1019,7 @@ inline bool cpp_fun_like_macro_p (cpp_hashnode *node)
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;
}
@@ -1126,7 +1128,7 @@ struct cpp_num
/* 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 *,
@@ -1165,30 +1167,30 @@ extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level,
/* 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,
@@ -1219,7 +1221,7 @@ typedef struct
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. */
@@ -1258,7 +1260,7 @@ extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
/* 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 *);
@@ -1281,7 +1283,7 @@ extern int cpp_read_state (cpp_reader *, const char *, FILE *,
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 */