diff options
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 20 | ||||
-rw-r--r-- | libcpp/charset.c | 2 | ||||
-rw-r--r-- | libcpp/directives-only.c | 2 | ||||
-rw-r--r-- | libcpp/directives.c | 30 | ||||
-rw-r--r-- | libcpp/errors.c | 16 | ||||
-rw-r--r-- | libcpp/expr.c | 14 | ||||
-rw-r--r-- | libcpp/files.c | 32 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 54 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 224 | ||||
-rw-r--r-- | libcpp/init.c | 2 | ||||
-rw-r--r-- | libcpp/internal.h | 40 | ||||
-rw-r--r-- | libcpp/lex.c | 8 | ||||
-rw-r--r-- | libcpp/line-map.c | 296 | ||||
-rw-r--r-- | libcpp/location-example.txt | 36 | ||||
-rw-r--r-- | libcpp/macro.c | 138 | ||||
-rw-r--r-- | libcpp/pch.c | 4 | ||||
-rw-r--r-- | libcpp/traditional.c | 4 |
17 files changed, 472 insertions, 450 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index a3d3dd6..575f18e 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,23 @@ +2018-11-13 David Malcolm <dmalcolm@redhat.com> + + * charset.c: Replace "source_location" with "location_t". + * directives-only.c: Likewise. + * directives.c: Likewise. + * errors.c: Likewise. + * expr.c: Likewise. + * files.c: Likewise. + * include/cpplib.h: Likewise. Rename MAX_SOURCE_LOCATION to + MAX_LOCATION_T. + * include/line-map.h: Likewise. + * init.c: Likewise. + * internal.h: Likewise. + * lex.c: Likewise. + * line-map.c: Likewise. + * location-example.txt: Likewise. + * macro.c: Likewise. + * pch.c: Likewise. + * traditional.c: Likewise. + 2018-11-07 Hafiz Abid Qadeer <abidh@codesourcery.com> * configure: Regenerated. diff --git a/libcpp/charset.c b/libcpp/charset.c index 36c57a6..9f2620c 100644 --- a/libcpp/charset.c +++ b/libcpp/charset.c @@ -2135,7 +2135,7 @@ _cpp_default_encoding (void) /* Constructor for cpp_string_location_reader. */ cpp_string_location_reader:: -cpp_string_location_reader (source_location src_loc, +cpp_string_location_reader (location_t src_loc, line_maps *line_table) : m_line_table (line_table) { diff --git a/libcpp/directives-only.c b/libcpp/directives-only.c index de67308..c2bcd9f 100644 --- a/libcpp/directives-only.c +++ b/libcpp/directives-only.c @@ -43,7 +43,7 @@ _cpp_preprocess_dir_only (cpp_reader *pfile, unsigned flags; linenum_type lines; int col; - source_location loc; + location_t loc; restart: /* Buffer initialization ala _cpp_clean_line(). */ diff --git a/libcpp/directives.c b/libcpp/directives.c index a76631d..7a8db57 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -30,7 +30,7 @@ along with this program; see the file COPYING3. If not see struct if_stack { struct if_stack *next; - source_location line; /* Line where condition started. */ + location_t line; /* Line where condition started. */ const cpp_hashnode *mi_cmacro;/* macro name for #ifndef around entire file */ bool skip_elses; /* Can future #else / #elif be skipped? */ bool was_skipping; /* If were skipping on entry. */ @@ -98,7 +98,7 @@ static void directive_diagnostics (cpp_reader *, const directive *, int); static void run_directive (cpp_reader *, int, const char *, size_t); static char *glue_header_name (cpp_reader *); static const char *parse_include (cpp_reader *, int *, const cpp_token ***, - source_location *); + location_t *); static void push_conditional (cpp_reader *, int, int, const cpp_hashnode *); static unsigned int read_flag (cpp_reader *, unsigned int); static bool strtolinenum (const uchar *, size_t, linenum_type *, bool *); @@ -124,8 +124,8 @@ static void do_linemarker (cpp_reader *); static const cpp_token *get_token_no_padding (cpp_reader *); static const cpp_token *get__Pragma_string (cpp_reader *); static void destringize_and_run (cpp_reader *, const cpp_string *, - source_location); -static bool parse_answer (cpp_reader *, int, source_location, cpp_macro **); + location_t); +static bool parse_answer (cpp_reader *, int, location_t, cpp_macro **); static cpp_hashnode *parse_assertion (cpp_reader *, int, cpp_macro **); static cpp_macro **find_answer (cpp_hashnode *, const cpp_macro *); static void handle_assertion (cpp_reader *, const char *, int); @@ -756,7 +756,7 @@ glue_header_name (cpp_reader *pfile) static const char * parse_include (cpp_reader *pfile, int *pangle_brackets, - const cpp_token ***buf, source_location *location) + const cpp_token ***buf, location_t *location) { char *fname; const cpp_token *header; @@ -814,7 +814,7 @@ do_include_common (cpp_reader *pfile, enum include_type type) const char *fname; int angle_brackets; const cpp_token **buf = NULL; - source_location location; + location_t location; /* Re-enable saving of comments if requested, so that the include callback can dump comments which follow #include. */ @@ -1093,7 +1093,7 @@ do_linemarker (cpp_reader *pfile) } /* Compensate for the increment in linemap_add that occurs in _cpp_do_file_change. We're currently at the start of the line - *following* the #line directive. A separate source_location for this + *following* the #line directive. A separate location_t for this location makes no sense (until we do the LC_LEAVE), and complicates LAST_SOURCE_LINE_LOCATION. */ pfile->line_table->highest_location--; @@ -1135,7 +1135,7 @@ do_diagnostic (cpp_reader *pfile, enum cpp_diagnostic_level code, { const unsigned char *dir_name; unsigned char *line; - source_location src_loc = pfile->cur_token[-1].src_loc; + location_t src_loc = pfile->cur_token[-1].src_loc; if (print_dir) dir_name = pfile->directive->name; @@ -1432,7 +1432,7 @@ do_pragma (cpp_reader *pfile) { const struct pragma_entry *p = NULL; const cpp_token *token, *pragma_token; - source_location pragma_token_virt_loc = 0; + location_t pragma_token_virt_loc = 0; cpp_token ns_token; unsigned int count = 1; @@ -1538,7 +1538,7 @@ do_pragma_push_macro (cpp_reader *pfile) txt = get__Pragma_string (pfile); if (!txt) { - source_location src_loc = pfile->cur_token[-1].src_loc; + location_t src_loc = pfile->cur_token[-1].src_loc; cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0, "invalid #pragma push_macro directive"); check_eol (pfile, false); @@ -1593,7 +1593,7 @@ do_pragma_pop_macro (cpp_reader *pfile) txt = get__Pragma_string (pfile); if (!txt) { - source_location src_loc = pfile->cur_token[-1].src_loc; + location_t src_loc = pfile->cur_token[-1].src_loc; cpp_error_with_line (pfile, CPP_DL_ERROR, src_loc, 0, "invalid #pragma pop_macro directive"); check_eol (pfile, false); @@ -1695,7 +1695,7 @@ do_pragma_dependency (cpp_reader *pfile) { const char *fname; int angle_brackets, ordering; - source_location location; + location_t location; fname = parse_include (pfile, &angle_brackets, NULL, &location); if (!fname) @@ -1801,7 +1801,7 @@ get__Pragma_string (cpp_reader *pfile) \" and \\ sequences, and process the result as a #pragma directive. */ static void destringize_and_run (cpp_reader *pfile, const cpp_string *in, - source_location expansion_loc) + location_t expansion_loc) { const unsigned char *src, *limit; char *dest, *result; @@ -1921,7 +1921,7 @@ destringize_and_run (cpp_reader *pfile, const cpp_string *in, /* Handle the _Pragma operator. Return 0 on error, 1 if ok. */ int -_cpp_do__Pragma (cpp_reader *pfile, source_location expansion_loc) +_cpp_do__Pragma (cpp_reader *pfile, location_t expansion_loc) { const cpp_token *string = get__Pragma_string (pfile); pfile->directive_result.type = CPP_PADDING; @@ -2142,7 +2142,7 @@ push_conditional (cpp_reader *pfile, int skip, int type, ANSWERP to point to the answer. PRED_LOC is the location of the predicate. */ static bool -parse_answer (cpp_reader *pfile, int type, source_location pred_loc, +parse_answer (cpp_reader *pfile, int type, location_t pred_loc, cpp_macro **answer_ptr) { /* In a conditional, it is legal to not have an open paren. We diff --git a/libcpp/errors.c b/libcpp/errors.c index 2268fc4..6746428 100644 --- a/libcpp/errors.c +++ b/libcpp/errors.c @@ -52,7 +52,7 @@ cpp_diagnostic (cpp_reader * pfile, enum cpp_diagnostic_level level, enum cpp_warning_reason reason, const char *msgid, va_list *ap) { - source_location src_loc; + location_t src_loc; if (CPP_OPTION (pfile, traditional)) { @@ -150,7 +150,7 @@ ATTRIBUTE_FPTR_PRINTF(6,0) static bool cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level, enum cpp_warning_reason reason, - source_location src_loc, unsigned int column, + location_t src_loc, unsigned int column, const char *msgid, va_list *ap) { bool ret; @@ -169,7 +169,7 @@ cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level, bool cpp_error_with_line (cpp_reader *pfile, enum cpp_diagnostic_level level, - source_location src_loc, unsigned int column, + location_t src_loc, unsigned int column, const char *msgid, ...) { va_list ap; @@ -188,7 +188,7 @@ cpp_error_with_line (cpp_reader *pfile, enum cpp_diagnostic_level level, bool cpp_warning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason, - source_location src_loc, unsigned int column, + location_t src_loc, unsigned int column, const char *msgid, ...) { va_list ap; @@ -207,7 +207,7 @@ cpp_warning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason, bool cpp_pedwarning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason, - source_location src_loc, unsigned int column, + location_t src_loc, unsigned int column, const char *msgid, ...) { va_list ap; @@ -227,7 +227,7 @@ cpp_pedwarning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason, bool cpp_warning_with_line_syshdr (cpp_reader *pfile, enum cpp_warning_reason reason, - source_location src_loc, unsigned int column, + location_t src_loc, unsigned int column, const char *msgid, ...) { va_list ap; @@ -247,7 +247,7 @@ cpp_warning_with_line_syshdr (cpp_reader *pfile, enum cpp_warning_reason reason, bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level, - source_location src_loc, const char *msgid, ...) + location_t src_loc, const char *msgid, ...) { va_list ap; bool ret; @@ -298,7 +298,7 @@ cpp_errno (cpp_reader *pfile, enum cpp_diagnostic_level level, bool cpp_errno_filename (cpp_reader *pfile, enum cpp_diagnostic_level level, const char *filename, - source_location loc) + location_t loc) { if (filename[0] == '\0') filename = _("stdout"); diff --git a/libcpp/expr.c b/libcpp/expr.c index 201a619..a639f5a 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -30,7 +30,7 @@ struct op { const cpp_token *token; /* The token forming op (for diagnostics). */ cpp_num value; /* The value logically "right" of op. */ - source_location loc; /* The location of this value. */ + location_t loc; /* The location of this value. */ enum cpp_ttype op; }; @@ -52,13 +52,13 @@ static cpp_num num_equality_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype); static cpp_num num_mul (cpp_reader *, cpp_num, cpp_num); static cpp_num num_div_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype, - source_location); + location_t); static cpp_num num_lshift (cpp_num, size_t, size_t); static cpp_num num_rshift (cpp_num, size_t, size_t); static cpp_num append_digit (cpp_num, int, int, size_t); static cpp_num parse_defined (cpp_reader *); -static cpp_num eval_token (cpp_reader *, const cpp_token *, source_location); +static cpp_num eval_token (cpp_reader *, const cpp_token *, location_t); static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype); static unsigned int interpret_float_suffix (cpp_reader *, const uchar *, size_t); static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t); @@ -505,7 +505,7 @@ cpp_get_userdef_suffix (const cpp_token *tok) VIRTUAL_LOCATION is the virtual location for TOKEN. */ unsigned int cpp_classify_number (cpp_reader *pfile, const cpp_token *token, - const char **ud_suffix, source_location virtual_location) + const char **ud_suffix, location_t virtual_location) { const uchar *str = token->val.str.text; const uchar *limit; @@ -1091,7 +1091,7 @@ parse_defined (cpp_reader *pfile) operators). */ static cpp_num eval_token (cpp_reader *pfile, const cpp_token *token, - source_location virtual_location) + location_t virtual_location) { cpp_num result; unsigned int temp; @@ -1288,7 +1288,7 @@ _cpp_parse_expr (cpp_reader *pfile, bool is_if) struct op *top = pfile->op_stack; unsigned int lex_count; bool saw_leading_not, want_value = true; - source_location virtual_location = 0; + location_t virtual_location = 0; pfile->state.skip_eval = 0; @@ -2086,7 +2086,7 @@ num_mul (cpp_reader *pfile, cpp_num lhs, cpp_num rhs) static cpp_num num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op, - source_location location) + location_t location) { cpp_num result, sub; cpp_num_part mask; diff --git a/libcpp/files.c b/libcpp/files.c index 0f0cc7b..3771fad 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -144,7 +144,7 @@ struct cpp_file_hash_entry { struct cpp_file_hash_entry *next; cpp_dir *start_dir; - source_location location; + location_t location; union { _cpp_file *file; @@ -171,18 +171,18 @@ static bool open_file (_cpp_file *file); static bool pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch); static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file, - bool *invalid_pch, source_location loc); + bool *invalid_pch, location_t loc); static bool read_file_guts (cpp_reader *pfile, _cpp_file *file, - source_location loc); + location_t loc); static bool read_file (cpp_reader *pfile, _cpp_file *file, - source_location loc); + location_t loc); static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import, - source_location loc); + location_t loc); static struct cpp_dir *search_path_head (cpp_reader *, const char *fname, int angle_brackets, enum include_type); static const char *dir_name_of_file (_cpp_file *file); static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int, - source_location); + location_t); static struct cpp_file_hash_entry *search_cache (struct cpp_file_hash_entry *head, const cpp_dir *start_dir); static _cpp_file *make_cpp_file (cpp_reader *, cpp_dir *, const char *fname); @@ -377,7 +377,7 @@ maybe_shorter_path (const char * file) static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch, - source_location loc) + location_t loc) { char *path; @@ -507,7 +507,7 @@ _cpp_find_failed (_cpp_file *file) _cpp_file * _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool fake, int angle_brackets, bool implicit_preinclude, - source_location loc) + location_t loc) { struct cpp_file_hash_entry *entry; void **hash_slot; @@ -671,7 +671,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, FIXME: Flush file cache and try again if we run out of memory. */ static bool -read_file_guts (cpp_reader *pfile, _cpp_file *file, source_location loc) +read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc) { ssize_t size, total, count; uchar *buf; @@ -755,7 +755,7 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, source_location loc) have been passed through find_file() at some stage. Use LOC for any diagnostics. */ static bool -read_file (cpp_reader *pfile, _cpp_file *file, source_location loc) +read_file (cpp_reader *pfile, _cpp_file *file, location_t loc) { /* If we already have its contents in memory, succeed immediately. */ if (file->buffer_valid) @@ -783,7 +783,7 @@ read_file (cpp_reader *pfile, _cpp_file *file, source_location loc) Use LOC for any diagnostics. */ static bool should_stack_file (cpp_reader *pfile, _cpp_file *file, bool import, - source_location loc) + location_t loc) { _cpp_file *f; @@ -892,7 +892,7 @@ should_stack_file (cpp_reader *pfile, _cpp_file *file, bool import, stacked. Use LOC for any diagnostics. */ bool _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import, - source_location loc) + location_t loc) { cpp_buffer *buffer; int sysp; @@ -1007,7 +1007,7 @@ dir_name_of_file (_cpp_file *file) Returns true if a buffer was stacked. */ bool _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, - enum include_type type, source_location loc) + enum include_type type, location_t loc) { struct cpp_dir *dir; _cpp_file *file; @@ -1037,7 +1037,7 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, /* Compensate for the increment in linemap_add that occurs if _cpp_stack_file actually stacks the file. In the case of a normal #include, we're currently at the start of the line - *following* the #include. A separate source_location for this + *following* the #include. A separate location_t for this location makes no sense (until we do the LC_LEAVE), and complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we found a PCH file (in which case linemap_add is not called) or we @@ -1059,7 +1059,7 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, /* Could not open FILE. The complication is dependency output. */ static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets, - source_location loc) + location_t loc) { int sysp = pfile->line_table->highest_line > 1 && pfile->buffer ? pfile->buffer->sysp : 0; bool print_dep = CPP_OPTION (pfile, deps.style) > (angle_brackets || !!sysp); @@ -1247,7 +1247,7 @@ cpp_included (cpp_reader *pfile, const char *fname) filenames aliased by links or redundant . or .. traversals etc. */ bool cpp_included_before (cpp_reader *pfile, const char *fname, - source_location location) + location_t location) { struct cpp_file_hash_entry *entry = (struct cpp_file_hash_entry *) diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index aad836d..ba99be6 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -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 */ diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index ae9780e..357b211 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -73,7 +73,7 @@ enum lc_reason LC_HWM /* High Water Mark. */ }; -/* The typedef "source_location" is a key within the location database, +/* The typedef "location_t" is a key within the location database, identifying a source location or macro expansion, along with range information, and (optionally) a pointer for use by gcc. @@ -182,7 +182,7 @@ enum lc_reason | macromap[1]->start_location | Start of macro map 1 -----------+-------------------------------+------------------------------- | macromap[0]->start_location | Start of macro map 0 - 0x7fffffff | MAX_SOURCE_LOCATION | Also used as a mask for + 0x7fffffff | MAX_LOCATION_T | Also used as a mask for | | accessing the ad-hoc data table -----------+-------------------------------+------------------------------- 0x80000000 | Start of ad-hoc values; the lower 31 bits are used as an index @@ -283,9 +283,9 @@ enum lc_reason finish == ordmap->start + (23 << 12) + (19 << 5) == ordmap->start + 0x17260 - To further see how source_location works in practice, see the + To further see how location_t works in practice, see the worked example in libcpp/location-example.txt. */ -typedef unsigned int source_location; +typedef unsigned int location_t; /* Do not track column numbers higher than this one. As a result, the range of column_bits is [12, 18] (or 0 if column numbers are @@ -295,15 +295,15 @@ const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 12); /* Do not pack ranges if locations get higher than this. If you change this, update: gcc.dg/plugin/location-overflow-test-*.c. */ -const source_location LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000; +const location_t LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000; /* Do not track column numbers if locations get higher than this. If you change this, update: gcc.dg/plugin/location-overflow-test-*.c. */ -const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000; +const location_t LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000; /* Highest possible source location encoded within an ordinary map. */ -const source_location LINE_MAP_MAX_LOCATION = 0x70000000; +const location_t LINE_MAP_MAX_LOCATION = 0x70000000; /* A range of source locations. @@ -315,15 +315,15 @@ const source_location LINE_MAP_MAX_LOCATION = 0x70000000; let's do it the simple way, as a pair. */ struct GTY(()) source_range { - source_location m_start; - source_location m_finish; + location_t m_start; + location_t m_finish; /* We avoid using constructors, since various structs that don't yet have constructors will embed instances of source_range. */ - /* Make a source_range from a source_location. */ - static source_range from_location (source_location loc) + /* Make a source_range from a location_t. */ + static source_range from_location (location_t loc) { source_range result; result.m_start = loc; @@ -331,9 +331,9 @@ struct GTY(()) source_range return result; } - /* Make a source_range from a pair of source_location. */ - static source_range from_locations (source_location start, - source_location finish) + /* Make a source_range from a pair of location_t. */ + static source_range from_locations (location_t start, + location_t finish) { source_range result; result.m_start = start; @@ -379,7 +379,7 @@ typedef size_t (*line_map_round_alloc_size_func) (size_t); /* This contains GTY mark-up to support precompiled headers. line_map is an abstract class, only derived objects exist. */ struct GTY((tag ("0"), desc ("MAP_ORDINARY_P (&%h) ? 1 : 2"))) line_map { - source_location start_location; + location_t start_location; /* Size and alignment is (usually) 4 bytes. */ }; @@ -395,7 +395,7 @@ struct GTY((tag ("0"), desc ("MAP_ORDINARY_P (&%h) ? 1 : 2"))) line_map { (The top line is line 1 and the leftmost column is column 1; line/column 0 means "entire file/line" or "unknown line/column" or "not applicable".) - The highest possible source location is MAX_SOURCE_LOCATION. */ + The highest possible source location is MAX_LOCATION_T. */ struct GTY((tag ("1"))) line_map_ordinary : public line_map { /* Base class is 4 bytes. */ @@ -410,7 +410,7 @@ struct GTY((tag ("1"))) line_map_ordinary : public line_map { cpp_buffer. */ unsigned char sysp; - /* Number of the low-order source_location bits used for column numbers + /* Number of the low-order location_t bits used for column numbers and ranges. */ unsigned int m_column_and_range_bits : 8; @@ -437,14 +437,14 @@ struct GTY((tag ("1"))) line_map_ordinary : public line_map { /* Location from whence this line map was included. For regular #includes, this location will be the last location of a map. For outermost file, this is 0. */ - source_location included_from; + location_t included_from; /* Size is 20 or 24 bytes, no padding */ }; /* This is the highest possible source location encoded within an ordinary or macro map. */ -const source_location MAX_SOURCE_LOCATION = 0x7FFFFFFF; +const location_t MAX_LOCATION_T = 0x7FFFFFFF; struct cpp_hashnode; @@ -521,14 +521,14 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { In the example above x1 (for token "+") is going to be the same as y1. x0 is the spelling location for the argument token "1", and x2 is the spelling location for the argument token "2". */ - source_location * GTY((atomic)) macro_locations; + location_t * GTY((atomic)) macro_locations; /* This is the location of the expansion point of the current macro map. It's the location of the macro name. That location is held by the map that was current right before the current one. It could have been either a macro or an ordinary map, depending on if we are in a nested expansion context not. */ - source_location expansion; + location_t expansion; /* Size is 20 or 32 (4 bytes padding on 64-bit). */ }; @@ -561,19 +561,19 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { /* Get whether location LOC is an ad-hoc, ordinary or macro location. */ inline bool -IS_ORDINARY_LOC (source_location loc) +IS_ORDINARY_LOC (location_t loc) { return loc < LINE_MAP_MAX_LOCATION; } inline bool -IS_ADHOC_LOC (source_location loc) +IS_ADHOC_LOC (location_t loc) { - return loc > MAX_SOURCE_LOCATION; + return loc > MAX_LOCATION_T; } inline bool -IS_MACRO_LOC (source_location loc) +IS_MACRO_LOC (location_t loc) { return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc); } @@ -634,7 +634,7 @@ linemap_check_macro (const line_map *map) /* Read the start location of MAP. */ -inline source_location +inline location_t MAP_START_LOCATION (const line_map *map) { return map->start_location; @@ -687,7 +687,7 @@ MACRO_MAP_NUM_MACRO_TOKENS (const line_map_macro *macro_map) /* Get the array of pairs of locations within macro map MAP. See the declaration of line_map_macro for more information. */ -inline source_location * +inline location_t * MACRO_MAP_LOCATIONS (const line_map_macro *macro_map) { return macro_map->macro_locations; @@ -695,7 +695,7 @@ MACRO_MAP_LOCATIONS (const line_map_macro *macro_map) /* Get the location of the expansion point of the macro map MAP. */ -inline source_location +inline location_t MACRO_MAP_EXPANSION_POINT_LOCATION (const line_map_macro *macro_map) { return macro_map->expansion; @@ -742,7 +742,7 @@ struct GTY(()) maps_info_macro { /* Data structure to associate a source_range together with an arbitrary data pointer with a source location. */ struct GTY(()) location_adhoc_data { - source_location locus; + location_t locus; source_range src_range; void * GTY((skip)) data; }; @@ -761,7 +761,7 @@ struct htab; struct GTY(()) location_adhoc_data_map { struct htab * GTY((skip)) htab; - source_location curr_loc; + location_t curr_loc; unsigned int allocated; struct location_adhoc_data GTY((length ("%h.allocated"))) *data; }; @@ -781,11 +781,11 @@ struct GTY(()) line_maps { /* If true, prints an include trace a la -H. */ bool trace_includes; - /* Highest source_location "given out". */ - source_location highest_location; + /* Highest location_t "given out". */ + location_t highest_location; - /* Start of line of highest source_location "given out". */ - source_location highest_line; + /* Start of line of highest location_t "given out". */ + location_t highest_line; /* The maximum column number we can quickly allocate. Higher numbers may require allocating a new line_map. */ @@ -802,7 +802,7 @@ struct GTY(()) line_maps { /* The special location value that is used as spelling location for built-in tokens. */ - source_location builtin_location; + location_t builtin_location; /* True if we've seen a #line or # 44 "file" directive. */ bool seen_line_directive; @@ -1032,12 +1032,12 @@ LINEMAPS_LAST_MACRO_MAP (const line_maps *set) /* Returns the lowest location [of a token resulting from macro expansion] encoded in this line table. */ -inline source_location +inline location_t LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set) { return LINEMAPS_MACRO_USED (set) ? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set)) - : MAX_SOURCE_LOCATION + 1; + : MAX_LOCATION_T + 1; } /* Returns the last macro map allocated in the line table SET. */ @@ -1047,33 +1047,33 @@ LINEMAPS_LAST_ALLOCATED_MACRO_MAP (const line_maps *set) return (line_map_macro *)LINEMAPS_LAST_ALLOCATED_MAP (set, true); } -extern source_location get_combined_adhoc_loc (struct line_maps *, - source_location, +extern location_t get_combined_adhoc_loc (struct line_maps *, + location_t, source_range, void *); -extern void *get_data_from_adhoc_loc (struct line_maps *, source_location); -extern source_location get_location_from_adhoc_loc (struct line_maps *, - source_location); +extern void *get_data_from_adhoc_loc (struct line_maps *, location_t); +extern location_t get_location_from_adhoc_loc (struct line_maps *, + location_t); -extern source_range get_range_from_loc (line_maps *set, source_location loc); +extern source_range get_range_from_loc (line_maps *set, location_t loc); /* Get whether location LOC is a "pure" location, or whether it is an ad-hoc location, or embeds range information. */ bool -pure_location_p (line_maps *set, source_location loc); +pure_location_p (line_maps *set, location_t loc); /* Given location LOC within SET, strip away any packed range information or ad-hoc information. */ -extern source_location get_pure_location (line_maps *set, - source_location loc); +extern location_t get_pure_location (line_maps *set, + location_t loc); /* Combine LOC and BLOCK, giving a combined adhoc location. */ -inline source_location +inline location_t COMBINE_LOCATION_DATA (struct line_maps *set, - source_location loc, + location_t loc, source_range src_range, void *block) { @@ -1087,19 +1087,19 @@ extern void rebuild_location_adhoc_htab (struct line_maps *); spelling location for built-in tokens. This BUILTIN_LOCATION has to be strictly less than RESERVED_LOCATION_COUNT. */ extern void linemap_init (struct line_maps *set, - source_location builtin_location); + location_t builtin_location); /* Check for and warn about line_maps entered but not exited. */ extern void linemap_check_files_exited (struct line_maps *); -/* Return a source_location for the start (i.e. column==0) of +/* Return a location_t for the start (i.e. column==0) of (physical) line TO_LINE in the current source file (as in the most recent linemap_add). MAX_COLUMN_HINT is the highest column number we expect to use in this line (but it does not change the highest_location). */ -extern source_location linemap_line_start +extern location_t linemap_line_start (struct line_maps *set, linenum_type to_line, unsigned int max_column_hint); /* Add a mapping of logical source line to physical source file and @@ -1126,7 +1126,7 @@ extern const struct line_map *linemap_add binary search. If no line map have been allocated yet, this function returns NULL. */ extern const struct line_map *linemap_lookup - (struct line_maps *, source_location); + (struct line_maps *, location_t); /* Returns TRUE if the line table set tracks token locations across macro expansion, FALSE otherwise. */ @@ -1145,49 +1145,49 @@ const char* linemap_map_get_macro_name (const line_map_macro *); that is part of a macro replacement-list defined in a system header, but expanded in a non-system file. */ int linemap_location_in_system_header_p (struct line_maps *, - source_location); + location_t); /* Return TRUE if LOCATION is a source code location of a token that is part of a macro expansion, FALSE otherwise. */ bool linemap_location_from_macro_expansion_p (const struct line_maps *, - source_location); + location_t); /* TRUE if LOCATION is a source code location of a token that is part of the definition of a macro, FALSE otherwise. */ bool linemap_location_from_macro_definition_p (struct line_maps *, - source_location); + location_t); /* With the precondition that LOCATION is the locus of a token that is an argument of a function-like macro MACRO_MAP and appears in the expansion of MACRO_MAP, return the locus of that argument in the context of the caller of MACRO_MAP. */ -extern source_location linemap_macro_map_loc_unwind_toward_spelling - (line_maps *set, const line_map_macro *macro_map, source_location location); +extern location_t linemap_macro_map_loc_unwind_toward_spelling + (line_maps *set, const line_map_macro *macro_map, location_t location); -/* source_location values from 0 to RESERVED_LOCATION_COUNT-1 will +/* location_t values from 0 to RESERVED_LOCATION_COUNT-1 will be reserved for libcpp user as special values, no token from libcpp will contain any of those locations. */ -const source_location RESERVED_LOCATION_COUNT = 2; +const location_t RESERVED_LOCATION_COUNT = 2; -/* Converts a map and a source_location to source line. */ +/* Converts a map and a location_t to source line. */ inline linenum_type -SOURCE_LINE (const line_map_ordinary *ord_map, source_location loc) +SOURCE_LINE (const line_map_ordinary *ord_map, location_t loc) { return ((loc - ord_map->start_location) >> ord_map->m_column_and_range_bits) + ord_map->to_line; } -/* Convert a map and source_location to source column number. */ +/* Convert a map and location_t to source column number. */ inline linenum_type -SOURCE_COLUMN (const line_map_ordinary *ord_map, source_location loc) +SOURCE_COLUMN (const line_map_ordinary *ord_map, location_t loc) { return ((loc - ord_map->start_location) & ((1 << ord_map->m_column_and_range_bits) - 1)) >> ord_map->m_range_bits; } -inline source_location +inline location_t linemap_included_from (const line_map_ordinary *ord_map) { return ord_map->included_from; @@ -1205,26 +1205,26 @@ MAIN_FILE_P (const line_map_ordinary *ord_map) return ord_map->included_from == 0; } -/* Encode and return a source_location from a column number. The +/* Encode and return a location_t from a column number. The source line considered is the last source line used to call linemap_line_start, i.e, the last source line which a location was encoded from. */ -extern source_location +extern location_t linemap_position_for_column (struct line_maps *, unsigned int); /* Encode and return a source location from a given line and column. */ -source_location +location_t linemap_position_for_line_and_column (line_maps *set, const line_map_ordinary *, linenum_type, unsigned int); -/* Encode and return a source_location starting from location LOC and +/* Encode and return a location_t starting from location LOC and shifting it by OFFSET columns. This function does not support virtual locations. */ -source_location +location_t linemap_position_for_loc_and_offset (struct line_maps *set, - source_location loc, + location_t loc, unsigned int offset); /* Return the file this map is for. */ @@ -1256,16 +1256,16 @@ LINEMAP_SYSP (const line_map_ordinary *ord_map) the same token as the token for POST, and a negative value otherwise. */ int linemap_compare_locations (struct line_maps *set, - source_location pre, - source_location post); + location_t pre, + location_t post); /* Return TRUE if LOC_A denotes the location a token that comes topogically before the token denoted by location LOC_B, or if they are equal. */ inline bool linemap_location_before_p (struct line_maps *set, - source_location loc_a, - source_location loc_b) + location_t loc_a, + location_t loc_b) { return linemap_compare_locations (set, loc_a, loc_b) >= 0; } @@ -1324,7 +1324,7 @@ enum range_display_kind struct location_range { - source_location m_loc; + location_t m_loc; enum range_display_kind m_range_display_kind; @@ -1607,7 +1607,7 @@ class fixit_hint; Adding a fix-it hint can fail: for example, attempts to insert content at the transition between two line maps may fail due to there being no - source_location (aka location_t) value to express the new location. + location_t value to express the new location. Attempts to add a fix-it hint within a macro expansion will fail. @@ -1637,24 +1637,24 @@ class rich_location /* Constructors. */ /* Constructing from a location. */ - rich_location (line_maps *set, source_location loc, + rich_location (line_maps *set, location_t loc, const range_label *label = NULL); /* Destructor. */ ~rich_location (); /* Accessors. */ - source_location get_loc () const { return get_loc (0); } - source_location get_loc (unsigned int idx) const; + location_t get_loc () const { return get_loc (0); } + location_t get_loc (unsigned int idx) const; void - add_range (source_location loc, + add_range (location_t loc, enum range_display_kind range_display_kind = SHOW_RANGE_WITHOUT_CARET, const range_label *label = NULL); void - set_range (unsigned int idx, source_location loc, + set_range (unsigned int idx, location_t loc, enum range_display_kind range_display_kind); unsigned int get_num_locations () const { return m_ranges.count (); } @@ -1678,7 +1678,7 @@ class rich_location /* Suggest inserting NEW_CONTENT immediately before the start of WHERE. */ void - add_fixit_insert_before (source_location where, + add_fixit_insert_before (location_t where, const char *new_content); /* Suggest inserting NEW_CONTENT immediately after the end of the primary @@ -1688,7 +1688,7 @@ class rich_location /* Suggest inserting NEW_CONTENT immediately after the end of WHERE. */ void - add_fixit_insert_after (source_location where, + add_fixit_insert_after (location_t where, const char *new_content); /* Methods for adding removal fix-it hints. */ @@ -1700,7 +1700,7 @@ class rich_location /* Suggest removing the content covered between the start and finish of WHERE. */ void - add_fixit_remove (source_location where); + add_fixit_remove (location_t where); /* Suggest removing the content covered by SRC_RANGE. */ void @@ -1715,7 +1715,7 @@ class rich_location /* Suggest replacing the content between the start and finish of WHERE with NEW_CONTENT. */ void - add_fixit_replace (source_location where, + add_fixit_replace (location_t where, const char *new_content); /* Suggest replacing the content covered by SRC_RANGE with @@ -1751,10 +1751,10 @@ class rich_location } private: - bool reject_impossible_fixit (source_location where); + bool reject_impossible_fixit (location_t where); void stop_supporting_fixits (); - void maybe_add_fixit (source_location start, - source_location next_loc, + void maybe_add_fixit (location_t start, + location_t next_loc, const char *new_content); public: @@ -1843,16 +1843,16 @@ class range_label class fixit_hint { public: - fixit_hint (source_location start, - source_location next_loc, + fixit_hint (location_t start, + location_t next_loc, const char *new_content); ~fixit_hint () { free (m_bytes); } bool affects_line_p (const char *file, int line) const; - source_location get_start_loc () const { return m_start; } - source_location get_next_loc () const { return m_next_loc; } - bool maybe_append (source_location start, - source_location next_loc, + location_t get_start_loc () const { return m_start; } + location_t get_next_loc () const { return m_next_loc; } + bool maybe_append (location_t start, + location_t next_loc, const char *new_content); const char *get_string () const { return m_bytes; } @@ -1867,8 +1867,8 @@ class fixit_hint this is a half-open/half-closed range: [start, next_loc) so that we can support insertion via start == next_loc. */ - source_location m_start; - source_location m_next_loc; + location_t m_start; + location_t m_next_loc; char *m_bytes; size_t m_len; }; @@ -1932,10 +1932,10 @@ enum location_resolution_kind resolves to a location reserved for the client code, like UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */ -source_location linemap_resolve_location (struct line_maps *, - source_location loc, - enum location_resolution_kind lrk, - const line_map_ordinary **loc_map); +location_t linemap_resolve_location (struct line_maps *, + location_t loc, + enum location_resolution_kind lrk, + const line_map_ordinary **loc_map); /* Suppose that LOC is the virtual location of a token coming from the expansion of a macro M. This function then steps up to get the @@ -1944,9 +1944,9 @@ source_location linemap_resolve_location (struct line_maps *, the point where M' was expanded. LOC_MAP is an output parameter. When non-NULL, *LOC_MAP is set to the map of the returned location. */ -source_location linemap_unwind_toward_expansion (struct line_maps *, - source_location loc, - const struct line_map **loc_map); +location_t linemap_unwind_toward_expansion (struct line_maps *, + location_t loc, + const struct line_map **loc_map); /* If LOC is the virtual location of a token coming from the expansion of a macro M and if its spelling location is reserved (e.g, a @@ -1962,9 +1962,9 @@ source_location linemap_unwind_toward_expansion (struct line_maps *, *MAP is set to the map of the returned location if the later is different from LOC. */ -source_location linemap_unwind_to_first_non_reserved_loc (struct line_maps *, - source_location loc, - const struct line_map **map); +location_t linemap_unwind_to_first_non_reserved_loc (struct line_maps *, + location_t loc, + const struct line_map **map); /* Expand source code location LOC and return a user readable source code location. LOC must be a spelling (non-virtual) location. If @@ -1972,7 +1972,7 @@ source_location linemap_unwind_to_first_non_reserved_loc (struct line_maps *, location is returned. */ expanded_location linemap_expand_location (struct line_maps *, const struct line_map *, - source_location loc); + location_t loc); /* Statistics about maps allocation and usage as returned by linemap_get_statistics. */ @@ -1999,7 +1999,7 @@ struct linemap_stats location emitted for that file. */ bool linemap_get_file_highest_location (struct line_maps * set, const char *file_name, - source_location *loc); + location_t *loc); /* Compute and return statistics about the memory consumption of some parts of the line table SET. */ @@ -2007,7 +2007,7 @@ void linemap_get_statistics (struct line_maps *, struct linemap_stats *); /* Dump debugging information about source location LOC into the file stream STREAM. SET is the line map set LOC comes from. */ -void linemap_dump_location (struct line_maps *, source_location, FILE *); +void linemap_dump_location (struct line_maps *, location_t, FILE *); /* Dump line map at index IX in line table SET to STREAM. If STREAM is NULL, use stderr. IS_MACRO is true if the caller wants to @@ -2019,7 +2019,7 @@ void linemap_dump (FILE *, struct line_maps *, unsigned, bool); specifies how many macro maps to dump. */ void line_table_dump (FILE *, struct line_maps *, unsigned int, unsigned int); -/* An enum for distinguishing the various parts within a source_location. */ +/* An enum for distinguishing the various parts within a location_t. */ enum location_aspect { @@ -2028,14 +2028,14 @@ enum location_aspect LOCATION_ASPECT_FINISH }; -/* The rich_location class requires a way to expand source_location instances. +/* The rich_location class requires a way to expand location_t instances. We would directly use expand_location_to_spelling_point, which is implemented in gcc/input.c, but we also need to use it for rich_location within genmatch.c. Hence we require client code of libcpp to implement the following symbol. */ extern expanded_location -linemap_client_expand_location_to_spelling_point (source_location, +linemap_client_expand_location_to_spelling_point (location_t, enum location_aspect); #endif /* !LIBCPP_LINE_MAP_H */ diff --git a/libcpp/init.c b/libcpp/init.c index 43c07fc..849aedc 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -633,7 +633,7 @@ cpp_post_options (cpp_reader *pfile) const char * cpp_read_main_file (cpp_reader *pfile, const char *fname) { - const source_location loc = 0; + const location_t loc = 0; if (CPP_OPTION (pfile, deps.style) != DEPS_NONE) { diff --git a/libcpp/internal.h b/libcpp/internal.h index 98fefeb..59e18ec 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -150,11 +150,11 @@ typedef struct location at index 0 is the virtual location of the token at index 0 in the current instance of cpp_context; similarly for all the other virtual locations. */ - source_location *virt_locs; + location_t *virt_locs; /* This is a pointer to the current virtual location. This is used to iterate over the virtual locations while we iterate over the tokens they belong to. */ - source_location *cur_virt_loc; + location_t *cur_virt_loc; } macro_context; /* The kind of tokens carried by a cpp_context. */ @@ -372,7 +372,7 @@ struct def_pragma_macro { unsigned char *definition; /* Definition line number. */ - source_location line; + location_t line; /* If macro defined in system header. */ unsigned int syshdr : 1; /* Nonzero if it has been expanded or had its existence tested. */ @@ -400,7 +400,7 @@ struct cpp_reader struct line_maps *line_table; /* The line of the '#' of the current directive. */ - source_location directive_line; + location_t directive_line; /* Memory buffers. */ _cpp_buff *a_buff; /* Aligned permanent storage. */ @@ -419,7 +419,7 @@ struct cpp_reader /* When expanding a macro at top-level, this is the location of the macro invocation. */ - source_location invocation_location; + location_t invocation_location; /* This is the node representing the macro being expanded at top-level. The value of this data member is valid iff @@ -551,7 +551,7 @@ struct cpp_reader unsigned char *base; unsigned char *limit; unsigned char *cur; - source_location first_line; + location_t first_line; } out; /* Used for buffer overlays by traditional.c. */ @@ -572,7 +572,7 @@ struct cpp_reader /* If non-zero, the lexer will use this location for the next token instead of getting a location from the linemap. */ - source_location forced_token_location; + location_t forced_token_location; }; /* Character classes. Based on the more primitive macros in safe-ctype.h. @@ -646,7 +646,7 @@ extern bool _cpp_arguments_ok (cpp_reader *, cpp_macro *, const cpp_hashnode *, unsigned int); extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *, cpp_hashnode *, - source_location = 0); + location_t = 0); extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *); extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *, const cpp_token *, unsigned int); @@ -659,14 +659,14 @@ extern void _cpp_destroy_hashtable (cpp_reader *); /* In files.c */ typedef struct _cpp_file _cpp_file; extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *, - bool, int, bool, source_location); + bool, int, bool, location_t); extern bool _cpp_find_failed (_cpp_file *); extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *); extern void _cpp_fake_include (cpp_reader *, const char *); extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, bool, - source_location); + location_t); extern bool _cpp_stack_include (cpp_reader *, const char *, int, - enum include_type, source_location); + enum include_type, location_t); extern int _cpp_compare_file_date (cpp_reader *, const char *, int); extern void _cpp_report_missing_guards (cpp_reader *); extern void _cpp_init_files (cpp_reader *); @@ -717,7 +717,7 @@ extern int _cpp_handle_directive (cpp_reader *, int); extern void _cpp_define_builtin (cpp_reader *, const char *); extern char ** _cpp_save_pragma_names (cpp_reader *); extern void _cpp_restore_pragma_names (cpp_reader *, char **); -extern int _cpp_do__Pragma (cpp_reader *, source_location); +extern int _cpp_do__Pragma (cpp_reader *, location_t); extern void _cpp_init_directives (cpp_reader *); extern void _cpp_init_internal_pragmas (cpp_reader *); extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *, @@ -730,7 +730,7 @@ struct _cpp_dir_only_callbacks { /* Called to print a block of lines. */ void (*print_lines) (int, const void *, size_t); - bool (*maybe_print_line) (source_location); + bool (*maybe_print_line) (location_t); }; extern void _cpp_preprocess_dir_only (cpp_reader *, @@ -867,7 +867,7 @@ ufputs (const unsigned char *s, FILE *f) the replacement-list of MACRO. */ const line_map_macro *linemap_enter_macro (struct line_maps *, struct cpp_hashnode*, - source_location, + location_t, unsigned int); /* Create and return a virtual location for a token that is part of a @@ -892,10 +892,10 @@ const line_map_macro *linemap_enter_macro (struct line_maps *, MACRO_DEFINITION_LOC is the location in the macro definition, either of the token itself or of a macro parameter that it replaces. */ -source_location linemap_add_macro_token (const line_map_macro *, - unsigned int, - source_location, - source_location); +location_t linemap_add_macro_token (const line_map_macro *, + unsigned int, + location_t, + location_t); /* Return the source line number corresponding to source location LOCATION. SET is the line map set LOCATION comes from. If @@ -903,7 +903,7 @@ source_location linemap_add_macro_token (const line_map_macro *, expansion-list of a macro expansion return the line number of the macro expansion point. */ int linemap_get_expansion_line (struct line_maps *, - source_location); + location_t); /* Return the path of the file corresponding to source code location LOCATION. @@ -914,7 +914,7 @@ int linemap_get_expansion_line (struct line_maps *, SET is the line map set LOCATION comes from. */ const char* linemap_get_expansion_filename (struct line_maps *, - source_location); + location_t); #ifdef __cplusplus } diff --git a/libcpp/lex.c b/libcpp/lex.c index c6e34b3..3a2fdb1 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1232,7 +1232,7 @@ static int skip_line_comment (cpp_reader *pfile) { cpp_buffer *buffer = pfile->buffer; - source_location orig_line = pfile->line_table->highest_line; + location_t orig_line = pfile->line_table->highest_line; while (*buffer->cur != '\n') buffer->cur++; @@ -1894,7 +1894,7 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base, _cpp_process_line_notes (pfile, false); if (!_cpp_get_fresh_line (pfile)) { - source_location src_loc = token->src_loc; + location_t src_loc = token->src_loc; token->type = CPP_EOF; /* Tell the compiler the line number of the EOF token. */ token->src_loc = pfile->line_table->highest_line; @@ -3774,11 +3774,11 @@ cpp_token_val_index (const cpp_token *tok) } /* All tokens lexed in R after calling this function will be forced to - have their source_location to be P, until + have their location_t to be P, until cpp_stop_forcing_token_locations is called for R. */ void -cpp_force_token_locations (cpp_reader *r, source_location loc) +cpp_force_token_locations (cpp_reader *r, location_t loc) { r->forced_token_location = loc; } diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 2d3ed83..bea7bb8 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -28,21 +28,21 @@ along with this program; see the file COPYING3. If not see static void trace_include (const struct line_maps *, const line_map_ordinary *); static const line_map_ordinary * linemap_ordinary_map_lookup (struct line_maps *, - source_location); + location_t); static const line_map_macro* linemap_macro_map_lookup (struct line_maps *, - source_location); -static source_location linemap_macro_map_loc_to_def_point -(const line_map_macro *, source_location); -static source_location linemap_macro_map_loc_to_exp_point -(const line_map_macro *, source_location); -static source_location linemap_macro_loc_to_spelling_point -(struct line_maps *, source_location, const line_map_ordinary **); -static source_location linemap_macro_loc_to_def_point (struct line_maps *, - source_location, - const line_map_ordinary **); -static source_location linemap_macro_loc_to_exp_point (struct line_maps *, - source_location, - const line_map_ordinary **); + location_t); +static location_t linemap_macro_map_loc_to_def_point +(const line_map_macro *, location_t); +static location_t linemap_macro_map_loc_to_exp_point +(const line_map_macro *, location_t); +static location_t linemap_macro_loc_to_spelling_point +(struct line_maps *, location_t, const line_map_ordinary **); +static location_t linemap_macro_loc_to_def_point (line_maps *, + location_t, + const line_map_ordinary **); +static location_t linemap_macro_loc_to_exp_point (line_maps *, + location_t, + const line_map_ordinary **); /* Counters defined in macro.c. */ extern unsigned num_expanded_macros_counter; @@ -110,16 +110,16 @@ rebuild_location_adhoc_htab (struct line_maps *set) /* Helper function for get_combined_adhoc_loc. Can the given LOCUS + SRC_RANGE and DATA pointer be stored compactly - within a source_location, without needing to use an ad-hoc location. */ + within a location_t, without needing to use an ad-hoc location. */ static bool can_be_stored_compactly_p (struct line_maps *set, - source_location locus, + location_t locus, source_range src_range, void *data) { /* If there's an ad-hoc pointer, we can't store it directly in the - source_location, we need the lookaside. */ + location_t, we need the lookaside. */ if (data) return false; @@ -139,7 +139,7 @@ can_be_stored_compactly_p (struct line_maps *set, /* All 3 locations must be within ordinary maps, typically, the same ordinary map. */ - source_location lowest_macro_loc = LINEMAPS_MACRO_LOWEST_LOCATION (set); + location_t lowest_macro_loc = LINEMAPS_MACRO_LOWEST_LOCATION (set); if (locus >= lowest_macro_loc) return false; if (src_range.m_start >= lowest_macro_loc) @@ -153,9 +153,9 @@ can_be_stored_compactly_p (struct line_maps *set, /* Combine LOCUS and DATA to a combined adhoc loc. */ -source_location +location_t get_combined_adhoc_loc (struct line_maps *set, - source_location locus, + location_t locus, source_range src_range, void *data) { @@ -164,7 +164,7 @@ get_combined_adhoc_loc (struct line_maps *set, if (IS_ADHOC_LOC (locus)) locus - = set->location_adhoc_data_map.data[locus & MAX_SOURCE_LOCATION].locus; + = set->location_adhoc_data_map.data[locus & MAX_LOCATION_T].locus; if (locus == 0 && data == NULL) return 0; @@ -186,7 +186,7 @@ get_combined_adhoc_loc (struct line_maps *set, unsigned int col_diff = (int_diff >> ordmap->m_range_bits); if (col_diff < (1U << ordmap->m_range_bits)) { - source_location packed = locus | col_diff; + location_t packed = locus | col_diff; set->num_optimized_ranges++; return packed; } @@ -243,28 +243,28 @@ get_combined_adhoc_loc (struct line_maps *set, /* Return the data for the adhoc loc. */ void * -get_data_from_adhoc_loc (struct line_maps *set, source_location loc) +get_data_from_adhoc_loc (struct line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].data; + return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data; } /* Return the location for the adhoc loc. */ -source_location -get_location_from_adhoc_loc (struct line_maps *set, source_location loc) +location_t +get_location_from_adhoc_loc (struct line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; } /* Return the source_range for adhoc location LOC. */ static source_range -get_range_from_adhoc_loc (struct line_maps *set, source_location loc) +get_range_from_adhoc_loc (struct line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); - return set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].src_range; + return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].src_range; } /* Get the source_range of location LOC, either from the ad-hoc @@ -272,7 +272,7 @@ get_range_from_adhoc_loc (struct line_maps *set, source_location loc) source_range get_range_from_loc (struct line_maps *set, - source_location loc) + location_t loc) { if (IS_ADHOC_LOC (loc)) return get_range_from_adhoc_loc (set, loc); @@ -298,7 +298,7 @@ get_range_from_loc (struct line_maps *set, whether it is an ad-hoc location, or embeds range information. */ bool -pure_location_p (line_maps *set, source_location loc) +pure_location_p (line_maps *set, location_t loc) { if (IS_ADHOC_LOC (loc)) return false; @@ -317,12 +317,12 @@ pure_location_p (line_maps *set, source_location loc) /* Given location LOC within SET, strip away any packed range information or ad-hoc information. */ -source_location -get_pure_location (line_maps *set, source_location loc) +location_t +get_pure_location (line_maps *set, location_t loc) { if (IS_ADHOC_LOC (loc)) loc - = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (set)) return loc; @@ -340,7 +340,7 @@ get_pure_location (line_maps *set, source_location loc) void linemap_init (struct line_maps *set, - source_location builtin_location) + location_t builtin_location) { #if __GNUC__ == 4 && __GNUC_MINOR__ == 2 && !defined (__clang__) /* PR33916, needed to fix PR82939. */ @@ -386,7 +386,7 @@ linemap_check_files_exited (struct line_maps *set) macro maps are allocated in different memory location. */ static struct line_map * -new_linemap (struct line_maps *set, source_location start_location) +new_linemap (struct line_maps *set, location_t start_location) { bool macro_p = start_location >= LINE_MAP_MAX_LOCATION; unsigned num_maps_allocated = LINEMAPS_ALLOCATED (set, macro_p); @@ -464,7 +464,7 @@ linemap_add (struct line_maps *set, enum lc_reason reason, { /* Generate a start_location above the current highest_location. If possible, make the low range bits be zero. */ - source_location start_location; + location_t start_location; if (set->highest_location < LINE_MAP_MAX_LOCATION_WITH_COLS) { start_location = set->highest_location + (1 << set->default_range_bits); @@ -610,9 +610,9 @@ linemap_tracks_macro_expansion_locs_p (struct line_maps *set) const line_map_macro * linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node, - source_location expansion, unsigned int num_tokens) + location_t expansion, unsigned int num_tokens) { - source_location start_location + location_t start_location = LINEMAPS_MACRO_LOWEST_LOCATION (set) - num_tokens; if (start_location < LINE_MAP_MAX_LOCATION) @@ -624,12 +624,12 @@ linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node, map->macro = macro_node; map->n_tokens = num_tokens; map->macro_locations - = (source_location*) set->reallocator (NULL, + = (location_t*) set->reallocator (NULL, 2 * num_tokens - * sizeof (source_location)); + * sizeof (location_t)); map->expansion = expansion; memset (MACRO_MAP_LOCATIONS (map), 0, - 2 * num_tokens * sizeof (source_location)); + 2 * num_tokens * sizeof (location_t)); LINEMAPS_MACRO_CACHE (set) = LINEMAPS_MACRO_USED (set) - 1; @@ -659,13 +659,13 @@ linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node, either of the token itself or of a macro parameter that it replaces. */ -source_location +location_t linemap_add_macro_token (const line_map_macro *map, unsigned int token_no, - source_location orig_loc, - source_location orig_parm_replacement_loc) + location_t orig_loc, + location_t orig_parm_replacement_loc) { - source_location result; + location_t result; linemap_assert (linemap_macro_expansion_map_p (map)); linemap_assert (token_no < MACRO_MAP_NUM_MACRO_TOKENS (map)); @@ -677,19 +677,19 @@ linemap_add_macro_token (const line_map_macro *map, return result; } -/* Return a source_location for the start (i.e. column==0) of +/* Return a location_t for the start (i.e. column==0) of (physical) line TO_LINE in the current source file (as in the most recent linemap_add). MAX_COLUMN_HINT is the highest column number we expect to use in this line (but it does not change the highest_location). */ -source_location +location_t linemap_line_start (struct line_maps *set, linenum_type to_line, unsigned int max_column_hint) { line_map_ordinary *map = LINEMAPS_LAST_ORDINARY_MAP (set); - source_location highest = set->highest_location; - source_location r; + location_t highest = set->highest_location; + location_t r; linenum_type last_line = SOURCE_LINE (map, set->highest_line); int line_delta = to_line - last_line; @@ -717,7 +717,7 @@ linemap_line_start (struct line_maps *set, linenum_type to_line, || highest > LINE_MAP_MAX_LOCATION_WITH_COLS) { /* If the column number is ridiculous or we've allocated a huge - number of source_locations, give up on column numbers + number of location_ts, give up on column numbers (and on packed ranges). */ max_column_hint = 0; column_bits = 0; @@ -782,15 +782,15 @@ linemap_line_start (struct line_maps *set, linenum_type to_line, return r; } -/* Encode and return a source_location from a column number. The +/* Encode and return a location_t from a column number. The source line considered is the last source line used to call linemap_line_start, i.e, the last source line which a location was encoded from. */ -source_location +location_t linemap_position_for_column (struct line_maps *set, unsigned int to_column) { - source_location r = set->highest_line; + location_t r = set->highest_line; linemap_assert (!linemap_macro_expansion_map_p (LINEMAPS_LAST_ORDINARY_MAP (set))); @@ -800,7 +800,7 @@ linemap_position_for_column (struct line_maps *set, unsigned int to_column) if (r > LINE_MAP_MAX_LOCATION_WITH_COLS || to_column > LINE_MAP_MAX_COLUMN_NUMBER) { - /* Running low on source_locations - disable column numbers. */ + /* Running low on location_ts - disable column numbers. */ return r; } else @@ -833,7 +833,7 @@ linemap_position_for_column (struct line_maps *set, unsigned int to_column) /* Encode and return a source location from a given line and column. */ -source_location +location_t linemap_position_for_line_and_column (line_maps *set, const line_map_ordinary *ord_map, linenum_type line, @@ -841,13 +841,13 @@ linemap_position_for_line_and_column (line_maps *set, { linemap_assert (ORDINARY_MAP_STARTING_LINE_NUMBER (ord_map) <= line); - source_location r = MAP_START_LOCATION (ord_map); + location_t r = MAP_START_LOCATION (ord_map); r += ((line - ORDINARY_MAP_STARTING_LINE_NUMBER (ord_map)) << ord_map->m_column_and_range_bits); if (r <= LINE_MAP_MAX_LOCATION_WITH_COLS) r += ((column & ((1 << ord_map->m_column_and_range_bits) - 1)) << ord_map->m_range_bits); - source_location upper_limit = LINEMAPS_MACRO_LOWEST_LOCATION (set); + location_t upper_limit = LINEMAPS_MACRO_LOWEST_LOCATION (set); if (r >= upper_limit) r = upper_limit - 1; if (r > set->highest_location) @@ -855,19 +855,19 @@ linemap_position_for_line_and_column (line_maps *set, return r; } -/* Encode and return a source_location starting from location LOC and +/* Encode and return a location_t starting from location LOC and shifting it by COLUMN_OFFSET columns. This function does not support virtual locations. */ -source_location +location_t linemap_position_for_loc_and_offset (struct line_maps *set, - source_location loc, + location_t loc, unsigned int column_offset) { const line_map_ordinary * map = NULL; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; /* This function does not support virtual locations yet. */ if (linemap_location_from_macro_expansion_p (set, loc)) @@ -913,7 +913,7 @@ linemap_position_for_loc_and_offset (struct line_maps *set, if (column >= (1u << (map->m_column_and_range_bits - map->m_range_bits))) return loc; - source_location r = + location_t r = linemap_position_for_line_and_column (set, map, line, column); if (linemap_assert_fails (r <= set->highest_location) || linemap_assert_fails (map == linemap_lookup (set, r))) @@ -926,10 +926,10 @@ linemap_position_for_loc_and_offset (struct line_maps *set, ordinary or a macro map), returns that map. */ const struct line_map* -linemap_lookup (struct line_maps *set, source_location line) +linemap_lookup (struct line_maps *set, location_t line) { if (IS_ADHOC_LOC (line)) - line = set->location_adhoc_data_map.data[line & MAX_SOURCE_LOCATION].locus; + line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus; if (linemap_location_from_macro_expansion_p (set, line)) return linemap_macro_map_lookup (set, line); return linemap_ordinary_map_lookup (set, line); @@ -941,13 +941,13 @@ linemap_lookup (struct line_maps *set, source_location line) binary search. */ static const line_map_ordinary * -linemap_ordinary_map_lookup (struct line_maps *set, source_location line) +linemap_ordinary_map_lookup (struct line_maps *set, location_t line) { unsigned int md, mn, mx; const line_map_ordinary *cached, *result; if (IS_ADHOC_LOC (line)) - line = set->location_adhoc_data_map.data[line & MAX_SOURCE_LOCATION].locus; + line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus; if (set == NULL || line < RESERVED_LOCATION_COUNT) return NULL; @@ -989,13 +989,13 @@ linemap_ordinary_map_lookup (struct line_maps *set, source_location line) binary search. */ static const line_map_macro * -linemap_macro_map_lookup (struct line_maps *set, source_location line) +linemap_macro_map_lookup (struct line_maps *set, location_t line) { unsigned int md, mn, mx; const struct line_map_macro *cached, *result; if (IS_ADHOC_LOC (line)) - line = set->location_adhoc_data_map.data[line & MAX_SOURCE_LOCATION].locus; + line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus; linemap_assert (line >= LINEMAPS_MACRO_LOWEST_LOCATION (set)); @@ -1045,9 +1045,9 @@ linemap_macro_expansion_map_p (const struct line_map *map) Read the comments of struct line_map and struct line_map_macro in line-map.h to understand what a macro expansion point is. */ -static source_location +static location_t linemap_macro_map_loc_to_exp_point (const line_map_macro *map, - source_location location ATTRIBUTE_UNUSED) + location_t location ATTRIBUTE_UNUSED) { linemap_assert (linemap_macro_expansion_map_p (map) && location >= MAP_START_LOCATION (map)); @@ -1065,9 +1065,9 @@ linemap_macro_map_loc_to_exp_point (const line_map_macro *map, Return the location of the token at the definition point of the macro. */ -static source_location +static location_t linemap_macro_map_loc_to_def_point (const line_map_macro *map, - source_location location) + location_t location) { unsigned token_no; @@ -1089,10 +1089,10 @@ linemap_macro_map_loc_to_def_point (const line_map_macro *map, In other words, this returns the xI location presented in the comments of line_map_macro above. */ -source_location +location_t linemap_macro_map_loc_unwind_toward_spelling (line_maps *set, const line_map_macro* map, - source_location location) + location_t location) { unsigned token_no; @@ -1120,13 +1120,13 @@ linemap_macro_map_loc_unwind_toward_spelling (line_maps *set, int linemap_get_expansion_line (struct line_maps *set, - source_location location) + location_t location) { const line_map_ordinary *map = NULL; if (IS_ADHOC_LOC (location)) location = set->location_adhoc_data_map.data[location - & MAX_SOURCE_LOCATION].locus; + & MAX_LOCATION_T].locus; if (location < RESERVED_LOCATION_COUNT) return 0; @@ -1148,13 +1148,13 @@ linemap_get_expansion_line (struct line_maps *set, const char* linemap_get_expansion_filename (struct line_maps *set, - source_location location) + location_t location) { const struct line_map_ordinary *map = NULL; if (IS_ADHOC_LOC (location)) location = set->location_adhoc_data_map.data[location - & MAX_SOURCE_LOCATION].locus; + & MAX_LOCATION_T].locus; if (location < RESERVED_LOCATION_COUNT) return NULL; @@ -1186,13 +1186,13 @@ linemap_map_get_macro_name (const line_map_macro *macro_map) int linemap_location_in_system_header_p (struct line_maps *set, - source_location location) + location_t location) { const struct line_map *map = NULL; if (IS_ADHOC_LOC (location)) location = set->location_adhoc_data_map.data[location - & MAX_SOURCE_LOCATION].locus; + & MAX_LOCATION_T].locus; if (location < RESERVED_LOCATION_COUNT) return false; @@ -1211,7 +1211,7 @@ linemap_location_in_system_header_p (struct line_maps *set, const line_map_macro *macro_map = linemap_check_macro (map); /* It's a token resulting from a macro expansion. */ - source_location loc = + location_t loc = linemap_macro_map_loc_unwind_toward_spelling (set, macro_map, location); if (loc < RESERVED_LOCATION_COUNT) /* This token might come from a built-in macro. Let's @@ -1232,11 +1232,11 @@ linemap_location_in_system_header_p (struct line_maps *set, bool linemap_location_from_macro_expansion_p (const struct line_maps *set, - source_location location) + location_t location) { if (IS_ADHOC_LOC (location)) location = set->location_adhoc_data_map.data[location - & MAX_SOURCE_LOCATION].locus; + & MAX_LOCATION_T].locus; return IS_MACRO_LOC (location); } @@ -1248,10 +1248,10 @@ linemap_location_from_macro_expansion_p (const struct line_maps *set, static const struct line_map* first_map_in_common_1 (struct line_maps *set, - source_location *loc0, - source_location *loc1) + location_t *loc0, + location_t *loc1) { - source_location l0 = *loc0, l1 = *loc1; + location_t l0 = *loc0, l1 = *loc1; const struct line_map *map0 = linemap_lookup (set, l0), *map1 = linemap_lookup (set, l1); @@ -1290,10 +1290,10 @@ first_map_in_common_1 (struct line_maps *set, static const struct line_map* first_map_in_common (struct line_maps *set, - source_location loc0, - source_location loc1, - source_location *res_loc0, - source_location *res_loc1) + location_t loc0, + location_t loc1, + location_t *res_loc0, + location_t *res_loc1) { *res_loc0 = loc0; *res_loc1 = loc1; @@ -1308,11 +1308,11 @@ first_map_in_common (struct line_maps *set, int linemap_compare_locations (struct line_maps *set, - source_location pre, - source_location post) + location_t pre, + location_t post) { bool pre_virtual_p, post_virtual_p; - source_location l0 = pre, l1 = post; + location_t l0 = pre, l1 = post; if (IS_ADHOC_LOC (l0)) l0 = get_location_from_adhoc_loc (set, l0); @@ -1378,9 +1378,9 @@ trace_include (const struct line_maps *set, const line_map_ordinary *map) This is a subroutine for linemap_resolve_location. */ -static source_location +static location_t linemap_macro_loc_to_spelling_point (struct line_maps *set, - source_location location, + location_t location, const line_map_ordinary **original_map) { linemap_assert (set && location >= RESERVED_LOCATION_COUNT); @@ -1412,16 +1412,16 @@ linemap_macro_loc_to_spelling_point (struct line_maps *set, This is a subroutine of linemap_resolve_location. */ -static source_location +static location_t linemap_macro_loc_to_def_point (struct line_maps *set, - source_location location, + location_t location, const line_map_ordinary **original_map) { linemap_assert (set && location >= RESERVED_LOCATION_COUNT); for (;;) { - source_location caret_loc = location; + location_t caret_loc = location; if (IS_ADHOC_LOC (caret_loc)) caret_loc = get_location_from_adhoc_loc (set, caret_loc); @@ -1454,16 +1454,16 @@ linemap_macro_loc_to_def_point (struct line_maps *set, This is a subroutine of linemap_resolve_location. */ -static source_location +static location_t linemap_macro_loc_to_exp_point (struct line_maps *set, - source_location location, + location_t location, const line_map_ordinary **original_map) { struct line_map *map; if (IS_ADHOC_LOC (location)) location = set->location_adhoc_data_map.data[location - & MAX_SOURCE_LOCATION].locus; + & MAX_LOCATION_T].locus; linemap_assert (set && location >= RESERVED_LOCATION_COUNT); @@ -1529,15 +1529,15 @@ linemap_macro_loc_to_exp_point (struct line_maps *set, resolves to a location reserved for the client code, like UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */ -source_location +location_t linemap_resolve_location (struct line_maps *set, - source_location loc, + location_t loc, enum location_resolution_kind lrk, const line_map_ordinary **map) { - source_location locus = loc; + location_t locus = loc; if (IS_ADHOC_LOC (loc)) - locus = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + locus = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; if (locus < RESERVED_LOCATION_COUNT) { @@ -1571,7 +1571,7 @@ linemap_resolve_location (struct line_maps *set, bool linemap_location_from_macro_definition_p (struct line_maps *set, - source_location loc) + location_t loc) { if (IS_ADHOC_LOC (loc)) loc = get_location_from_adhoc_loc (set, loc); @@ -1584,13 +1584,13 @@ linemap_location_from_macro_definition_p (struct line_maps *set, const struct line_map_macro *map = linemap_check_macro (linemap_lookup (set, loc)); - source_location s_loc + location_t s_loc = linemap_macro_map_loc_unwind_toward_spelling (set, map, loc); if (linemap_location_from_macro_expansion_p (set, s_loc)) loc = s_loc; else { - source_location def_loc + location_t def_loc = linemap_macro_map_loc_to_def_point (map, loc); return s_loc == def_loc; } @@ -1609,17 +1609,17 @@ linemap_location_from_macro_definition_p (struct line_maps *set, *LOC_MAP must be set to the map of LOC. This function then sets it to the map of the returned location. */ -source_location +location_t linemap_unwind_toward_expansion (struct line_maps *set, - source_location loc, + location_t loc, const struct line_map **map) { - source_location resolved_location; + location_t resolved_location; const line_map_macro *macro_map = linemap_check_macro (*map); const struct line_map *resolved_map; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; resolved_location = linemap_macro_map_loc_unwind_toward_spelling (set, macro_map, loc); @@ -1649,17 +1649,17 @@ linemap_unwind_toward_expansion (struct line_maps *set, *MAP is set to the map of the returned location if the later is different from LOC. */ -source_location +location_t linemap_unwind_to_first_non_reserved_loc (struct line_maps *set, - source_location loc, + location_t loc, const struct line_map **map) { - source_location resolved_loc; + location_t resolved_loc; const struct line_map *map0 = NULL; const line_map_ordinary *map1 = NULL; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; map0 = linemap_lookup (set, loc); if (!linemap_macro_expansion_map_p (map0)) @@ -1696,7 +1696,7 @@ linemap_unwind_to_first_non_reserved_loc (struct line_maps *set, expanded_location linemap_expand_location (struct line_maps *set, const struct line_map *map, - source_location loc) + location_t loc) { expanded_location xloc; @@ -1705,8 +1705,8 @@ linemap_expand_location (struct line_maps *set, if (IS_ADHOC_LOC (loc)) { xloc.data - = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].data; - loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data; + loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; } if (loc < RESERVED_LOCATION_COUNT) @@ -1801,16 +1801,16 @@ linemap_dump (FILE *stream, struct line_maps *set, unsigned ix, bool is_macro) void linemap_dump_location (struct line_maps *set, - source_location loc, + location_t loc, FILE *stream) { const line_map_ordinary *map; - source_location location; + location_t location; const char *path = "", *from = ""; int l = -1, c = -1, s = -1, e = -1; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus; + loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; if (loc == 0) return; @@ -1852,7 +1852,7 @@ linemap_dump_location (struct line_maps *set, bool linemap_get_file_highest_location (struct line_maps *set, const char *file_name, - source_location *loc) + location_t *loc) { /* If the set is empty or no ordinary map has been created then there is no file to look for ... */ @@ -1874,7 +1874,7 @@ linemap_get_file_highest_location (struct line_maps *set, /* The highest location for a given map is either the starting location of the next map minus one, or -- if the map is the latest one -- the highest location of the set. */ - source_location result; + location_t result; if (i == (int) set->info_ordinary.used - 1) result = set->highest_location; else @@ -1915,14 +1915,14 @@ linemap_get_statistics (struct line_maps *set, linemap_assert (linemap_macro_expansion_map_p (cur_map)); macro_maps_locations_size += - 2 * MACRO_MAP_NUM_MACRO_TOKENS (cur_map) * sizeof (source_location); + 2 * MACRO_MAP_NUM_MACRO_TOKENS (cur_map) * sizeof (location_t); for (i = 0; i < 2 * MACRO_MAP_NUM_MACRO_TOKENS (cur_map); i += 2) { if (MACRO_MAP_LOCATIONS (cur_map)[i] == MACRO_MAP_LOCATIONS (cur_map)[i + 1]) duplicated_macro_maps_locations_size += - sizeof (source_location); + sizeof (location_t); } } @@ -1989,7 +1989,7 @@ line_table_dump (FILE *stream, struct line_maps *set, unsigned int num_ordinary, /* Construct a rich_location with location LOC as its initial range. */ -rich_location::rich_location (line_maps *set, source_location loc, +rich_location::rich_location (line_maps *set, location_t loc, const range_label *label) : m_line_table (set), m_ranges (), @@ -2012,7 +2012,7 @@ rich_location::~rich_location () /* Get location IDX within this rich_location. */ -source_location +location_t rich_location::get_loc (unsigned int idx) const { const location_range *locrange = get_range (idx); @@ -2075,7 +2075,7 @@ rich_location::override_column (int column) /* Add the given range. */ void -rich_location::add_range (source_location loc, +rich_location::add_range (location_t loc, enum range_display_kind range_display_kind, const range_label *label) { @@ -2100,7 +2100,7 @@ rich_location::add_range (source_location loc, - the "%C" and "%L" format codes in the Fortran frontend. */ void -rich_location::set_range (unsigned int idx, source_location loc, +rich_location::set_range (unsigned int idx, location_t loc, enum range_display_kind range_display_kind) { /* We can either overwrite an existing range, or add one exactly @@ -2136,10 +2136,10 @@ rich_location::add_fixit_insert_before (const char *new_content) immediately before the start of WHERE. */ void -rich_location::add_fixit_insert_before (source_location where, +rich_location::add_fixit_insert_before (location_t where, const char *new_content) { - source_location start = get_range_from_loc (m_line_table, where).m_start; + location_t start = get_range_from_loc (m_line_table, where).m_start; maybe_add_fixit (start, start, new_content); } @@ -2156,11 +2156,11 @@ rich_location::add_fixit_insert_after (const char *new_content) immediately after the end-point of WHERE. */ void -rich_location::add_fixit_insert_after (source_location where, +rich_location::add_fixit_insert_after (location_t where, const char *new_content) { - source_location finish = get_range_from_loc (m_line_table, where).m_finish; - source_location next_loc + location_t finish = get_range_from_loc (m_line_table, where).m_finish; + location_t next_loc = linemap_position_for_loc_and_offset (m_line_table, finish, 1); /* linemap_position_for_loc_and_offset can fail, if so, it returns @@ -2189,7 +2189,7 @@ rich_location::add_fixit_remove () the start and finish of WHERE. */ void -rich_location::add_fixit_remove (source_location where) +rich_location::add_fixit_remove (location_t where) { source_range range = get_range_from_loc (m_line_table, where); add_fixit_remove (range); @@ -2219,7 +2219,7 @@ rich_location::add_fixit_replace (const char *new_content) the start and finish of WHERE with NEW_CONTENT. */ void -rich_location::add_fixit_replace (source_location where, +rich_location::add_fixit_replace (location_t where, const char *new_content) { source_range range = get_range_from_loc (m_line_table, where); @@ -2233,11 +2233,11 @@ void rich_location::add_fixit_replace (source_range src_range, const char *new_content) { - source_location start = get_pure_location (m_line_table, src_range.m_start); - source_location finish = get_pure_location (m_line_table, src_range.m_finish); + location_t start = get_pure_location (m_line_table, src_range.m_start); + location_t finish = get_pure_location (m_line_table, src_range.m_finish); /* Fix-it hints use half-closed ranges, so attempt to offset the endpoint. */ - source_location next_loc + location_t next_loc = linemap_position_for_loc_and_offset (m_line_table, finish, 1); /* linemap_position_for_loc_and_offset can fail, if so, it returns its input value. */ @@ -2268,7 +2268,7 @@ rich_location::get_last_fixit_hint () const Otherwise (the common case), return false. */ bool -rich_location::reject_impossible_fixit (source_location where) +rich_location::reject_impossible_fixit (location_t where) { /* Fix-its within a rich_location should either all be suggested, or none of them should be suggested. @@ -2306,8 +2306,8 @@ rich_location::stop_supporting_fixits () consolidating into the prior fixit if possible. */ void -rich_location::maybe_add_fixit (source_location start, - source_location next_loc, +rich_location::maybe_add_fixit (location_t start, + location_t next_loc, const char *new_content) { if (reject_impossible_fixit (start)) @@ -2388,8 +2388,8 @@ rich_location::maybe_add_fixit (source_location start, /* class fixit_hint. */ -fixit_hint::fixit_hint (source_location start, - source_location next_loc, +fixit_hint::fixit_hint (location_t start, + location_t next_loc, const char *new_content) : m_start (start), m_next_loc (next_loc), @@ -2427,8 +2427,8 @@ fixit_hint::affects_line_p (const char *file, int line) const Otherwise return false. */ bool -fixit_hint::maybe_append (source_location start, - source_location next_loc, +fixit_hint::maybe_append (location_t start, + location_t next_loc, const char *new_content) { /* For consolidation to be possible, START must be at this hint's diff --git a/libcpp/location-example.txt b/libcpp/location-example.txt index 14b5c2e..829ca53 100644 --- a/libcpp/location-example.txt +++ b/libcpp/location-example.txt @@ -20,17 +20,17 @@ extern int foo (); The undocumented -fdump-internal-locations option outputs this information -to stderr, showing what each source_location value means. Source code -lines are quoted, showing both per-line source_location values and -per-line&column source_location values (written vertically under the +to stderr, showing what each location_t value means. Source code +lines are quoted, showing both per-line location_t values and +per-line&column location_t values (written vertically under the corresponding character of source code). VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV RESERVED LOCATIONS - source_location interval: 0 <= loc < 2 + location_t interval: 0 <= loc < 2 ORDINARY MAP: 0 - source_location interval: 32 <= loc < 64 + location_t interval: 32 <= loc < 64 file: test.c starting at line: 1 column bits: 12 @@ -40,21 +40,21 @@ test.c: 1|loc: 32|#include "test.h" |46802468024680246 ORDINARY MAP: 1 - source_location interval: 64 <= loc < 96 + location_t interval: 64 <= loc < 96 file: <built-in> starting at line: 0 column bits: 0 range bits: 0 ORDINARY MAP: 2 - source_location interval: 96 <= loc < 128 + location_t interval: 96 <= loc < 128 file: <command-line> starting at line: 0 column bits: 0 range bits: 0 ORDINARY MAP: 3 - source_location interval: 128 <= loc < 160128 + location_t interval: 128 <= loc < 160128 file: /usr/include/stdc-predef.h starting at line: 1 column bits: 12 @@ -62,14 +62,14 @@ ORDINARY MAP: 3 (contents of /usr/include/stdc-predef.h snipped for brevity) ORDINARY MAP: 4 - source_location interval: 160128 <= loc < 160160 + location_t interval: 160128 <= loc < 160160 file: <command-line> starting at line: 32 column bits: 12 range bits: 5 ORDINARY MAP: 5 - source_location interval: 160160 <= loc < 164256 + location_t interval: 160160 <= loc < 164256 file: test.c starting at line: 1 column bits: 12 @@ -81,7 +81,7 @@ test.c: 1|loc:160160|#include "test.h" |24680246802468024 ORDINARY MAP: 6 - source_location interval: 164256 <= loc < 173280 + location_t interval: 164256 <= loc < 173280 file: test.h starting at line: 1 column bits: 12 @@ -103,7 +103,7 @@ test.h: 3|loc:172448|#define PLUS(A, B) A + B |024680246802468024680246 ORDINARY MAP: 7 - source_location interval: 173280 <= loc < 202016 + location_t interval: 173280 <= loc < 202016 file: test.c starting at line: 2 column bits: 12 @@ -150,10 +150,10 @@ test.c: 9|loc:201952|} |4 UNALLOCATED LOCATIONS - source_location interval: 202016 <= loc < 2147483633 + location_t interval: 202016 <= loc < 2147483633 MACRO 1: PLUS (7 tokens) - source_location interval: 2147483633 <= loc < 2147483640 + location_t interval: 2147483633 <= loc < 2147483640 test.c:7:11: note: expansion point is location 194115 int b = PLUS (3,4); ^~~~ @@ -189,7 +189,7 @@ x-location == y-location == 2947526575 encodes token # 800042942 x-location == y-location == 2947526575 encodes token # 800042942 MACRO 0: PLUS (7 tokens) - source_location interval: 2147483640 <= loc < 2147483647 + location_t interval: 2147483640 <= loc < 2147483647 test.c:6:11: note: expansion point is location 190019 int a = PLUS (1,2); ^~~~ @@ -224,9 +224,9 @@ x-location == y-location == 2947526575 encodes token # 800042935 6: 2947526575, 2947526575 x-location == y-location == 2947526575 encodes token # 800042935 -MAX_SOURCE_LOCATION - source_location interval: 2147483647 <= loc < 2147483648 +MAX_LOCATION_T + location_t interval: 2147483647 <= loc < 2147483648 AD-HOC LOCATIONS - source_location interval: 2147483648 <= loc < 4294967295 + location_t interval: 2147483648 <= loc < 4294967295 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/libcpp/macro.c b/libcpp/macro.c index bb3d958..3cbf24e 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -39,9 +39,9 @@ struct macro_arg const cpp_token *stringified; /* Stringified argument. */ unsigned int count; /* # of tokens in argument. */ unsigned int expanded_count; /* # of tokens in expanded argument. */ - source_location *virt_locs; /* Where virtual locations for + location_t *virt_locs; /* Where virtual locations for unexpanded tokens are stored. */ - source_location *expanded_virt_locs; /* Where virtual locations for + location_t *expanded_virt_locs; /* Where virtual locations for expanded tokens are stored. */ }; @@ -72,7 +72,7 @@ struct macro_arg_token_iter /* A pointer to the "full" location of the current token. If -ftrack-macro-expansion is used this location tracks loci across macro expansion. */ - const source_location *location_ptr; + const location_t *location_ptr; #if CHECKING_P /* The number of times the iterator went forward. This useful only when checking is enabled. */ @@ -235,22 +235,22 @@ class vaopt_state { int m_state; /* The location of the paste token. */ - source_location m_paste_location; + location_t m_paste_location; /* Location of the __VA_OPT__ token. */ - source_location m_location; + location_t m_location; }; /* Macro expansion. */ static int enter_macro_context (cpp_reader *, cpp_hashnode *, - const cpp_token *, source_location); + const cpp_token *, location_t); static int builtin_macro (cpp_reader *, cpp_hashnode *, - source_location, source_location); + location_t, location_t); static void push_ptoken_context (cpp_reader *, cpp_hashnode *, _cpp_buff *, const cpp_token **, unsigned int); static void push_extended_tokens_context (cpp_reader *, cpp_hashnode *, - _cpp_buff *, source_location *, + _cpp_buff *, location_t *, const cpp_token **, unsigned int); static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *, _cpp_buff **, unsigned *); @@ -260,21 +260,21 @@ static void expand_arg (cpp_reader *, macro_arg *); static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int); static const cpp_token *stringify_arg (cpp_reader *, macro_arg *); static void paste_all_tokens (cpp_reader *, const cpp_token *); -static bool paste_tokens (cpp_reader *, source_location, +static bool paste_tokens (cpp_reader *, location_t, const cpp_token **, const cpp_token *); static void alloc_expanded_arg_mem (cpp_reader *, macro_arg *, size_t); static void ensure_expanded_arg_room (cpp_reader *, macro_arg *, size_t, size_t *); static void delete_macro_args (_cpp_buff*, unsigned num_args); static void set_arg_token (macro_arg *, const cpp_token *, - source_location, size_t, + location_t, size_t, enum macro_arg_token_kind, bool); -static const source_location *get_arg_token_location (const macro_arg *, +static const location_t *get_arg_token_location (const macro_arg *, enum macro_arg_token_kind); static const cpp_token **arg_token_ptr_at (const macro_arg *, size_t, enum macro_arg_token_kind, - source_location **virt_location); + location_t **virt_location); static void macro_arg_token_iter_init (macro_arg_token_iter *, bool, enum macro_arg_token_kind, @@ -282,31 +282,31 @@ static void macro_arg_token_iter_init (macro_arg_token_iter *, bool, const cpp_token **); static const cpp_token *macro_arg_token_iter_get_token (const macro_arg_token_iter *it); -static source_location macro_arg_token_iter_get_location +static location_t macro_arg_token_iter_get_location (const macro_arg_token_iter *); static void macro_arg_token_iter_forward (macro_arg_token_iter *); static _cpp_buff *tokens_buff_new (cpp_reader *, size_t, - source_location **); + location_t **); static size_t tokens_buff_count (_cpp_buff *); static const cpp_token **tokens_buff_last_token_ptr (_cpp_buff *); static inline const cpp_token **tokens_buff_put_token_to (const cpp_token **, - source_location *, + location_t *, const cpp_token *, - source_location, - source_location, + location_t, + location_t, const line_map_macro *, unsigned int); static const cpp_token **tokens_buff_add_token (_cpp_buff *, - source_location *, + location_t *, const cpp_token *, - source_location, - source_location, + location_t, + location_t, const line_map_macro *, unsigned int); static inline void tokens_buff_remove_last_token (_cpp_buff *); static void replace_args (cpp_reader *, cpp_hashnode *, cpp_macro *, - macro_arg *, source_location); + macro_arg *, location_t); static _cpp_buff *funlike_invocation_p (cpp_reader *, cpp_hashnode *, _cpp_buff **, unsigned *); static cpp_macro *create_iso_definition (cpp_reader *); @@ -322,8 +322,8 @@ static void check_trad_stringification (cpp_reader *, const cpp_macro *, static bool reached_end_of_context (cpp_context *); static void consume_next_token_from_context (cpp_reader *pfile, const cpp_token **, - source_location *); -static const cpp_token* cpp_get_token_1 (cpp_reader *, source_location *); + location_t *); +static const cpp_token* cpp_get_token_1 (cpp_reader *, location_t *); static cpp_hashnode* macro_of_context (cpp_context *context); @@ -382,7 +382,7 @@ static const char * const monthnames[] = a builtin macro. */ const uchar * _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node, - source_location loc) + location_t loc) { const uchar *result = NULL; linenum_type number = 1; @@ -587,7 +587,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node, point of the macro. */ static int builtin_macro (cpp_reader *pfile, cpp_hashnode *node, - source_location loc, source_location expand_loc) + location_t loc, location_t expand_loc) { const uchar *buf; size_t len; @@ -623,7 +623,7 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node, Create a macro line map and generate a virtual location for the token resulting from the expansion of the built-in macro. */ - source_location *virt_locs = NULL; + location_t *virt_locs = NULL; _cpp_buff *token_buf = tokens_buff_new (pfile, 1, &virt_locs); const line_map_macro * map = linemap_enter_macro (pfile->line_table, node, loc, 1); @@ -773,7 +773,7 @@ stringify_arg (cpp_reader *pfile, macro_arg *arg) guaranteed to not have the PASTE_LEFT flag set. LOCATION is the virtual location used for error reporting. */ static bool -paste_tokens (cpp_reader *pfile, source_location location, +paste_tokens (cpp_reader *pfile, location_t location, const cpp_token **plhs, const cpp_token *rhs) { unsigned char *buf, *end, *lhsend; @@ -803,7 +803,7 @@ paste_tokens (cpp_reader *pfile, source_location location, lhs = _cpp_lex_direct (pfile); if (pfile->buffer->cur != pfile->buffer->rlimit) { - source_location saved_loc = lhs->src_loc; + location_t saved_loc = lhs->src_loc; _cpp_pop_buffer (pfile); _cpp_backup_tokens (pfile, 1); @@ -841,7 +841,7 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs) { const cpp_token *rhs = NULL; cpp_context *context = pfile->context; - source_location virt_loc = 0; + location_t virt_loc = 0; /* We are expanding a macro and we must have been called on a token that appears at the left hand side of a ## operator. */ @@ -903,7 +903,7 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs) /* Put the resulting token in its own context. */ if (context->tokens_kind == TOKENS_KIND_EXTENDED) { - source_location *virt_locs = NULL; + location_t *virt_locs = NULL; _cpp_buff *token_buf = tokens_buff_new (pfile, 1, &virt_locs); tokens_buff_add_token (token_buf, virt_locs, lhs, virt_loc, 0, NULL, 0); @@ -993,7 +993,7 @@ collect_args (cpp_reader *pfile, const cpp_hashnode *node, macro_arg *args, *arg; const cpp_token *token; unsigned int argc; - source_location virt_loc; + location_t virt_loc; bool track_macro_expansion_p = CPP_OPTION (pfile, track_macro_expansion); unsigned num_args_alloced = 0; @@ -1030,7 +1030,7 @@ collect_args (cpp_reader *pfile, const cpp_hashnode *node, if (track_macro_expansion_p) { virt_locs_capacity = DEFAULT_NUM_TOKENS_PER_MACRO_ARG; - arg->virt_locs = XNEWVEC (source_location, + arg->virt_locs = XNEWVEC (location_t, virt_locs_capacity); } @@ -1048,7 +1048,7 @@ collect_args (cpp_reader *pfile, const cpp_hashnode *node, && (ntokens + 2 > virt_locs_capacity)) { virt_locs_capacity += ARG_TOKENS_EXTENT; - arg->virt_locs = XRESIZEVEC (source_location, + arg->virt_locs = XRESIZEVEC (location_t, arg->virt_locs, virt_locs_capacity); } @@ -1260,7 +1260,7 @@ macro_real_token_count (const cpp_macro *macro) macro. */ static int enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, - const cpp_token *result, source_location location) + const cpp_token *result, location_t location) { /* The presence of a macro invalidates a file's controlling macro. */ pfile->mi_valid = false; @@ -1340,7 +1340,7 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, unsigned int i; const cpp_token *src = macro->exp.tokens; const line_map_macro *map; - source_location *virt_locs = NULL; + location_t *virt_locs = NULL; _cpp_buff *macro_tokens = tokens_buff_new (pfile, tokens_count, &virt_locs); @@ -1401,7 +1401,7 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, pfile->about_to_expand_macro_p = false; /* Handle built-in macros and the _Pragma operator. */ { - source_location expand_loc; + location_t expand_loc; if (/* The top-level macro invocation that triggered the expansion we are looking at is with a function-like user macro ... */ @@ -1467,12 +1467,12 @@ delete_macro_args (_cpp_buff *buff, unsigned num_args) tokens, at least. */ static void set_arg_token (macro_arg *arg, const cpp_token *token, - source_location location, size_t index, + location_t location, size_t index, enum macro_arg_token_kind kind, bool track_macro_exp_p) { const cpp_token **token_ptr; - source_location *loc = NULL; + location_t *loc = NULL; token_ptr = arg_token_ptr_at (arg, index, kind, @@ -1493,13 +1493,13 @@ set_arg_token (macro_arg *arg, const cpp_token *token, /* Get the pointer to the location of the argument token of the function-like macro argument ARG. This function must be called only when we -ftrack-macro-expansion is on. */ -static const source_location * +static const location_t * get_arg_token_location (const macro_arg *arg, enum macro_arg_token_kind kind) { - const source_location *loc = NULL; + const location_t *loc = NULL; const cpp_token **token_ptr = - arg_token_ptr_at (arg, 0, kind, (source_location **) &loc); + arg_token_ptr_at (arg, 0, kind, (location_t **) &loc); if (token_ptr == NULL) return NULL; @@ -1516,7 +1516,7 @@ get_arg_token_location (const macro_arg *arg, static const cpp_token ** arg_token_ptr_at (const macro_arg *arg, size_t index, enum macro_arg_token_kind kind, - source_location **virt_location) + location_t **virt_location) { const cpp_token **tokens_ptr = NULL; @@ -1546,7 +1546,7 @@ arg_token_ptr_at (const macro_arg *arg, size_t index, *virt_location = &arg->expanded_virt_locs[index]; else if (kind == MACRO_ARG_TOKEN_STRINGIFIED) *virt_location = - (source_location *) &tokens_ptr[index]->src_loc; + (location_t *) &tokens_ptr[index]->src_loc; } return &tokens_ptr[index]; } @@ -1623,7 +1623,7 @@ macro_arg_token_iter_get_token (const macro_arg_token_iter *it) } /* Return the location of the token pointed to by the iterator.*/ -static source_location +static location_t macro_arg_token_iter_get_location (const macro_arg_token_iter *it) { #if CHECKING_P @@ -1720,14 +1720,14 @@ last_token_is (_cpp_buff *buff, const cpp_token **ptr) function-like macro invocation. */ static void replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, - macro_arg *args, source_location expansion_point_loc) + macro_arg *args, location_t expansion_point_loc) { unsigned int i, total; const cpp_token *src, *limit; const cpp_token **first = NULL; macro_arg *arg; _cpp_buff *buff = NULL; - source_location *virt_locs = NULL; + location_t *virt_locs = NULL; unsigned int exp_count; const line_map_macro *map = NULL; int track_macro_exp; @@ -1797,7 +1797,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, As far as tokens are concerned, the memory overhead of -ftrack-macro-expansion is proportional to the number of - macros that get expanded multiplied by sizeof (source_location). + macros that get expanded multiplied by sizeof (location_t). The good news is that extra memory gets freed when the macro context is freed, i.e shortly after the macro got expanded. */ @@ -2216,7 +2216,7 @@ static void push_extended_tokens_context (cpp_reader *pfile, cpp_hashnode *macro, _cpp_buff *token_buff, - source_location *virt_locs, + location_t *virt_locs, const cpp_token **first, unsigned int count) { @@ -2262,13 +2262,13 @@ _cpp_push_text_context (cpp_reader *pfile, cpp_hashnode *macro, expansion. */ static _cpp_buff* tokens_buff_new (cpp_reader *pfile, size_t len, - source_location **virt_locs) + location_t **virt_locs) { size_t tokens_size = len * sizeof (cpp_token *); - size_t locs_size = len * sizeof (source_location); + size_t locs_size = len * sizeof (location_t); if (virt_locs != NULL) - *virt_locs = XNEWVEC (source_location, locs_size); + *virt_locs = XNEWVEC (location_t, locs_size); return _cpp_get_buff (pfile, tokens_size); } @@ -2325,14 +2325,14 @@ tokens_buff_remove_last_token (_cpp_buff *tokens_buff) point. */ static inline const cpp_token ** tokens_buff_put_token_to (const cpp_token **dest, - source_location *virt_loc_dest, + location_t *virt_loc_dest, const cpp_token *token, - source_location virt_loc, - source_location parm_def_loc, + location_t virt_loc, + location_t parm_def_loc, const line_map_macro *map, unsigned int macro_token_index) { - source_location macro_loc = virt_loc; + location_t macro_loc = virt_loc; const cpp_token **result; if (virt_loc_dest) @@ -2370,15 +2370,15 @@ tokens_buff_put_token_to (const cpp_token **dest, position of the token coming right after the insertion point. */ static const cpp_token ** tokens_buff_add_token (_cpp_buff *buffer, - source_location *virt_locs, + location_t *virt_locs, const cpp_token *token, - source_location virt_loc, - source_location parm_def_loc, + location_t virt_loc, + location_t parm_def_loc, const line_map_macro *map, unsigned int macro_token_index) { const cpp_token **result; - source_location *virt_loc_dest = NULL; + location_t *virt_loc_dest = NULL; unsigned token_index = (BUFF_FRONT (buffer) - buffer->base) / sizeof (cpp_token *); @@ -2410,7 +2410,7 @@ alloc_expanded_arg_mem (cpp_reader *pfile, macro_arg *arg, size_t capacity) arg->expanded = XNEWVEC (const cpp_token *, capacity); if (CPP_OPTION (pfile, track_macro_expansion)) - arg->expanded_virt_locs = XNEWVEC (source_location, capacity); + arg->expanded_virt_locs = XNEWVEC (location_t, capacity); } @@ -2432,9 +2432,9 @@ ensure_expanded_arg_room (cpp_reader *pfile, macro_arg *arg, if (CPP_OPTION (pfile, track_macro_expansion)) { if (arg->expanded_virt_locs == NULL) - arg->expanded_virt_locs = XNEWVEC (source_location, size); + arg->expanded_virt_locs = XNEWVEC (location_t, size); else - arg->expanded_virt_locs = XRESIZEVEC (source_location, + arg->expanded_virt_locs = XRESIZEVEC (location_t, arg->expanded_virt_locs, size); } @@ -2477,7 +2477,7 @@ expand_arg (cpp_reader *pfile, macro_arg *arg) for (;;) { const cpp_token *token; - source_location location; + location_t location; ensure_expanded_arg_room (pfile, arg, arg->expanded_count + 1, &capacity); @@ -2616,7 +2616,7 @@ reached_end_of_context (cpp_context *context) static inline void consume_next_token_from_context (cpp_reader *pfile, const cpp_token ** token, - source_location *location) + location_t *location) { cpp_context *c = pfile->context; @@ -2655,8 +2655,8 @@ consume_next_token_from_context (cpp_reader *pfile, location if we are in the traditional mode, and just returns LOCATION otherwise. */ -static inline source_location -maybe_adjust_loc_for_trad_cpp (cpp_reader *pfile, source_location location) +static inline location_t +maybe_adjust_loc_for_trad_cpp (cpp_reader *pfile, location_t location) { if (CPP_OPTION (pfile, traditional)) { @@ -2681,12 +2681,12 @@ maybe_adjust_loc_for_trad_cpp (cpp_reader *pfile, source_location location) cpp_get_token_with_location to learn more about the meaning of this location. */ static const cpp_token* -cpp_get_token_1 (cpp_reader *pfile, source_location *location) +cpp_get_token_1 (cpp_reader *pfile, location_t *location) { const cpp_token *result; /* This token is a virtual token that either encodes a location related to macro expansion or a spelling location. */ - source_location virt_loc = 0; + location_t virt_loc = 0; /* pfile->about_to_expand_macro_p can be overriden by indirect calls to functions that push macro contexts. So let's save it so that we can restore it when we are about to leave this routine. */ @@ -2884,7 +2884,7 @@ cpp_get_token (cpp_reader *pfile) location is just the same thing as its spelling location. */ const cpp_token * -cpp_get_token_with_location (cpp_reader *pfile, source_location *loc) +cpp_get_token_with_location (cpp_reader *pfile, location_t *loc) { return cpp_get_token_1 (pfile, loc); } diff --git a/libcpp/pch.c b/libcpp/pch.c index 04d7094..fb6c12a 100644 --- a/libcpp/pch.c +++ b/libcpp/pch.c @@ -437,7 +437,7 @@ _cpp_restore_pushed_macros (cpp_reader *r, FILE *f) return 0; p->definition = defn; - if (fread (&(p->line), sizeof (source_location), 1, f) != 1) + if (fread (&(p->line), sizeof (location_t), 1, f) != 1) return 0; defnlen = 0; if (fread (&defnlen, sizeof (defnlen), 1, f) != 1) @@ -501,7 +501,7 @@ _cpp_save_pushed_macros (cpp_reader *r, FILE *f) if (fwrite (&defnlen, sizeof (size_t), 1, f) != 1 || fwrite (pp[i]->definition, defnlen, 1, f) != 1) return 0; - if (fwrite (&(pp[i]->line), sizeof (source_location), 1, f) != 1) + if (fwrite (&(pp[i]->line), sizeof (location_t), 1, f) != 1) return 0; defnlen = 0; defnlen |= (pp[i]->syshdr != 0 ? 1 : 0); diff --git a/libcpp/traditional.c b/libcpp/traditional.c index 51c3e35..a538337 100644 --- a/libcpp/traditional.c +++ b/libcpp/traditional.c @@ -60,7 +60,7 @@ struct fun_macro size_t offset; /* The line the macro name appeared on. */ - source_location line; + location_t line; /* Number of parameters. */ unsigned int paramc; @@ -161,7 +161,7 @@ static const uchar * copy_comment (cpp_reader *pfile, const uchar *cur, int in_define) { bool unterminated, copy = false; - source_location src_loc = pfile->line_table->highest_line; + location_t src_loc = pfile->line_table->highest_line; cpp_buffer *buffer = pfile->buffer; buffer->cur = cur; |