Mercurial > hg > CbC > CbC_gcc
comparison libcpp/internal.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Part of CPP library. | 1 /* Part of CPP library. |
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, | 2 Copyright (C) 1997-2017 Free Software Foundation, Inc. |
3 2008, 2009, 2010 Free Software Foundation, Inc. | |
4 | 3 |
5 This program is free software; you can redistribute it and/or modify it | 4 This program is free software; you can redistribute it and/or modify it |
6 under the terms of the GNU General Public License as published by the | 5 under the terms of the GNU General Public License as published by the |
7 Free Software Foundation; either version 3, or (at your option) any | 6 Free Software Foundation; either version 3, or (at your option) any |
8 later version. | 7 later version. |
58 (((c) == '+' || (c) == '-') && \ | 57 (((c) == '+' || (c) == '-') && \ |
59 ((prevc) == 'e' || (prevc) == 'E' \ | 58 ((prevc) == 'e' || (prevc) == 'E' \ |
60 || (((prevc) == 'p' || (prevc) == 'P') \ | 59 || (((prevc) == 'p' || (prevc) == 'P') \ |
61 && CPP_OPTION (pfile, extended_numbers)))) | 60 && CPP_OPTION (pfile, extended_numbers)))) |
62 | 61 |
62 #define DIGIT_SEP(c) ((c) == '\'' && CPP_OPTION (pfile, digit_separators)) | |
63 | |
63 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION) | 64 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION) |
64 #define CPP_BUFFER(PFILE) ((PFILE)->buffer) | 65 #define CPP_BUFFER(PFILE) ((PFILE)->buffer) |
65 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base) | 66 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base) |
66 #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur) | 67 #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur) |
67 | 68 |
68 #define CPP_INCREMENT_LINE(PFILE, COLS_HINT) do { \ | 69 #define CPP_INCREMENT_LINE(PFILE, COLS_HINT) do { \ |
69 const struct line_maps *line_table = PFILE->line_table; \ | 70 const struct line_maps *line_table = PFILE->line_table; \ |
70 const struct line_map *map = &line_table->maps[line_table->used-1]; \ | 71 const struct line_map_ordinary *map = \ |
72 LINEMAPS_LAST_ORDINARY_MAP (line_table); \ | |
71 linenum_type line = SOURCE_LINE (map, line_table->highest_line); \ | 73 linenum_type line = SOURCE_LINE (map, line_table->highest_line); \ |
72 linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \ | 74 linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \ |
73 } while (0) | 75 } while (0) |
74 | 76 |
75 /* Maximum nesting of cpp_buffers. We use a static limit, partly for | 77 /* Maximum nesting of cpp_buffers. We use a static limit, partly for |
114 #define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur) | 116 #define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur) |
115 #define BUFF_FRONT(BUFF) ((BUFF)->cur) | 117 #define BUFF_FRONT(BUFF) ((BUFF)->cur) |
116 #define BUFF_LIMIT(BUFF) ((BUFF)->limit) | 118 #define BUFF_LIMIT(BUFF) ((BUFF)->limit) |
117 | 119 |
118 /* #include types. */ | 120 /* #include types. */ |
119 enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE}; | 121 enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE, IT_DEFAULT}; |
120 | 122 |
121 union utoken | 123 union utoken |
122 { | 124 { |
123 const cpp_token *token; | 125 const cpp_token *token; |
124 const cpp_token **ptoken; | 126 const cpp_token **ptoken; |
135 /* Accessor macros for struct cpp_context. */ | 137 /* Accessor macros for struct cpp_context. */ |
136 #define FIRST(c) ((c)->u.iso.first) | 138 #define FIRST(c) ((c)->u.iso.first) |
137 #define LAST(c) ((c)->u.iso.last) | 139 #define LAST(c) ((c)->u.iso.last) |
138 #define CUR(c) ((c)->u.trad.cur) | 140 #define CUR(c) ((c)->u.trad.cur) |
139 #define RLIMIT(c) ((c)->u.trad.rlimit) | 141 #define RLIMIT(c) ((c)->u.trad.rlimit) |
142 | |
143 /* This describes some additional data that is added to the macro | |
144 token context of type cpp_context, when -ftrack-macro-expansion is | |
145 on. */ | |
146 typedef struct | |
147 { | |
148 /* The node of the macro we are referring to. */ | |
149 cpp_hashnode *macro_node; | |
150 /* This buffer contains an array of virtual locations. The virtual | |
151 location at index 0 is the virtual location of the token at index | |
152 0 in the current instance of cpp_context; similarly for all the | |
153 other virtual locations. */ | |
154 source_location *virt_locs; | |
155 /* This is a pointer to the current virtual location. This is used | |
156 to iterate over the virtual locations while we iterate over the | |
157 tokens they belong to. */ | |
158 source_location *cur_virt_loc; | |
159 } macro_context; | |
160 | |
161 /* The kind of tokens carried by a cpp_context. */ | |
162 enum context_tokens_kind { | |
163 /* This is the value of cpp_context::tokens_kind if u.iso.first | |
164 contains an instance of cpp_token **. */ | |
165 TOKENS_KIND_INDIRECT, | |
166 /* This is the value of cpp_context::tokens_kind if u.iso.first | |
167 contains an instance of cpp_token *. */ | |
168 TOKENS_KIND_DIRECT, | |
169 /* This is the value of cpp_context::tokens_kind when the token | |
170 context contains tokens resulting from macro expansion. In that | |
171 case struct cpp_context::macro points to an instance of struct | |
172 macro_context. This is used only when the | |
173 -ftrack-macro-expansion flag is on. */ | |
174 TOKENS_KIND_EXTENDED | |
175 }; | |
140 | 176 |
141 typedef struct cpp_context cpp_context; | 177 typedef struct cpp_context cpp_context; |
142 struct cpp_context | 178 struct cpp_context |
143 { | 179 { |
144 /* Doubly-linked list. */ | 180 /* Doubly-linked list. */ |
165 | 201 |
166 /* If non-NULL, a buffer used for storage related to this context. | 202 /* If non-NULL, a buffer used for storage related to this context. |
167 When the context is popped, the buffer is released. */ | 203 When the context is popped, the buffer is released. */ |
168 _cpp_buff *buff; | 204 _cpp_buff *buff; |
169 | 205 |
170 /* For a macro context, the macro node, otherwise NULL. */ | 206 /* If tokens_kind is TOKEN_KIND_EXTENDED, then (as we thus are in a |
171 cpp_hashnode *macro; | 207 macro context) this is a pointer to an instance of macro_context. |
172 | 208 Otherwise if tokens_kind is *not* TOKEN_KIND_EXTENDED, then, if |
173 /* True if utoken element is token, else ptoken. */ | 209 we are in a macro context, this is a pointer to an instance of |
174 bool direct_p; | 210 cpp_hashnode, representing the name of the macro this context is |
211 for. If we are not in a macro context, then this is just NULL. | |
212 Note that when tokens_kind is TOKEN_KIND_EXTENDED, the memory | |
213 used by the instance of macro_context pointed to by this member | |
214 is de-allocated upon de-allocation of the instance of struct | |
215 cpp_context. */ | |
216 union | |
217 { | |
218 macro_context *mc; | |
219 cpp_hashnode *macro; | |
220 } c; | |
221 | |
222 /* This determines the type of tokens held by this context. */ | |
223 enum context_tokens_kind tokens_kind; | |
175 }; | 224 }; |
176 | 225 |
177 struct lexer_state | 226 struct lexer_state |
178 { | 227 { |
179 /* Nonzero if first token on line is CPP_HASH. */ | 228 /* Nonzero if first token on line is CPP_HASH. */ |
207 unsigned char prevent_expansion; | 256 unsigned char prevent_expansion; |
208 | 257 |
209 /* Nonzero when parsing arguments to a function-like macro. */ | 258 /* Nonzero when parsing arguments to a function-like macro. */ |
210 unsigned char parsing_args; | 259 unsigned char parsing_args; |
211 | 260 |
261 /* Nonzero if in a __has_include__ or __has_include_next__ statement. */ | |
262 unsigned char in__has_include__; | |
263 | |
212 /* Nonzero if prevent_expansion is true only because output is | 264 /* Nonzero if prevent_expansion is true only because output is |
213 being discarded. */ | 265 being discarded. */ |
214 unsigned char discarding_output; | 266 unsigned char discarding_output; |
215 | 267 |
216 /* Nonzero to skip evaluating part of an expression. */ | 268 /* Nonzero to skip evaluating part of an expression. */ |
228 { | 280 { |
229 cpp_hashnode *n_defined; /* defined operator */ | 281 cpp_hashnode *n_defined; /* defined operator */ |
230 cpp_hashnode *n_true; /* C++ keyword true */ | 282 cpp_hashnode *n_true; /* C++ keyword true */ |
231 cpp_hashnode *n_false; /* C++ keyword false */ | 283 cpp_hashnode *n_false; /* C++ keyword false */ |
232 cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */ | 284 cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */ |
285 cpp_hashnode *n__has_include__; /* __has_include__ operator */ | |
286 cpp_hashnode *n__has_include_next__; /* __has_include_next__ operator */ | |
233 }; | 287 }; |
234 | 288 |
235 typedef struct _cpp_line_note _cpp_line_note; | 289 typedef struct _cpp_line_note _cpp_line_note; |
236 struct _cpp_line_note | 290 struct _cpp_line_note |
237 { | 291 { |
252 const unsigned char *line_base; /* Start of current physical line. */ | 306 const unsigned char *line_base; /* Start of current physical line. */ |
253 const unsigned char *next_line; /* Start of to-be-cleaned logical line. */ | 307 const unsigned char *next_line; /* Start of to-be-cleaned logical line. */ |
254 | 308 |
255 const unsigned char *buf; /* Entire character buffer. */ | 309 const unsigned char *buf; /* Entire character buffer. */ |
256 const unsigned char *rlimit; /* Writable byte at end of file. */ | 310 const unsigned char *rlimit; /* Writable byte at end of file. */ |
311 const unsigned char *to_free; /* Pointer that should be freed when | |
312 popping the buffer. */ | |
257 | 313 |
258 _cpp_line_note *notes; /* Array of notes. */ | 314 _cpp_line_note *notes; /* Array of notes. */ |
259 unsigned int cur_note; /* Next note to process. */ | 315 unsigned int cur_note; /* Next note to process. */ |
260 unsigned int notes_used; /* Number of notes. */ | 316 unsigned int notes_used; /* Number of notes. */ |
261 unsigned int notes_cap; /* Size of allocated array. */ | 317 unsigned int notes_cap; /* Size of allocated array. */ |
363 | 419 |
364 /* When expanding a macro at top-level, this is the location of the | 420 /* When expanding a macro at top-level, this is the location of the |
365 macro invocation. */ | 421 macro invocation. */ |
366 source_location invocation_location; | 422 source_location invocation_location; |
367 | 423 |
368 /* True if this call to cpp_get_token should consider setting | 424 /* This is the node representing the macro being expanded at |
369 invocation_location. */ | 425 top-level. The value of this data member is valid iff |
370 bool set_invocation_location; | 426 in_macro_expansion_p() returns TRUE. */ |
427 cpp_hashnode *top_most_macro_node; | |
428 | |
429 /* Nonzero if we are about to expand a macro. Note that if we are | |
430 really expanding a macro, the function macro_of_context returns | |
431 the macro being expanded and this flag is set to false. Client | |
432 code should use the function in_macro_expansion_p to know if we | |
433 are either about to expand a macro, or are actually expanding | |
434 one. */ | |
435 bool about_to_expand_macro_p; | |
371 | 436 |
372 /* Search paths for include files. */ | 437 /* Search paths for include files. */ |
373 struct cpp_dir *quote_include; /* "" */ | 438 struct cpp_dir *quote_include; /* "" */ |
374 struct cpp_dir *bracket_include; /* <> */ | 439 struct cpp_dir *bracket_include; /* <> */ |
375 struct cpp_dir no_search_path; /* No path. */ | 440 struct cpp_dir no_search_path; /* No path. */ |
434 struct cset_converter wide_cset_desc; | 499 struct cset_converter wide_cset_desc; |
435 | 500 |
436 /* Date and time text. Calculated together if either is requested. */ | 501 /* Date and time text. Calculated together if either is requested. */ |
437 const unsigned char *date; | 502 const unsigned char *date; |
438 const unsigned char *time; | 503 const unsigned char *time; |
504 | |
505 /* Externally set timestamp to replace current date and time useful for | |
506 reproducibility. It should be initialized to -2 (not yet set) and | |
507 set to -1 to disable it or to a non-negative value to enable it. */ | |
508 time_t source_date_epoch; | |
439 | 509 |
440 /* EOF token, and a token forcing paste avoidance. */ | 510 /* EOF token, and a token forcing paste avoidance. */ |
441 cpp_token avoid_paste; | 511 cpp_token avoid_paste; |
442 cpp_token eof; | 512 cpp_token eof; |
443 | 513 |
497 /* Table of comments, when state.save_comments is true. */ | 567 /* Table of comments, when state.save_comments is true. */ |
498 cpp_comment_table comments; | 568 cpp_comment_table comments; |
499 | 569 |
500 /* List of saved macros by push_macro. */ | 570 /* List of saved macros by push_macro. */ |
501 struct def_pragma_macro *pushed_macros; | 571 struct def_pragma_macro *pushed_macros; |
572 | |
573 /* If non-null, the lexer will use this location for the next token | |
574 instead of getting a location from the linemap. */ | |
575 source_location *forced_token_location_p; | |
502 }; | 576 }; |
503 | 577 |
504 /* Character classes. Based on the more primitive macros in safe-ctype.h. | 578 /* Character classes. Based on the more primitive macros in safe-ctype.h. |
505 If the definition of `numchar' looks odd to you, please look up the | 579 If the definition of `numchar' looks odd to you, please look up the |
506 definition of a pp-number in the C standard [section 6.4.8 of C99]. | 580 definition of a pp-number in the C standard [section 6.4.8 of C99]. |
550 extern void _cpp_free_definition (cpp_hashnode *); | 624 extern void _cpp_free_definition (cpp_hashnode *); |
551 extern bool _cpp_create_definition (cpp_reader *, cpp_hashnode *); | 625 extern bool _cpp_create_definition (cpp_reader *, cpp_hashnode *); |
552 extern void _cpp_pop_context (cpp_reader *); | 626 extern void _cpp_pop_context (cpp_reader *); |
553 extern void _cpp_push_text_context (cpp_reader *, cpp_hashnode *, | 627 extern void _cpp_push_text_context (cpp_reader *, cpp_hashnode *, |
554 const unsigned char *, size_t); | 628 const unsigned char *, size_t); |
555 extern bool _cpp_save_parameter (cpp_reader *, cpp_macro *, cpp_hashnode *); | 629 extern bool _cpp_save_parameter (cpp_reader *, cpp_macro *, cpp_hashnode *, |
630 cpp_hashnode *); | |
556 extern bool _cpp_arguments_ok (cpp_reader *, cpp_macro *, const cpp_hashnode *, | 631 extern bool _cpp_arguments_ok (cpp_reader *, cpp_macro *, const cpp_hashnode *, |
557 unsigned int); | 632 unsigned int); |
558 extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *, | 633 extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *, |
559 cpp_hashnode *); | 634 cpp_hashnode *, |
635 source_location = 0); | |
560 extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *); | 636 extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *); |
561 extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *, | 637 extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *, |
562 const cpp_token *, unsigned int); | 638 const cpp_token *, unsigned int); |
563 extern void _cpp_backup_tokens_direct (cpp_reader *, unsigned int); | 639 extern void _cpp_backup_tokens_direct (cpp_reader *, unsigned int); |
564 | 640 |
565 /* In identifiers.c */ | 641 /* In identifiers.c */ |
566 extern void _cpp_init_hashtable (cpp_reader *, hash_table *); | 642 extern void _cpp_init_hashtable (cpp_reader *, cpp_hash_table *); |
567 extern void _cpp_destroy_hashtable (cpp_reader *); | 643 extern void _cpp_destroy_hashtable (cpp_reader *); |
568 | 644 |
569 /* In files.c */ | 645 /* In files.c */ |
570 typedef struct _cpp_file _cpp_file; | 646 typedef struct _cpp_file _cpp_file; |
571 extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *, | 647 extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *, |
572 bool, int); | 648 bool, int, bool, source_location); |
573 extern bool _cpp_find_failed (_cpp_file *); | 649 extern bool _cpp_find_failed (_cpp_file *); |
574 extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *); | 650 extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *); |
575 extern void _cpp_fake_include (cpp_reader *, const char *); | 651 extern void _cpp_fake_include (cpp_reader *, const char *); |
576 extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, bool); | 652 extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, bool, |
653 source_location); | |
577 extern bool _cpp_stack_include (cpp_reader *, const char *, int, | 654 extern bool _cpp_stack_include (cpp_reader *, const char *, int, |
578 enum include_type); | 655 enum include_type, source_location); |
579 extern int _cpp_compare_file_date (cpp_reader *, const char *, int); | 656 extern int _cpp_compare_file_date (cpp_reader *, const char *, int); |
580 extern void _cpp_report_missing_guards (cpp_reader *); | 657 extern void _cpp_report_missing_guards (cpp_reader *); |
581 extern void _cpp_init_files (cpp_reader *); | 658 extern void _cpp_init_files (cpp_reader *); |
582 extern void _cpp_cleanup_files (cpp_reader *); | 659 extern void _cpp_cleanup_files (cpp_reader *); |
583 extern void _cpp_pop_file_buffer (cpp_reader *, struct _cpp_file *); | 660 extern void _cpp_pop_file_buffer (cpp_reader *, struct _cpp_file *, |
661 const unsigned char *); | |
584 extern bool _cpp_save_file_entries (cpp_reader *pfile, FILE *f); | 662 extern bool _cpp_save_file_entries (cpp_reader *pfile, FILE *f); |
585 extern bool _cpp_read_file_entries (cpp_reader *, FILE *); | 663 extern bool _cpp_read_file_entries (cpp_reader *, FILE *); |
664 extern const char *_cpp_get_file_name (_cpp_file *); | |
586 extern struct stat *_cpp_get_file_stat (_cpp_file *); | 665 extern struct stat *_cpp_get_file_stat (_cpp_file *); |
666 extern bool _cpp_has_header (cpp_reader *, const char *, int, | |
667 enum include_type); | |
587 | 668 |
588 /* In expr.c */ | 669 /* In expr.c */ |
589 extern bool _cpp_parse_expr (cpp_reader *, bool); | 670 extern bool _cpp_parse_expr (cpp_reader *, bool); |
590 extern struct op *_cpp_expand_op_stack (cpp_reader *); | 671 extern struct op *_cpp_expand_op_stack (cpp_reader *); |
591 | 672 |
595 extern bool _cpp_get_fresh_line (cpp_reader *); | 676 extern bool _cpp_get_fresh_line (cpp_reader *); |
596 extern bool _cpp_skip_block_comment (cpp_reader *); | 677 extern bool _cpp_skip_block_comment (cpp_reader *); |
597 extern cpp_token *_cpp_temp_token (cpp_reader *); | 678 extern cpp_token *_cpp_temp_token (cpp_reader *); |
598 extern const cpp_token *_cpp_lex_token (cpp_reader *); | 679 extern const cpp_token *_cpp_lex_token (cpp_reader *); |
599 extern cpp_token *_cpp_lex_direct (cpp_reader *); | 680 extern cpp_token *_cpp_lex_direct (cpp_reader *); |
681 extern unsigned char *_cpp_spell_ident_ucns (unsigned char *, cpp_hashnode *); | |
600 extern int _cpp_equiv_tokens (const cpp_token *, const cpp_token *); | 682 extern int _cpp_equiv_tokens (const cpp_token *, const cpp_token *); |
601 extern void _cpp_init_tokenrun (tokenrun *, unsigned int); | 683 extern void _cpp_init_tokenrun (tokenrun *, unsigned int); |
602 extern cpp_hashnode *_cpp_lex_identifier (cpp_reader *, const char *); | 684 extern cpp_hashnode *_cpp_lex_identifier (cpp_reader *, const char *); |
685 extern int _cpp_remaining_tokens_num_in_context (cpp_context *); | |
686 extern void _cpp_init_lexer (void); | |
603 | 687 |
604 /* In init.c. */ | 688 /* In init.c. */ |
605 extern void _cpp_maybe_push_include_file (cpp_reader *); | 689 extern void _cpp_maybe_push_include_file (cpp_reader *); |
606 extern const char *cpp_named_operator2name (enum cpp_ttype type); | 690 extern const char *cpp_named_operator2name (enum cpp_ttype type); |
607 | 691 |
609 extern int _cpp_test_assertion (cpp_reader *, unsigned int *); | 693 extern int _cpp_test_assertion (cpp_reader *, unsigned int *); |
610 extern int _cpp_handle_directive (cpp_reader *, int); | 694 extern int _cpp_handle_directive (cpp_reader *, int); |
611 extern void _cpp_define_builtin (cpp_reader *, const char *); | 695 extern void _cpp_define_builtin (cpp_reader *, const char *); |
612 extern char ** _cpp_save_pragma_names (cpp_reader *); | 696 extern char ** _cpp_save_pragma_names (cpp_reader *); |
613 extern void _cpp_restore_pragma_names (cpp_reader *, char **); | 697 extern void _cpp_restore_pragma_names (cpp_reader *, char **); |
614 extern int _cpp_do__Pragma (cpp_reader *); | 698 extern int _cpp_do__Pragma (cpp_reader *, source_location); |
615 extern void _cpp_init_directives (cpp_reader *); | 699 extern void _cpp_init_directives (cpp_reader *); |
616 extern void _cpp_init_internal_pragmas (cpp_reader *); | 700 extern void _cpp_init_internal_pragmas (cpp_reader *); |
617 extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *, | 701 extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *, |
618 linenum_type, unsigned int); | 702 linenum_type, unsigned int); |
619 extern void _cpp_pop_buffer (cpp_reader *); | 703 extern void _cpp_pop_buffer (cpp_reader *); |
704 extern char *_cpp_bracket_include (cpp_reader *); | |
620 | 705 |
621 /* In directives.c */ | 706 /* In directives.c */ |
622 struct _cpp_dir_only_callbacks | 707 struct _cpp_dir_only_callbacks |
623 { | 708 { |
624 /* Called to print a block of lines. */ | 709 /* Called to print a block of lines. */ |
628 | 713 |
629 extern void _cpp_preprocess_dir_only (cpp_reader *, | 714 extern void _cpp_preprocess_dir_only (cpp_reader *, |
630 const struct _cpp_dir_only_callbacks *); | 715 const struct _cpp_dir_only_callbacks *); |
631 | 716 |
632 /* In traditional.c. */ | 717 /* In traditional.c. */ |
633 extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *); | 718 extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *, bool); |
634 extern bool _cpp_read_logical_line_trad (cpp_reader *); | 719 extern bool _cpp_read_logical_line_trad (cpp_reader *); |
635 extern void _cpp_overlay_buffer (cpp_reader *pfile, const unsigned char *, | 720 extern void _cpp_overlay_buffer (cpp_reader *pfile, const unsigned char *, |
636 size_t); | 721 size_t); |
637 extern void _cpp_remove_overlay (cpp_reader *); | 722 extern void _cpp_remove_overlay (cpp_reader *); |
638 extern bool _cpp_create_trad_definition (cpp_reader *, cpp_macro *); | 723 extern bool _cpp_create_trad_definition (cpp_reader *, cpp_macro *); |
648 It starts initialized to all zeros, and at the end | 733 It starts initialized to all zeros, and at the end |
649 'level' is the normalization level of the sequence. */ | 734 'level' is the normalization level of the sequence. */ |
650 | 735 |
651 struct normalize_state | 736 struct normalize_state |
652 { | 737 { |
653 /* The previous character. */ | 738 /* The previous starter character. */ |
654 cppchar_t previous; | 739 cppchar_t previous; |
655 /* The combining class of the previous character. */ | 740 /* The combining class of the previous character (whether or not a |
741 starter). */ | |
656 unsigned char prev_class; | 742 unsigned char prev_class; |
657 /* The lowest normalization level so far. */ | 743 /* The lowest normalization level so far. */ |
658 enum cpp_normalize_level level; | 744 enum cpp_normalize_level level; |
659 }; | 745 }; |
660 #define INITIAL_NORMALIZE_STATE { 0, 0, normalized_KC } | 746 #define INITIAL_NORMALIZE_STATE { 0, 0, normalized_KC } |
661 #define NORMALIZE_STATE_RESULT(st) ((st)->level) | 747 #define NORMALIZE_STATE_RESULT(st) ((st)->level) |
662 | 748 |
663 /* We saw a character that matches ISIDNUM(), update a | 749 /* We saw a character C that matches ISIDNUM(), update a |
664 normalize_state appropriately. */ | 750 normalize_state appropriately. */ |
665 #define NORMALIZE_STATE_UPDATE_IDNUM(st) \ | 751 #define NORMALIZE_STATE_UPDATE_IDNUM(st, c) \ |
666 ((st)->previous = 0, (st)->prev_class = 0) | 752 ((st)->previous = (c), (st)->prev_class = 0) |
667 | 753 |
668 extern cppchar_t _cpp_valid_ucn (cpp_reader *, const unsigned char **, | 754 extern bool _cpp_valid_ucn (cpp_reader *, const unsigned char **, |
669 const unsigned char *, int, | 755 const unsigned char *, int, |
670 struct normalize_state *state); | 756 struct normalize_state *state, |
757 cppchar_t *, | |
758 source_range *char_range, | |
759 cpp_string_location_reader *loc_reader); | |
671 extern void _cpp_destroy_iconv (cpp_reader *); | 760 extern void _cpp_destroy_iconv (cpp_reader *); |
672 extern unsigned char *_cpp_convert_input (cpp_reader *, const char *, | 761 extern unsigned char *_cpp_convert_input (cpp_reader *, const char *, |
673 unsigned char *, size_t, size_t, | 762 unsigned char *, size_t, size_t, |
674 const unsigned char **, off_t *); | 763 const unsigned char **, off_t *); |
675 extern const char *_cpp_default_encoding (void); | 764 extern const char *_cpp_default_encoding (void); |
684 checking. */ | 773 checking. */ |
685 static inline int ustrcmp (const unsigned char *, const unsigned char *); | 774 static inline int ustrcmp (const unsigned char *, const unsigned char *); |
686 static inline int ustrncmp (const unsigned char *, const unsigned char *, | 775 static inline int ustrncmp (const unsigned char *, const unsigned char *, |
687 size_t); | 776 size_t); |
688 static inline size_t ustrlen (const unsigned char *); | 777 static inline size_t ustrlen (const unsigned char *); |
689 static inline unsigned char *uxstrdup (const unsigned char *); | 778 static inline const unsigned char *uxstrdup (const unsigned char *); |
690 static inline unsigned char *ustrchr (const unsigned char *, int); | 779 static inline const unsigned char *ustrchr (const unsigned char *, int); |
691 static inline int ufputs (const unsigned char *, FILE *); | 780 static inline int ufputs (const unsigned char *, FILE *); |
692 | 781 |
693 /* Use a const char for the second parameter since it is usually a literal. */ | 782 /* Use a const char for the second parameter since it is usually a literal. */ |
694 static inline int ustrcspn (const unsigned char *, const char *); | 783 static inline int ustrcspn (const unsigned char *, const char *); |
695 | 784 |
715 ustrlen (const unsigned char *s1) | 804 ustrlen (const unsigned char *s1) |
716 { | 805 { |
717 return strlen ((const char *)s1); | 806 return strlen ((const char *)s1); |
718 } | 807 } |
719 | 808 |
720 static inline unsigned char * | 809 static inline const unsigned char * |
721 uxstrdup (const unsigned char *s1) | 810 uxstrdup (const unsigned char *s1) |
722 { | 811 { |
723 return (unsigned char *) xstrdup ((const char *)s1); | 812 return (const unsigned char *) xstrdup ((const char *)s1); |
724 } | 813 } |
725 | 814 |
726 static inline unsigned char * | 815 static inline const unsigned char * |
727 ustrchr (const unsigned char *s1, int c) | 816 ustrchr (const unsigned char *s1, int c) |
728 { | 817 { |
729 return (unsigned char *) strchr ((const char *)s1, c); | 818 return (const unsigned char *) strchr ((const char *)s1, c); |
730 } | 819 } |
731 | 820 |
732 static inline int | 821 static inline int |
733 ufputs (const unsigned char *s, FILE *f) | 822 ufputs (const unsigned char *s, FILE *f) |
734 { | 823 { |
735 return fputs ((const char *)s, f); | 824 return fputs ((const char *)s, f); |
736 } | 825 } |
826 | |
827 /* In line-map.c. */ | |
828 | |
829 /* Create a macro map. A macro map encodes source locations of tokens | |
830 that are part of a macro replacement-list, at a macro expansion | |
831 point. See the extensive comments of struct line_map and struct | |
832 line_map_macro, in line-map.h. | |
833 | |
834 This map shall be created when the macro is expanded. The map | |
835 encodes the source location of the expansion point of the macro as | |
836 well as the "original" source location of each token that is part | |
837 of the macro replacement-list. If a macro is defined but never | |
838 expanded, it has no macro map. SET is the set of maps the macro | |
839 map should be part of. MACRO_NODE is the macro which the new macro | |
840 map should encode source locations for. EXPANSION is the location | |
841 of the expansion point of MACRO. For function-like macros | |
842 invocations, it's best to make it point to the closing parenthesis | |
843 of the macro, rather than the the location of the first character | |
844 of the macro. NUM_TOKENS is the number of tokens that are part of | |
845 the replacement-list of MACRO. */ | |
846 const line_map_macro *linemap_enter_macro (struct line_maps *, | |
847 struct cpp_hashnode*, | |
848 source_location, | |
849 unsigned int); | |
850 | |
851 /* Create and return a virtual location for a token that is part of a | |
852 macro expansion-list at a macro expansion point. See the comment | |
853 inside struct line_map_macro to see what an expansion-list exactly | |
854 is. | |
855 | |
856 A call to this function must come after a call to | |
857 linemap_enter_macro. | |
858 | |
859 MAP is the map into which the source location is created. TOKEN_NO | |
860 is the index of the token in the macro replacement-list, starting | |
861 at number 0. | |
862 | |
863 ORIG_LOC is the location of the token outside of this macro | |
864 expansion. If the token comes originally from the macro | |
865 definition, it is the locus in the macro definition; otherwise it | |
866 is a location in the context of the caller of this macro expansion | |
867 (which is a virtual location or a source location if the caller is | |
868 itself a macro expansion or not). | |
869 | |
870 MACRO_DEFINITION_LOC is the location in the macro definition, | |
871 either of the token itself or of a macro parameter that it | |
872 replaces. */ | |
873 source_location linemap_add_macro_token (const line_map_macro *, | |
874 unsigned int, | |
875 source_location, | |
876 source_location); | |
877 | |
878 /* Return the source line number corresponding to source location | |
879 LOCATION. SET is the line map set LOCATION comes from. If | |
880 LOCATION is the location of token that is part of the | |
881 expansion-list of a macro expansion return the line number of the | |
882 macro expansion point. */ | |
883 int linemap_get_expansion_line (struct line_maps *, | |
884 source_location); | |
885 | |
886 /* Return the path of the file corresponding to source code location | |
887 LOCATION. | |
888 | |
889 If LOCATION is the location of a token that is part of the | |
890 replacement-list of a macro expansion return the file path of the | |
891 macro expansion point. | |
892 | |
893 SET is the line map set LOCATION comes from. */ | |
894 const char* linemap_get_expansion_filename (struct line_maps *, | |
895 source_location); | |
737 | 896 |
738 #ifdef __cplusplus | 897 #ifdef __cplusplus |
739 } | 898 } |
740 #endif | 899 #endif |
741 | 900 |