diff options
Diffstat (limited to 'libcpp/internal.h')
-rw-r--r-- | libcpp/internal.h | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/libcpp/internal.h b/libcpp/internal.h index b1a2a99..4010af8 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -48,6 +48,8 @@ struct cset_converter convert_f func; iconv_t cd; int width; + const char* from; + const char* to; }; #define BITS_PER_CPPCHAR_T (CHAR_BIT * sizeof (cppchar_t)) @@ -280,6 +282,9 @@ struct lexer_state /* Nonzero when tokenizing a deferred pragma. */ unsigned char in_deferred_pragma; + /* Count to token that is a header-name. */ + unsigned char directive_file_token; + /* Nonzero if the deferred pragma being handled allows macro expansion. */ unsigned char pragma_allow_expansion; }; @@ -292,6 +297,12 @@ struct spec_nodes cpp_hashnode *n_false; /* C++ keyword false */ cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */ cpp_hashnode *n__VA_OPT__; /* C++ vararg macros */ + + enum {M_EXPORT, M_MODULE, M_IMPORT, M__IMPORT, M_HWM}; + + /* C++20 modules, only set when module_directives is in effect. + incoming variants [0], outgoing ones [1] */ + cpp_hashnode *n_modules[M_HWM][2]; }; typedef struct _cpp_line_note _cpp_line_note; @@ -512,10 +523,9 @@ struct cpp_reader const unsigned char *date; const unsigned char *time; - /* Externally set timestamp to replace current date and time useful for - reproducibility. It should be initialized to -2 (not yet set) and - set to -1 to disable it or to a non-negative value to enable it. */ - time_t source_date_epoch; + /* Time stamp, set idempotently lazily. */ + time_t time_stamp; + int time_stamp_kind; /* Or errno. */ /* A token forcing paste avoidance, and one demarking macro arguments. */ cpp_token avoid_paste; @@ -583,6 +593,10 @@ struct cpp_reader /* If non-zero, the lexer will use this location for the next token instead of getting a location from the linemap. */ location_t forced_token_location; + + /* Location identifying the main source file -- intended to be line + zero of said file. */ + location_t main_loc; }; /* Character classes. Based on the more primitive macros in safe-ctype.h. @@ -620,22 +634,23 @@ typedef unsigned char uchar; #define UC (const uchar *) /* Intended use: UC"string" */ -/* Macros. */ +/* Accessors. */ -static inline int cpp_in_system_header (cpp_reader *); -static inline int -cpp_in_system_header (cpp_reader *pfile) +inline int +_cpp_in_system_header (cpp_reader *pfile) { return pfile->buffer ? pfile->buffer->sysp : 0; } #define CPP_PEDANTIC(PF) CPP_OPTION (PF, cpp_pedantic) #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, cpp_warn_traditional) -static inline int cpp_in_primary_file (cpp_reader *); -static inline int -cpp_in_primary_file (cpp_reader *pfile) +/* Return true if we're in the main file (unless it's considered to be + an include file in its own right. */ +inline int +_cpp_in_main_source_file (cpp_reader *pfile) { - return pfile->line_table->depth == 1; + return (!CPP_OPTION (pfile, main_search) + && pfile->buffer->file == pfile->main_file); } /* True if NODE is a macro for the purposes of ifdef, defined etc. */ @@ -649,11 +664,14 @@ inline bool _cpp_defined_macro_p (cpp_hashnode *node) } /* In macro.c */ -extern void _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node); -inline void _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node) +extern bool _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node, + location_t); +inline bool _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node, + location_t loc) { if (!(node->flags & NODE_USED)) - _cpp_notify_macro_use (pfile, node); + return _cpp_notify_macro_use (pfile, node, loc); + return true; } extern cpp_macro *_cpp_new_macro (cpp_reader *, cpp_macro_kind, void *); extern void _cpp_free_definition (cpp_hashnode *); @@ -867,29 +885,7 @@ ufputs (const unsigned char *s, FILE *f) return fputs ((const char *)s, f); } - /* In line-map.c. */ - -/* Create a macro map. A macro map encodes source locations of tokens - that are part of a macro replacement-list, at a macro expansion - point. See the extensive comments of struct line_map and struct - line_map_macro, in line-map.h. - - This map shall be created when the macro is expanded. The map - encodes the source location of the expansion point of the macro as - well as the "original" source location of each token that is part - of the macro replacement-list. If a macro is defined but never - expanded, it has no macro map. SET is the set of maps the macro - map should be part of. MACRO_NODE is the macro which the new macro - map should encode source locations for. EXPANSION is the location - of the expansion point of MACRO. For function-like macros - invocations, it's best to make it point to the closing parenthesis - of the macro, rather than the the location of the first character - of the macro. NUM_TOKENS is the number of tokens that are part of - the replacement-list of MACRO. */ -const line_map_macro *linemap_enter_macro (class line_maps *, - struct cpp_hashnode*, - location_t, - unsigned int); +/* In line-map.c. */ /* Create and return a virtual location for a token that is part of a macro expansion-list at a macro expansion point. See the comment |