Home | History | Annotate | Line # | Download | only in libcpp
      1   1.1  mrg /* Part of CPP library.
      2  1.13  mrg    Copyright (C) 1997-2024 Free Software Foundation, Inc.
      3   1.1  mrg 
      4   1.1  mrg This program is free software; you can redistribute it and/or modify it
      5   1.1  mrg under the terms of the GNU General Public License as published by the
      6   1.1  mrg Free Software Foundation; either version 3, or (at your option) any
      7   1.1  mrg later version.
      8   1.1  mrg 
      9   1.1  mrg This program is distributed in the hope that it will be useful,
     10   1.1  mrg but WITHOUT ANY WARRANTY; without even the implied warranty of
     11   1.1  mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12   1.1  mrg GNU General Public License for more details.
     13   1.1  mrg 
     14   1.1  mrg You should have received a copy of the GNU General Public License
     15   1.1  mrg along with this program; see the file COPYING3.  If not see
     16   1.1  mrg <http://www.gnu.org/licenses/>.  */
     17   1.1  mrg 
     18   1.1  mrg /* This header defines all the internal data structures and functions
     19   1.1  mrg    that need to be visible across files.  It should not be used outside
     20   1.1  mrg    cpplib.  */
     21   1.1  mrg 
     22   1.1  mrg #ifndef LIBCPP_INTERNAL_H
     23   1.1  mrg #define LIBCPP_INTERNAL_H
     24   1.1  mrg 
     25   1.1  mrg #include "symtab.h"
     26  1.10  mrg #include "cpplib.h"
     27  1.13  mrg #include "rich-location.h"
     28   1.1  mrg 
     29   1.1  mrg #if HAVE_ICONV
     30   1.1  mrg #include <iconv.h>
     31   1.1  mrg #else
     32   1.1  mrg #define HAVE_ICONV 0
     33   1.1  mrg typedef int iconv_t;  /* dummy */
     34   1.1  mrg #endif
     35   1.1  mrg 
     36   1.1  mrg #ifdef __cplusplus
     37   1.1  mrg extern "C" {
     38   1.1  mrg #endif
     39   1.1  mrg 
     40   1.1  mrg struct directive;		/* Deliberately incomplete.  */
     41   1.1  mrg struct pending_option;
     42   1.1  mrg struct op;
     43   1.1  mrg struct _cpp_strbuf;
     44   1.1  mrg 
     45   1.1  mrg typedef bool (*convert_f) (iconv_t, const unsigned char *, size_t,
     46   1.1  mrg 			   struct _cpp_strbuf *);
     47   1.1  mrg struct cset_converter
     48   1.1  mrg {
     49   1.1  mrg   convert_f func;
     50   1.1  mrg   iconv_t cd;
     51   1.1  mrg   int width;
     52  1.12  mrg   const char* from;
     53  1.12  mrg   const char* to;
     54   1.1  mrg };
     55   1.1  mrg 
     56   1.1  mrg #define BITS_PER_CPPCHAR_T (CHAR_BIT * sizeof (cppchar_t))
     57   1.1  mrg 
     58   1.1  mrg /* Test if a sign is valid within a preprocessing number.  */
     59   1.1  mrg #define VALID_SIGN(c, prevc) \
     60   1.1  mrg   (((c) == '+' || (c) == '-') && \
     61   1.1  mrg    ((prevc) == 'e' || (prevc) == 'E' \
     62   1.1  mrg     || (((prevc) == 'p' || (prevc) == 'P') \
     63   1.1  mrg         && CPP_OPTION (pfile, extended_numbers))))
     64   1.1  mrg 
     65   1.4  mrg #define DIGIT_SEP(c) ((c) == '\'' && CPP_OPTION (pfile, digit_separators))
     66   1.4  mrg 
     67   1.1  mrg #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
     68   1.1  mrg #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
     69   1.1  mrg #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base)
     70   1.1  mrg #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur)
     71   1.1  mrg 
     72   1.1  mrg #define CPP_INCREMENT_LINE(PFILE, COLS_HINT) do { \
     73  1.11  mrg     const class line_maps *line_table = PFILE->line_table; \
     74   1.5  mrg     const struct line_map_ordinary *map = \
     75   1.3  mrg       LINEMAPS_LAST_ORDINARY_MAP (line_table); \
     76   1.1  mrg     linenum_type line = SOURCE_LINE (map, line_table->highest_line); \
     77   1.1  mrg     linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \
     78   1.1  mrg   } while (0)
     79   1.1  mrg 
     80   1.1  mrg /* Host alignment handling.  */
     81   1.1  mrg struct dummy
     82   1.1  mrg {
     83   1.1  mrg   char c;
     84   1.1  mrg   union
     85   1.1  mrg   {
     86   1.1  mrg     double d;
     87   1.1  mrg     int *p;
     88   1.1  mrg   } u;
     89   1.1  mrg };
     90   1.1  mrg 
     91   1.1  mrg #define DEFAULT_ALIGNMENT offsetof (struct dummy, u)
     92   1.1  mrg #define CPP_ALIGN2(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
     93   1.1  mrg #define CPP_ALIGN(size) CPP_ALIGN2 (size, DEFAULT_ALIGNMENT)
     94   1.1  mrg 
     95  1.10  mrg #define _cpp_mark_macro_used(NODE) 					\
     96  1.10  mrg   (cpp_user_macro_p (NODE) ? (NODE)->value.macro->used = 1 : 0)
     97   1.1  mrg 
     98   1.1  mrg /* A generic memory buffer, and operations on it.  */
     99   1.1  mrg typedef struct _cpp_buff _cpp_buff;
    100   1.1  mrg struct _cpp_buff
    101   1.1  mrg {
    102   1.1  mrg   struct _cpp_buff *next;
    103   1.1  mrg   unsigned char *base, *cur, *limit;
    104   1.1  mrg };
    105   1.1  mrg 
    106   1.1  mrg extern _cpp_buff *_cpp_get_buff (cpp_reader *, size_t);
    107   1.1  mrg extern void _cpp_release_buff (cpp_reader *, _cpp_buff *);
    108   1.1  mrg extern void _cpp_extend_buff (cpp_reader *, _cpp_buff **, size_t);
    109   1.1  mrg extern _cpp_buff *_cpp_append_extend_buff (cpp_reader *, _cpp_buff *, size_t);
    110   1.1  mrg extern void _cpp_free_buff (_cpp_buff *);
    111   1.1  mrg extern unsigned char *_cpp_aligned_alloc (cpp_reader *, size_t);
    112   1.1  mrg extern unsigned char *_cpp_unaligned_alloc (cpp_reader *, size_t);
    113   1.1  mrg 
    114   1.1  mrg #define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur)
    115   1.1  mrg #define BUFF_FRONT(BUFF) ((BUFF)->cur)
    116   1.1  mrg #define BUFF_LIMIT(BUFF) ((BUFF)->limit)
    117   1.1  mrg 
    118   1.1  mrg /* #include types.  */
    119  1.11  mrg enum include_type
    120  1.11  mrg   {
    121  1.11  mrg    /* Directive-based including mechanisms.  */
    122  1.11  mrg    IT_INCLUDE,  /* #include */
    123  1.11  mrg    IT_INCLUDE_NEXT,  /* #include_next */
    124  1.11  mrg    IT_IMPORT,   /* #import  */
    125  1.11  mrg 
    126  1.11  mrg    /* Non-directive including mechanisms.  */
    127  1.11  mrg    IT_CMDLINE,  /* -include */
    128  1.11  mrg    IT_DEFAULT,  /* forced header  */
    129  1.12  mrg    IT_MAIN,     /* main, start on line 1 */
    130  1.12  mrg    IT_PRE_MAIN,  /* main, but there will be a preamble before line
    131  1.12  mrg 		    1 */
    132  1.11  mrg 
    133  1.11  mrg    IT_DIRECTIVE_HWM = IT_IMPORT + 1,  /* Directives below this.  */
    134  1.11  mrg    IT_HEADER_HWM = IT_DEFAULT + 1     /* Header files below this.  */
    135  1.11  mrg   };
    136   1.1  mrg 
    137   1.1  mrg union utoken
    138   1.1  mrg {
    139   1.1  mrg   const cpp_token *token;
    140   1.1  mrg   const cpp_token **ptoken;
    141   1.1  mrg };
    142   1.1  mrg 
    143   1.1  mrg /* A "run" of tokens; part of a chain of runs.  */
    144   1.1  mrg typedef struct tokenrun tokenrun;
    145   1.1  mrg struct tokenrun
    146   1.1  mrg {
    147   1.1  mrg   tokenrun *next, *prev;
    148   1.1  mrg   cpp_token *base, *limit;
    149   1.1  mrg };
    150   1.1  mrg 
    151   1.1  mrg /* Accessor macros for struct cpp_context.  */
    152   1.1  mrg #define FIRST(c) ((c)->u.iso.first)
    153   1.1  mrg #define LAST(c) ((c)->u.iso.last)
    154   1.1  mrg #define CUR(c) ((c)->u.trad.cur)
    155   1.1  mrg #define RLIMIT(c) ((c)->u.trad.rlimit)
    156   1.1  mrg 
    157   1.3  mrg /* This describes some additional data that is added to the macro
    158   1.3  mrg    token context of type cpp_context, when -ftrack-macro-expansion is
    159   1.3  mrg    on.  */
    160   1.3  mrg typedef struct
    161   1.3  mrg {
    162   1.3  mrg   /* The node of the macro we are referring to.  */
    163   1.3  mrg   cpp_hashnode *macro_node;
    164   1.3  mrg   /* This buffer contains an array of virtual locations.  The virtual
    165   1.3  mrg      location at index 0 is the virtual location of the token at index
    166   1.3  mrg      0 in the current instance of cpp_context; similarly for all the
    167   1.3  mrg      other virtual locations.  */
    168  1.10  mrg   location_t *virt_locs;
    169   1.3  mrg   /* This is a pointer to the current virtual location.  This is used
    170   1.3  mrg      to iterate over the virtual locations while we iterate over the
    171   1.3  mrg      tokens they belong to.  */
    172  1.10  mrg   location_t *cur_virt_loc;
    173   1.3  mrg } macro_context;
    174   1.3  mrg 
    175   1.3  mrg /* The kind of tokens carried by a cpp_context.  */
    176   1.3  mrg enum context_tokens_kind {
    177   1.3  mrg   /* This is the value of cpp_context::tokens_kind if u.iso.first
    178   1.3  mrg      contains an instance of cpp_token **.  */
    179   1.3  mrg   TOKENS_KIND_INDIRECT,
    180   1.3  mrg   /* This is the value of cpp_context::tokens_kind if u.iso.first
    181   1.3  mrg      contains an instance of cpp_token *.  */
    182   1.3  mrg   TOKENS_KIND_DIRECT,
    183   1.3  mrg   /* This is the value of cpp_context::tokens_kind when the token
    184   1.3  mrg      context contains tokens resulting from macro expansion.  In that
    185   1.3  mrg      case struct cpp_context::macro points to an instance of struct
    186   1.3  mrg      macro_context.  This is used only when the
    187   1.3  mrg      -ftrack-macro-expansion flag is on.  */
    188   1.3  mrg   TOKENS_KIND_EXTENDED
    189   1.3  mrg };
    190   1.3  mrg 
    191   1.1  mrg typedef struct cpp_context cpp_context;
    192   1.1  mrg struct cpp_context
    193   1.1  mrg {
    194   1.1  mrg   /* Doubly-linked list.  */
    195   1.1  mrg   cpp_context *next, *prev;
    196   1.1  mrg 
    197   1.1  mrg   union
    198   1.1  mrg   {
    199   1.1  mrg     /* For ISO macro expansion.  Contexts other than the base context
    200   1.1  mrg        are contiguous tokens.  e.g. macro expansions, expanded
    201   1.1  mrg        argument tokens.  */
    202   1.1  mrg     struct
    203   1.1  mrg     {
    204   1.1  mrg       union utoken first;
    205   1.1  mrg       union utoken last;
    206   1.1  mrg     } iso;
    207   1.1  mrg 
    208   1.1  mrg     /* For traditional macro expansion.  */
    209   1.1  mrg     struct
    210   1.1  mrg     {
    211   1.1  mrg       const unsigned char *cur;
    212   1.1  mrg       const unsigned char *rlimit;
    213   1.1  mrg     } trad;
    214   1.1  mrg   } u;
    215   1.1  mrg 
    216   1.1  mrg   /* If non-NULL, a buffer used for storage related to this context.
    217   1.1  mrg      When the context is popped, the buffer is released.  */
    218   1.1  mrg   _cpp_buff *buff;
    219   1.1  mrg 
    220   1.3  mrg   /* If tokens_kind is TOKEN_KIND_EXTENDED, then (as we thus are in a
    221   1.3  mrg      macro context) this is a pointer to an instance of macro_context.
    222   1.3  mrg      Otherwise if tokens_kind is *not* TOKEN_KIND_EXTENDED, then, if
    223   1.3  mrg      we are in a macro context, this is a pointer to an instance of
    224   1.3  mrg      cpp_hashnode, representing the name of the macro this context is
    225   1.3  mrg      for.  If we are not in a macro context, then this is just NULL.
    226   1.3  mrg      Note that when tokens_kind is TOKEN_KIND_EXTENDED, the memory
    227   1.3  mrg      used by the instance of macro_context pointed to by this member
    228   1.3  mrg      is de-allocated upon de-allocation of the instance of struct
    229   1.3  mrg      cpp_context.  */
    230   1.3  mrg   union
    231   1.3  mrg   {
    232   1.3  mrg     macro_context *mc;
    233   1.3  mrg     cpp_hashnode *macro;
    234   1.3  mrg   } c;
    235   1.1  mrg 
    236   1.3  mrg   /* This determines the type of tokens held by this context.  */
    237   1.3  mrg   enum context_tokens_kind tokens_kind;
    238   1.1  mrg };
    239   1.1  mrg 
    240   1.1  mrg struct lexer_state
    241   1.1  mrg {
    242  1.11  mrg   /* 1 if we're handling a directive.  2 if it's an include-like
    243  1.11  mrg      directive.  */
    244   1.1  mrg   unsigned char in_directive;
    245   1.1  mrg 
    246   1.1  mrg   /* Nonzero if in a directive that will handle padding tokens itself.
    247   1.1  mrg      #include needs this to avoid problems with computed include and
    248   1.1  mrg      spacing between tokens.  */
    249   1.1  mrg   unsigned char directive_wants_padding;
    250   1.1  mrg 
    251   1.1  mrg   /* True if we are skipping a failed conditional group.  */
    252   1.1  mrg   unsigned char skipping;
    253   1.1  mrg 
    254   1.1  mrg   /* Nonzero if in a directive that takes angle-bracketed headers.  */
    255   1.1  mrg   unsigned char angled_headers;
    256   1.1  mrg 
    257   1.1  mrg   /* Nonzero if in a #if or #elif directive.  */
    258   1.1  mrg   unsigned char in_expression;
    259   1.1  mrg 
    260   1.1  mrg   /* Nonzero to save comments.  Turned off if discard_comments, and in
    261   1.1  mrg      all directives apart from #define.  */
    262   1.1  mrg   unsigned char save_comments;
    263   1.1  mrg 
    264   1.7  mrg   /* Nonzero if lexing __VA_ARGS__ and __VA_OPT__ are valid.  */
    265   1.1  mrg   unsigned char va_args_ok;
    266   1.1  mrg 
    267   1.1  mrg   /* Nonzero if lexing poisoned identifiers is valid.  */
    268   1.1  mrg   unsigned char poisoned_ok;
    269   1.1  mrg 
    270   1.1  mrg   /* Nonzero to prevent macro expansion.  */
    271   1.1  mrg   unsigned char prevent_expansion;
    272   1.1  mrg 
    273   1.1  mrg   /* Nonzero when parsing arguments to a function-like macro.  */
    274   1.1  mrg   unsigned char parsing_args;
    275   1.1  mrg 
    276   1.1  mrg   /* Nonzero if prevent_expansion is true only because output is
    277   1.1  mrg      being discarded.  */
    278   1.1  mrg   unsigned char discarding_output;
    279   1.1  mrg 
    280   1.1  mrg   /* Nonzero to skip evaluating part of an expression.  */
    281   1.1  mrg   unsigned int skip_eval;
    282   1.1  mrg 
    283  1.12  mrg   /* Nonzero when tokenizing a deferred pragma.  */
    284   1.1  mrg   unsigned char in_deferred_pragma;
    285   1.1  mrg 
    286  1.12  mrg   /* Count to token that is a header-name.  */
    287  1.12  mrg   unsigned char directive_file_token;
    288  1.12  mrg 
    289   1.1  mrg   /* Nonzero if the deferred pragma being handled allows macro expansion.  */
    290   1.1  mrg   unsigned char pragma_allow_expansion;
    291  1.12  mrg 
    292  1.12  mrg   /* Nonzero if _Pragma should not be interpreted.  */
    293  1.12  mrg   unsigned char ignore__Pragma;
    294   1.1  mrg };
    295   1.1  mrg 
    296   1.1  mrg /* Special nodes - identifiers with predefined significance.  */
    297   1.1  mrg struct spec_nodes
    298   1.1  mrg {
    299   1.1  mrg   cpp_hashnode *n_defined;		/* defined operator */
    300   1.1  mrg   cpp_hashnode *n_true;			/* C++ keyword true */
    301   1.1  mrg   cpp_hashnode *n_false;		/* C++ keyword false */
    302   1.1  mrg   cpp_hashnode *n__VA_ARGS__;		/* C99 vararg macros */
    303   1.7  mrg   cpp_hashnode *n__VA_OPT__;		/* C++ vararg macros */
    304  1.12  mrg 
    305  1.12  mrg   enum {M_EXPORT, M_MODULE, M_IMPORT, M__IMPORT, M_HWM};
    306  1.12  mrg 
    307  1.12  mrg   /* C++20 modules, only set when module_directives is in effect.
    308  1.12  mrg      incoming variants [0], outgoing ones [1] */
    309  1.12  mrg   cpp_hashnode *n_modules[M_HWM][2];
    310   1.1  mrg };
    311   1.1  mrg 
    312   1.1  mrg typedef struct _cpp_line_note _cpp_line_note;
    313   1.1  mrg struct _cpp_line_note
    314   1.1  mrg {
    315   1.1  mrg   /* Location in the clean line the note refers to.  */
    316   1.1  mrg   const unsigned char *pos;
    317   1.1  mrg 
    318   1.1  mrg   /* Type of note.  The 9 'from' trigraph characters represent those
    319   1.1  mrg      trigraphs, '\\' an escaped newline, ' ' an escaped newline with
    320   1.1  mrg      intervening space, 0 represents a note that has already been handled,
    321   1.1  mrg      and anything else is invalid.  */
    322   1.1  mrg   unsigned int type;
    323   1.1  mrg };
    324   1.1  mrg 
    325   1.1  mrg /* Represents the contents of a file cpplib has read in.  */
    326   1.1  mrg struct cpp_buffer
    327   1.1  mrg {
    328   1.1  mrg   const unsigned char *cur;        /* Current location.  */
    329   1.1  mrg   const unsigned char *line_base;  /* Start of current physical line.  */
    330   1.1  mrg   const unsigned char *next_line;  /* Start of to-be-cleaned logical line.  */
    331   1.1  mrg 
    332   1.1  mrg   const unsigned char *buf;        /* Entire character buffer.  */
    333   1.1  mrg   const unsigned char *rlimit;     /* Writable byte at end of file.  */
    334   1.3  mrg   const unsigned char *to_free;	   /* Pointer that should be freed when
    335   1.3  mrg 				      popping the buffer.  */
    336   1.1  mrg 
    337   1.1  mrg   _cpp_line_note *notes;           /* Array of notes.  */
    338   1.1  mrg   unsigned int cur_note;           /* Next note to process.  */
    339   1.1  mrg   unsigned int notes_used;         /* Number of notes.  */
    340   1.1  mrg   unsigned int notes_cap;          /* Size of allocated array.  */
    341   1.1  mrg 
    342   1.1  mrg   struct cpp_buffer *prev;
    343   1.1  mrg 
    344   1.1  mrg   /* Pointer into the file table; non-NULL if this is a file buffer.
    345   1.1  mrg      Used for include_next and to record control macros.  */
    346   1.1  mrg   struct _cpp_file *file;
    347   1.1  mrg 
    348   1.1  mrg   /* Saved value of __TIMESTAMP__ macro - date and time of last modification
    349   1.1  mrg      of the assotiated file.  */
    350   1.1  mrg   const unsigned char *timestamp;
    351   1.1  mrg 
    352   1.1  mrg   /* Value of if_stack at start of this file.
    353   1.1  mrg      Used to prohibit unmatched #endif (etc) in an include file.  */
    354   1.1  mrg   struct if_stack *if_stack;
    355   1.1  mrg 
    356   1.1  mrg   /* True if we need to get the next clean line.  */
    357  1.11  mrg   bool need_line : 1;
    358   1.1  mrg 
    359   1.1  mrg   /* True if we have already warned about C++ comments in this file.
    360   1.1  mrg      The warning happens only for C89 extended mode with -pedantic on,
    361   1.1  mrg      or for -Wtraditional, and only once per file (otherwise it would
    362   1.1  mrg      be far too noisy).  */
    363  1.11  mrg   bool warned_cplusplus_comments : 1;
    364   1.1  mrg 
    365   1.1  mrg   /* True if we don't process trigraphs and escaped newlines.  True
    366   1.1  mrg      for preprocessed input, command line directives, and _Pragma
    367   1.1  mrg      buffers.  */
    368  1.11  mrg   bool from_stage3 : 1;
    369   1.1  mrg 
    370   1.1  mrg   /* At EOF, a buffer is automatically popped.  If RETURN_AT_EOF is
    371   1.1  mrg      true, a CPP_EOF token is then returned.  Otherwise, the next
    372   1.1  mrg      token from the enclosing buffer is returned.  */
    373  1.11  mrg   bool return_at_eof : 1;
    374   1.1  mrg 
    375   1.1  mrg   /* One for a system header, two for a C system header file that therefore
    376   1.1  mrg      needs to be extern "C" protected in C++, and zero otherwise.  */
    377   1.1  mrg   unsigned char sysp;
    378   1.1  mrg 
    379   1.1  mrg   /* The directory of the this buffer's file.  Its NAME member is not
    380   1.1  mrg      allocated, so we don't need to worry about freeing it.  */
    381   1.1  mrg   struct cpp_dir dir;
    382   1.1  mrg 
    383   1.1  mrg   /* Descriptor for converting from the input character set to the
    384   1.1  mrg      source character set.  */
    385   1.1  mrg   struct cset_converter input_cset_desc;
    386   1.1  mrg };
    387   1.1  mrg 
    388   1.1  mrg /* The list of saved macros by push_macro pragma.  */
    389   1.1  mrg struct def_pragma_macro {
    390   1.1  mrg   /* Chain element to previous saved macro.  */
    391   1.1  mrg   struct def_pragma_macro *next;
    392   1.1  mrg   /* Name of the macro.  */
    393   1.1  mrg   char *name;
    394   1.1  mrg   /* The stored macro content.  */
    395   1.3  mrg   unsigned char *definition;
    396   1.3  mrg 
    397   1.3  mrg   /* Definition line number.  */
    398  1.10  mrg   location_t line;
    399   1.3  mrg   /* If macro defined in system header.  */
    400   1.3  mrg   unsigned int syshdr   : 1;
    401   1.3  mrg   /* Nonzero if it has been expanded or had its existence tested.  */
    402   1.3  mrg   unsigned int used     : 1;
    403   1.3  mrg 
    404   1.3  mrg   /* Mark if we save an undefined macro.  */
    405   1.3  mrg   unsigned int is_undef : 1;
    406   1.9  mrg   /* Nonzero if it was a builtin macro.  */
    407   1.9  mrg   unsigned int is_builtin : 1;
    408   1.1  mrg };
    409   1.1  mrg 
    410   1.1  mrg /* A cpp_reader encapsulates the "state" of a pre-processor run.
    411   1.1  mrg    Applying cpp_get_token repeatedly yields a stream of pre-processor
    412   1.1  mrg    tokens.  Usually, there is only one cpp_reader object active.  */
    413   1.1  mrg struct cpp_reader
    414   1.1  mrg {
    415   1.1  mrg   /* Top of buffer stack.  */
    416   1.1  mrg   cpp_buffer *buffer;
    417   1.1  mrg 
    418   1.1  mrg   /* Overlaid buffer (can be different after processing #include).  */
    419   1.1  mrg   cpp_buffer *overlaid_buffer;
    420   1.1  mrg 
    421   1.1  mrg   /* Lexer state.  */
    422   1.1  mrg   struct lexer_state state;
    423   1.1  mrg 
    424   1.1  mrg   /* Source line tracking.  */
    425  1.11  mrg   class line_maps *line_table;
    426   1.1  mrg 
    427   1.1  mrg   /* The line of the '#' of the current directive.  */
    428  1.10  mrg   location_t directive_line;
    429   1.1  mrg 
    430   1.1  mrg   /* Memory buffers.  */
    431   1.1  mrg   _cpp_buff *a_buff;		/* Aligned permanent storage.  */
    432   1.1  mrg   _cpp_buff *u_buff;		/* Unaligned permanent storage.  */
    433   1.1  mrg   _cpp_buff *free_buffs;	/* Free buffer chain.  */
    434   1.1  mrg 
    435   1.1  mrg   /* Context stack.  */
    436   1.1  mrg   struct cpp_context base_context;
    437   1.1  mrg   struct cpp_context *context;
    438   1.1  mrg 
    439   1.1  mrg   /* If in_directive, the directive if known.  */
    440   1.1  mrg   const struct directive *directive;
    441   1.1  mrg 
    442   1.1  mrg   /* Token generated while handling a directive, if any. */
    443   1.1  mrg   cpp_token directive_result;
    444   1.1  mrg 
    445   1.1  mrg   /* When expanding a macro at top-level, this is the location of the
    446   1.1  mrg      macro invocation.  */
    447  1.10  mrg   location_t invocation_location;
    448   1.1  mrg 
    449   1.4  mrg   /* This is the node representing the macro being expanded at
    450   1.4  mrg      top-level.  The value of this data member is valid iff
    451  1.11  mrg      cpp_in_macro_expansion_p() returns TRUE.  */
    452   1.4  mrg   cpp_hashnode *top_most_macro_node;
    453   1.4  mrg 
    454   1.3  mrg   /* Nonzero if we are about to expand a macro.  Note that if we are
    455   1.3  mrg      really expanding a macro, the function macro_of_context returns
    456   1.3  mrg      the macro being expanded and this flag is set to false.  Client
    457  1.11  mrg      code should use the function cpp_in_macro_expansion_p to know if we
    458   1.3  mrg      are either about to expand a macro, or are actually expanding
    459   1.3  mrg      one.  */
    460   1.3  mrg   bool about_to_expand_macro_p;
    461   1.1  mrg 
    462   1.1  mrg   /* Search paths for include files.  */
    463   1.1  mrg   struct cpp_dir *quote_include;	/* "" */
    464   1.1  mrg   struct cpp_dir *bracket_include;	/* <> */
    465   1.1  mrg   struct cpp_dir no_search_path;	/* No path.  */
    466   1.1  mrg 
    467   1.1  mrg   /* Chain of all hashed _cpp_file instances.  */
    468   1.1  mrg   struct _cpp_file *all_files;
    469   1.1  mrg 
    470   1.1  mrg   struct _cpp_file *main_file;
    471   1.1  mrg 
    472   1.1  mrg   /* File and directory hash table.  */
    473   1.1  mrg   struct htab *file_hash;
    474   1.1  mrg   struct htab *dir_hash;
    475   1.1  mrg   struct file_hash_entry_pool *file_hash_entries;
    476   1.1  mrg 
    477   1.1  mrg   /* Negative path lookup hash table.  */
    478   1.1  mrg   struct htab *nonexistent_file_hash;
    479   1.1  mrg   struct obstack nonexistent_file_ob;
    480   1.1  mrg 
    481   1.1  mrg   /* Nonzero means don't look for #include "foo" the source-file
    482   1.1  mrg      directory.  */
    483   1.1  mrg   bool quote_ignores_source_dir;
    484   1.1  mrg 
    485   1.1  mrg   /* Nonzero if any file has contained #pragma once or #import has
    486   1.1  mrg      been used.  */
    487   1.1  mrg   bool seen_once_only;
    488   1.1  mrg 
    489   1.1  mrg   /* Multiple include optimization.  */
    490   1.1  mrg   const cpp_hashnode *mi_cmacro;
    491   1.1  mrg   const cpp_hashnode *mi_ind_cmacro;
    492   1.1  mrg   bool mi_valid;
    493   1.1  mrg 
    494   1.1  mrg   /* Lexing.  */
    495   1.1  mrg   cpp_token *cur_token;
    496   1.1  mrg   tokenrun base_run, *cur_run;
    497   1.1  mrg   unsigned int lookaheads;
    498   1.1  mrg 
    499   1.1  mrg   /* Nonzero prevents the lexer from re-using the token runs.  */
    500   1.1  mrg   unsigned int keep_tokens;
    501   1.1  mrg 
    502   1.1  mrg   /* Buffer to hold macro definition string.  */
    503   1.1  mrg   unsigned char *macro_buffer;
    504   1.1  mrg   unsigned int macro_buffer_len;
    505   1.1  mrg 
    506   1.1  mrg   /* Descriptor for converting from the source character set to the
    507   1.1  mrg      execution character set.  */
    508   1.1  mrg   struct cset_converter narrow_cset_desc;
    509   1.1  mrg 
    510   1.1  mrg   /* Descriptor for converting from the source character set to the
    511   1.1  mrg      UTF-8 execution character set.  */
    512   1.1  mrg   struct cset_converter utf8_cset_desc;
    513   1.1  mrg 
    514   1.1  mrg   /* Descriptor for converting from the source character set to the
    515   1.1  mrg      UTF-16 execution character set.  */
    516   1.1  mrg   struct cset_converter char16_cset_desc;
    517   1.1  mrg 
    518   1.1  mrg   /* Descriptor for converting from the source character set to the
    519   1.1  mrg      UTF-32 execution character set.  */
    520   1.1  mrg   struct cset_converter char32_cset_desc;
    521   1.1  mrg 
    522   1.1  mrg   /* Descriptor for converting from the source character set to the
    523   1.1  mrg      wide execution character set.  */
    524   1.1  mrg   struct cset_converter wide_cset_desc;
    525   1.1  mrg 
    526   1.1  mrg   /* Date and time text.  Calculated together if either is requested.  */
    527   1.1  mrg   const unsigned char *date;
    528   1.1  mrg   const unsigned char *time;
    529   1.1  mrg 
    530  1.12  mrg   /* Time stamp, set idempotently lazily.  */
    531  1.12  mrg   time_t time_stamp;
    532  1.12  mrg   int time_stamp_kind; /* Or errno.  */
    533   1.6  mrg 
    534  1.12  mrg   /* A token forcing paste avoidance, and one demarking macro arguments.  */
    535   1.1  mrg   cpp_token avoid_paste;
    536  1.12  mrg   cpp_token endarg;
    537   1.1  mrg 
    538  1.12  mrg   /* Opaque handle to the dependencies of mkdeps.cc.  */
    539  1.11  mrg   class mkdeps *deps;
    540   1.1  mrg 
    541   1.1  mrg   /* Obstack holding all macro hash nodes.  This never shrinks.
    542  1.12  mrg      See identifiers.cc */
    543   1.1  mrg   struct obstack hash_ob;
    544   1.1  mrg 
    545   1.1  mrg   /* Obstack holding buffer and conditional structures.  This is a
    546  1.12  mrg      real stack.  See directives.cc.  */
    547   1.1  mrg   struct obstack buffer_ob;
    548   1.1  mrg 
    549   1.1  mrg   /* Pragma table - dynamic, because a library user can add to the
    550   1.1  mrg      list of recognized pragmas.  */
    551   1.1  mrg   struct pragma_entry *pragmas;
    552   1.1  mrg 
    553   1.1  mrg   /* Call backs to cpplib client.  */
    554   1.1  mrg   struct cpp_callbacks cb;
    555   1.1  mrg 
    556   1.1  mrg   /* Identifier hash table.  */
    557   1.1  mrg   struct ht *hash_table;
    558   1.1  mrg 
    559  1.13  mrg   /* Identifier ancillary data hash table.  */
    560  1.13  mrg   struct ht *extra_hash_table;
    561  1.13  mrg 
    562   1.1  mrg   /* Expression parser stack.  */
    563   1.1  mrg   struct op *op_stack, *op_limit;
    564   1.1  mrg 
    565   1.1  mrg   /* User visible options.  */
    566   1.1  mrg   struct cpp_options opts;
    567   1.1  mrg 
    568   1.1  mrg   /* Special nodes - identifiers with predefined significance to the
    569   1.1  mrg      preprocessor.  */
    570   1.1  mrg   struct spec_nodes spec_nodes;
    571   1.1  mrg 
    572   1.1  mrg   /* Whether cpplib owns the hashtable.  */
    573  1.13  mrg   bool our_hashtable, our_extra_hashtable;
    574   1.1  mrg 
    575   1.1  mrg   /* Traditional preprocessing output buffer (a logical line).  */
    576   1.1  mrg   struct
    577   1.1  mrg   {
    578   1.1  mrg     unsigned char *base;
    579   1.1  mrg     unsigned char *limit;
    580   1.1  mrg     unsigned char *cur;
    581  1.10  mrg     location_t first_line;
    582   1.1  mrg   } out;
    583   1.1  mrg 
    584  1.12  mrg   /* Used for buffer overlays by traditional.cc.  */
    585   1.1  mrg   const unsigned char *saved_cur, *saved_rlimit, *saved_line_base;
    586   1.1  mrg 
    587   1.1  mrg   /* A saved list of the defined macros, for dependency checking
    588   1.1  mrg      of precompiled headers.  */
    589   1.1  mrg   struct cpp_savedstate *savedstate;
    590   1.1  mrg 
    591   1.1  mrg   /* Next value of __COUNTER__ macro. */
    592   1.1  mrg   unsigned int counter;
    593   1.1  mrg 
    594   1.1  mrg   /* Table of comments, when state.save_comments is true.  */
    595   1.1  mrg   cpp_comment_table comments;
    596   1.1  mrg 
    597   1.1  mrg   /* List of saved macros by push_macro.  */
    598   1.1  mrg   struct def_pragma_macro *pushed_macros;
    599   1.3  mrg 
    600  1.10  mrg   /* If non-zero, the lexer will use this location for the next token
    601   1.3  mrg      instead of getting a location from the linemap.  */
    602  1.10  mrg   location_t forced_token_location;
    603  1.12  mrg 
    604  1.12  mrg   /* Location identifying the main source file -- intended to be line
    605  1.12  mrg      zero of said file.  */
    606  1.12  mrg   location_t main_loc;
    607  1.12  mrg 
    608  1.12  mrg   /* Returns true iff we should warn about UTF-8 bidirectional control
    609  1.12  mrg      characters.  */
    610  1.12  mrg   bool warn_bidi_p () const
    611  1.12  mrg   {
    612  1.12  mrg     return (CPP_OPTION (this, cpp_warn_bidirectional)
    613  1.12  mrg 	    & (bidirectional_unpaired|bidirectional_any));
    614  1.12  mrg   }
    615   1.1  mrg };
    616   1.1  mrg 
    617   1.1  mrg /* Character classes.  Based on the more primitive macros in safe-ctype.h.
    618   1.1  mrg    If the definition of `numchar' looks odd to you, please look up the
    619   1.1  mrg    definition of a pp-number in the C standard [section 6.4.8 of C99].
    620   1.1  mrg 
    621   1.1  mrg    In the unlikely event that characters other than \r and \n enter
    622  1.12  mrg    the set is_vspace, the macro handle_newline() in lex.cc must be
    623   1.1  mrg    updated.  */
    624   1.1  mrg #define _dollar_ok(x)	((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
    625   1.1  mrg 
    626   1.1  mrg #define is_idchar(x)	(ISIDNUM(x) || _dollar_ok(x))
    627   1.1  mrg #define is_numchar(x)	ISIDNUM(x)
    628   1.1  mrg #define is_idstart(x)	(ISIDST(x) || _dollar_ok(x))
    629   1.1  mrg #define is_numstart(x)	ISDIGIT(x)
    630   1.1  mrg #define is_hspace(x)	ISBLANK(x)
    631   1.1  mrg #define is_vspace(x)	IS_VSPACE(x)
    632   1.1  mrg #define is_nvspace(x)	IS_NVSPACE(x)
    633   1.1  mrg #define is_space(x)	IS_SPACE_OR_NUL(x)
    634   1.1  mrg 
    635  1.10  mrg #define SEEN_EOL() (pfile->cur_token[-1].type == CPP_EOF)
    636  1.10  mrg 
    637   1.1  mrg /* This table is constant if it can be initialized at compile time,
    638   1.1  mrg    which is the case if cpp was compiled with GCC >=2.7, or another
    639   1.1  mrg    compiler that supports C99.  */
    640   1.1  mrg #if HAVE_DESIGNATED_INITIALIZERS
    641   1.1  mrg extern const unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
    642   1.1  mrg #else
    643   1.1  mrg extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
    644   1.1  mrg #endif
    645   1.1  mrg 
    646  1.10  mrg #if !defined (HAVE_UCHAR) && !defined (IN_GCC)
    647  1.10  mrg typedef unsigned char uchar;
    648  1.10  mrg #endif
    649  1.10  mrg 
    650  1.10  mrg #define UC (const uchar *)  /* Intended use: UC"string" */
    651  1.10  mrg 
    652  1.12  mrg /* Accessors.  */
    653   1.1  mrg 
    654  1.12  mrg inline int
    655  1.12  mrg _cpp_in_system_header (cpp_reader *pfile)
    656   1.1  mrg {
    657   1.1  mrg   return pfile->buffer ? pfile->buffer->sysp : 0;
    658   1.1  mrg }
    659   1.3  mrg #define CPP_PEDANTIC(PF) CPP_OPTION (PF, cpp_pedantic)
    660   1.3  mrg #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, cpp_warn_traditional)
    661   1.1  mrg 
    662  1.12  mrg /* Return true if we're in the main file (unless it's considered to be
    663  1.12  mrg    an include file in its own right.  */
    664  1.12  mrg inline int
    665  1.12  mrg _cpp_in_main_source_file (cpp_reader *pfile)
    666   1.1  mrg {
    667  1.12  mrg   return (!CPP_OPTION (pfile, main_search)
    668  1.12  mrg 	  && pfile->buffer->file == pfile->main_file);
    669   1.1  mrg }
    670   1.1  mrg 
    671  1.11  mrg /* True if NODE is a macro for the purposes of ifdef, defined etc.  */
    672  1.11  mrg inline bool _cpp_defined_macro_p (cpp_hashnode *node)
    673  1.11  mrg {
    674  1.11  mrg   /* Do not treat conditional macros as being defined.  This is due to
    675  1.11  mrg      the powerpc port using conditional macros for 'vector', 'bool',
    676  1.11  mrg      and 'pixel' to act as conditional keywords.  This messes up tests
    677  1.11  mrg      like #ifndef bool.  */
    678  1.11  mrg   return cpp_macro_p (node) && !(node->flags & NODE_CONDITIONAL);
    679  1.11  mrg }
    680  1.11  mrg 
    681  1.12  mrg /* In macro.cc */
    682  1.12  mrg extern bool _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
    683  1.12  mrg 				   location_t);
    684  1.12  mrg inline bool _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node,
    685  1.12  mrg 					 location_t loc)
    686  1.10  mrg {
    687  1.10  mrg   if (!(node->flags & NODE_USED))
    688  1.12  mrg     return _cpp_notify_macro_use (pfile, node, loc);
    689  1.12  mrg   return true;
    690  1.10  mrg }
    691  1.10  mrg extern cpp_macro *_cpp_new_macro (cpp_reader *, cpp_macro_kind, void *);
    692   1.1  mrg extern void _cpp_free_definition (cpp_hashnode *);
    693  1.13  mrg extern bool _cpp_create_definition (cpp_reader *, cpp_hashnode *, location_t);
    694   1.1  mrg extern void _cpp_pop_context (cpp_reader *);
    695   1.1  mrg extern void _cpp_push_text_context (cpp_reader *, cpp_hashnode *,
    696   1.1  mrg 				    const unsigned char *, size_t);
    697  1.10  mrg extern bool _cpp_save_parameter (cpp_reader *, unsigned, cpp_hashnode *,
    698   1.4  mrg 				 cpp_hashnode *);
    699  1.10  mrg extern void _cpp_unsave_parameters (cpp_reader *, unsigned);
    700   1.1  mrg extern bool _cpp_arguments_ok (cpp_reader *, cpp_macro *, const cpp_hashnode *,
    701   1.1  mrg 			       unsigned int);
    702   1.1  mrg extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *,
    703   1.5  mrg 						     cpp_hashnode *,
    704  1.10  mrg 						     location_t = 0);
    705   1.1  mrg extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *);
    706   1.1  mrg extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *,
    707   1.1  mrg 				     const cpp_token *, unsigned int);
    708   1.1  mrg extern void _cpp_backup_tokens_direct (cpp_reader *, unsigned int);
    709   1.1  mrg 
    710  1.12  mrg /* In identifiers.cc */
    711  1.13  mrg extern void
    712  1.13  mrg _cpp_init_hashtable (cpp_reader *, cpp_hash_table *, cpp_hash_table *);
    713   1.1  mrg extern void _cpp_destroy_hashtable (cpp_reader *);
    714   1.1  mrg 
    715  1.12  mrg /* In files.cc */
    716  1.12  mrg enum _cpp_find_file_kind
    717  1.12  mrg   { _cpp_FFK_NORMAL, _cpp_FFK_FAKE, _cpp_FFK_PRE_INCLUDE, _cpp_FFK_HAS_INCLUDE };
    718   1.1  mrg extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *,
    719  1.12  mrg 				  int angle, _cpp_find_file_kind, location_t);
    720   1.1  mrg extern bool _cpp_find_failed (_cpp_file *);
    721   1.1  mrg extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *);
    722  1.12  mrg extern const char *_cpp_find_header_unit (cpp_reader *, const char *file,
    723  1.12  mrg 					  bool angle_p,  location_t);
    724   1.1  mrg extern void _cpp_fake_include (cpp_reader *, const char *);
    725  1.11  mrg extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, include_type, location_t);
    726   1.1  mrg extern bool _cpp_stack_include (cpp_reader *, const char *, int,
    727  1.10  mrg 				enum include_type, location_t);
    728   1.1  mrg extern int _cpp_compare_file_date (cpp_reader *, const char *, int);
    729   1.1  mrg extern void _cpp_report_missing_guards (cpp_reader *);
    730   1.1  mrg extern void _cpp_init_files (cpp_reader *);
    731   1.1  mrg extern void _cpp_cleanup_files (cpp_reader *);
    732   1.3  mrg extern void _cpp_pop_file_buffer (cpp_reader *, struct _cpp_file *,
    733   1.3  mrg 				  const unsigned char *);
    734   1.1  mrg extern bool _cpp_save_file_entries (cpp_reader *pfile, FILE *f);
    735   1.1  mrg extern bool _cpp_read_file_entries (cpp_reader *, FILE *);
    736   1.3  mrg extern const char *_cpp_get_file_name (_cpp_file *);
    737   1.1  mrg extern struct stat *_cpp_get_file_stat (_cpp_file *);
    738   1.4  mrg extern bool _cpp_has_header (cpp_reader *, const char *, int,
    739   1.4  mrg 			     enum include_type);
    740   1.1  mrg 
    741  1.12  mrg /* In expr.cc */
    742   1.1  mrg extern bool _cpp_parse_expr (cpp_reader *, bool);
    743   1.1  mrg extern struct op *_cpp_expand_op_stack (cpp_reader *);
    744   1.1  mrg 
    745  1.12  mrg /* In lex.cc */
    746   1.1  mrg extern void _cpp_process_line_notes (cpp_reader *, int);
    747   1.1  mrg extern void _cpp_clean_line (cpp_reader *);
    748   1.1  mrg extern bool _cpp_get_fresh_line (cpp_reader *);
    749   1.1  mrg extern bool _cpp_skip_block_comment (cpp_reader *);
    750   1.1  mrg extern cpp_token *_cpp_temp_token (cpp_reader *);
    751   1.1  mrg extern const cpp_token *_cpp_lex_token (cpp_reader *);
    752   1.1  mrg extern cpp_token *_cpp_lex_direct (cpp_reader *);
    753   1.4  mrg extern unsigned char *_cpp_spell_ident_ucns (unsigned char *, cpp_hashnode *);
    754   1.1  mrg extern int _cpp_equiv_tokens (const cpp_token *, const cpp_token *);
    755   1.1  mrg extern void _cpp_init_tokenrun (tokenrun *, unsigned int);
    756   1.1  mrg extern cpp_hashnode *_cpp_lex_identifier (cpp_reader *, const char *);
    757   1.3  mrg extern int _cpp_remaining_tokens_num_in_context (cpp_context *);
    758   1.3  mrg extern void _cpp_init_lexer (void);
    759  1.10  mrg static inline void *_cpp_reserve_room (cpp_reader *pfile, size_t have,
    760  1.10  mrg 				       size_t extra)
    761  1.10  mrg {
    762  1.10  mrg   if (BUFF_ROOM (pfile->a_buff) < (have + extra))
    763  1.10  mrg     _cpp_extend_buff (pfile, &pfile->a_buff, extra);
    764  1.10  mrg   return BUFF_FRONT (pfile->a_buff);
    765  1.10  mrg }
    766  1.10  mrg extern void *_cpp_commit_buff (cpp_reader *pfile, size_t size);
    767   1.1  mrg 
    768  1.12  mrg /* In init.cc.  */
    769   1.1  mrg extern void _cpp_maybe_push_include_file (cpp_reader *);
    770   1.1  mrg extern const char *cpp_named_operator2name (enum cpp_ttype type);
    771   1.9  mrg extern void _cpp_restore_special_builtin (cpp_reader *pfile,
    772   1.9  mrg 					  struct def_pragma_macro *);
    773   1.1  mrg 
    774  1.12  mrg /* In directives.cc */
    775   1.1  mrg extern int _cpp_test_assertion (cpp_reader *, unsigned int *);
    776  1.11  mrg extern int _cpp_handle_directive (cpp_reader *, bool);
    777   1.1  mrg extern void _cpp_define_builtin (cpp_reader *, const char *);
    778   1.1  mrg extern char ** _cpp_save_pragma_names (cpp_reader *);
    779   1.1  mrg extern void _cpp_restore_pragma_names (cpp_reader *, char **);
    780  1.10  mrg extern int _cpp_do__Pragma (cpp_reader *, location_t);
    781   1.1  mrg extern void _cpp_init_directives (cpp_reader *);
    782   1.1  mrg extern void _cpp_init_internal_pragmas (cpp_reader *);
    783   1.1  mrg extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
    784   1.1  mrg 				 linenum_type, unsigned int);
    785   1.1  mrg extern void _cpp_pop_buffer (cpp_reader *);
    786   1.4  mrg extern char *_cpp_bracket_include (cpp_reader *);
    787   1.1  mrg 
    788  1.12  mrg /* In errors.cc  */
    789  1.12  mrg extern location_t cpp_diagnostic_get_current_location (cpp_reader *);
    790   1.1  mrg 
    791  1.12  mrg /* In traditional.cc.  */
    792   1.4  mrg extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *, bool);
    793   1.1  mrg extern bool _cpp_read_logical_line_trad (cpp_reader *);
    794   1.1  mrg extern void _cpp_overlay_buffer (cpp_reader *pfile, const unsigned char *,
    795   1.1  mrg 				 size_t);
    796   1.1  mrg extern void _cpp_remove_overlay (cpp_reader *);
    797  1.10  mrg extern cpp_macro *_cpp_create_trad_definition (cpp_reader *);
    798   1.1  mrg extern bool _cpp_expansions_different_trad (const cpp_macro *,
    799   1.1  mrg 					    const cpp_macro *);
    800   1.1  mrg extern unsigned char *_cpp_copy_replacement_text (const cpp_macro *,
    801   1.1  mrg 						  unsigned char *);
    802   1.1  mrg extern size_t _cpp_replacement_text_len (const cpp_macro *);
    803   1.1  mrg 
    804  1.12  mrg /* In charset.cc.  */
    805   1.1  mrg 
    806   1.1  mrg /* The normalization state at this point in the sequence.
    807   1.1  mrg    It starts initialized to all zeros, and at the end
    808   1.1  mrg    'level' is the normalization level of the sequence.  */
    809   1.1  mrg 
    810   1.1  mrg struct normalize_state
    811   1.1  mrg {
    812   1.4  mrg   /* The previous starter character.  */
    813   1.1  mrg   cppchar_t previous;
    814   1.4  mrg   /* The combining class of the previous character (whether or not a
    815   1.4  mrg      starter).  */
    816   1.1  mrg   unsigned char prev_class;
    817   1.1  mrg   /* The lowest normalization level so far.  */
    818   1.1  mrg   enum cpp_normalize_level level;
    819   1.1  mrg };
    820   1.1  mrg #define INITIAL_NORMALIZE_STATE { 0, 0, normalized_KC }
    821   1.1  mrg #define NORMALIZE_STATE_RESULT(st) ((st)->level)
    822   1.1  mrg 
    823   1.4  mrg /* We saw a character C that matches ISIDNUM(), update a
    824   1.1  mrg    normalize_state appropriately.  */
    825   1.4  mrg #define NORMALIZE_STATE_UPDATE_IDNUM(st, c)	\
    826   1.4  mrg   ((st)->previous = (c), (st)->prev_class = 0)
    827   1.1  mrg 
    828   1.5  mrg extern bool _cpp_valid_ucn (cpp_reader *, const unsigned char **,
    829   1.5  mrg 			    const unsigned char *, int,
    830   1.5  mrg 			    struct normalize_state *state,
    831   1.6  mrg 			    cppchar_t *,
    832   1.6  mrg 			    source_range *char_range,
    833   1.6  mrg 			    cpp_string_location_reader *loc_reader);
    834  1.11  mrg 
    835  1.11  mrg extern bool _cpp_valid_utf8 (cpp_reader *pfile,
    836  1.11  mrg 			     const uchar **pstr,
    837  1.11  mrg 			     const uchar *limit,
    838  1.11  mrg 			     int identifier_pos,
    839  1.11  mrg 			     struct normalize_state *nst,
    840  1.11  mrg 			     cppchar_t *cp);
    841  1.11  mrg 
    842   1.1  mrg extern void _cpp_destroy_iconv (cpp_reader *);
    843   1.1  mrg extern unsigned char *_cpp_convert_input (cpp_reader *, const char *,
    844   1.1  mrg 					  unsigned char *, size_t, size_t,
    845   1.1  mrg 					  const unsigned char **, off_t *);
    846   1.1  mrg extern const char *_cpp_default_encoding (void);
    847   1.1  mrg extern cpp_hashnode * _cpp_interpret_identifier (cpp_reader *pfile,
    848   1.1  mrg 						 const unsigned char *id,
    849   1.1  mrg 						 size_t len);
    850   1.1  mrg 
    851   1.1  mrg /* Utility routines and macros.  */
    852   1.1  mrg #define DSC(str) (const unsigned char *)str, sizeof str - 1
    853   1.1  mrg 
    854   1.1  mrg /* These are inline functions instead of macros so we can get type
    855   1.1  mrg    checking.  */
    856   1.1  mrg static inline int ustrcmp (const unsigned char *, const unsigned char *);
    857   1.1  mrg static inline int ustrncmp (const unsigned char *, const unsigned char *,
    858   1.1  mrg 			    size_t);
    859   1.1  mrg static inline size_t ustrlen (const unsigned char *);
    860   1.3  mrg static inline const unsigned char *uxstrdup (const unsigned char *);
    861   1.3  mrg static inline const unsigned char *ustrchr (const unsigned char *, int);
    862   1.1  mrg static inline int ufputs (const unsigned char *, FILE *);
    863   1.1  mrg 
    864   1.1  mrg /* Use a const char for the second parameter since it is usually a literal.  */
    865   1.1  mrg static inline int ustrcspn (const unsigned char *, const char *);
    866   1.1  mrg 
    867   1.1  mrg static inline int
    868   1.1  mrg ustrcmp (const unsigned char *s1, const unsigned char *s2)
    869   1.1  mrg {
    870   1.1  mrg   return strcmp ((const char *)s1, (const char *)s2);
    871   1.1  mrg }
    872   1.1  mrg 
    873   1.1  mrg static inline int
    874   1.1  mrg ustrncmp (const unsigned char *s1, const unsigned char *s2, size_t n)
    875   1.1  mrg {
    876   1.1  mrg   return strncmp ((const char *)s1, (const char *)s2, n);
    877   1.1  mrg }
    878   1.1  mrg 
    879   1.1  mrg static inline int
    880   1.1  mrg ustrcspn (const unsigned char *s1, const char *s2)
    881   1.1  mrg {
    882   1.1  mrg   return strcspn ((const char *)s1, s2);
    883   1.1  mrg }
    884   1.1  mrg 
    885   1.1  mrg static inline size_t
    886   1.1  mrg ustrlen (const unsigned char *s1)
    887   1.1  mrg {
    888   1.1  mrg   return strlen ((const char *)s1);
    889   1.1  mrg }
    890   1.1  mrg 
    891   1.3  mrg static inline const unsigned char *
    892   1.1  mrg uxstrdup (const unsigned char *s1)
    893   1.1  mrg {
    894   1.3  mrg   return (const unsigned char *) xstrdup ((const char *)s1);
    895   1.1  mrg }
    896   1.1  mrg 
    897   1.3  mrg static inline const unsigned char *
    898   1.1  mrg ustrchr (const unsigned char *s1, int c)
    899   1.1  mrg {
    900   1.3  mrg   return (const unsigned char *) strchr ((const char *)s1, c);
    901   1.1  mrg }
    902   1.1  mrg 
    903   1.1  mrg static inline int
    904   1.1  mrg ufputs (const unsigned char *s, FILE *f)
    905   1.1  mrg {
    906   1.1  mrg   return fputs ((const char *)s, f);
    907   1.1  mrg }
    908   1.1  mrg 
    909  1.12  mrg /* In line-map.cc.  */
    910   1.3  mrg 
    911   1.3  mrg /* Create and return a virtual location for a token that is part of a
    912   1.3  mrg    macro expansion-list at a macro expansion point.  See the comment
    913   1.3  mrg    inside struct line_map_macro to see what an expansion-list exactly
    914   1.3  mrg    is.
    915   1.3  mrg 
    916   1.3  mrg    A call to this function must come after a call to
    917   1.3  mrg    linemap_enter_macro.
    918   1.3  mrg 
    919   1.3  mrg    MAP is the map into which the source location is created.  TOKEN_NO
    920   1.3  mrg    is the index of the token in the macro replacement-list, starting
    921   1.3  mrg    at number 0.
    922   1.3  mrg 
    923   1.3  mrg    ORIG_LOC is the location of the token outside of this macro
    924   1.3  mrg    expansion.  If the token comes originally from the macro
    925   1.3  mrg    definition, it is the locus in the macro definition; otherwise it
    926   1.3  mrg    is a location in the context of the caller of this macro expansion
    927   1.3  mrg    (which is a virtual location or a source location if the caller is
    928   1.3  mrg    itself a macro expansion or not).
    929   1.3  mrg 
    930   1.3  mrg    MACRO_DEFINITION_LOC is the location in the macro definition,
    931   1.3  mrg    either of the token itself or of a macro parameter that it
    932   1.3  mrg    replaces.  */
    933  1.10  mrg location_t linemap_add_macro_token (const line_map_macro *,
    934  1.10  mrg 				    unsigned int,
    935  1.10  mrg 				    location_t,
    936  1.10  mrg 				    location_t);
    937   1.3  mrg 
    938   1.3  mrg /* Return the source line number corresponding to source location
    939   1.3  mrg    LOCATION.  SET is the line map set LOCATION comes from.  If
    940   1.3  mrg    LOCATION is the location of token that is part of the
    941   1.3  mrg    expansion-list of a macro expansion return the line number of the
    942   1.3  mrg    macro expansion point.  */
    943  1.13  mrg int linemap_get_expansion_line (const line_maps *,
    944  1.10  mrg 				location_t);
    945   1.3  mrg 
    946   1.3  mrg /* Return the path of the file corresponding to source code location
    947   1.3  mrg    LOCATION.
    948   1.3  mrg 
    949   1.3  mrg    If LOCATION is the location of a token that is part of the
    950   1.3  mrg    replacement-list of a macro expansion return the file path of the
    951   1.3  mrg    macro expansion point.
    952   1.3  mrg 
    953   1.3  mrg    SET is the line map set LOCATION comes from.  */
    954  1.13  mrg const char* linemap_get_expansion_filename (const line_maps *,
    955  1.10  mrg 					    location_t);
    956   1.3  mrg 
    957  1.12  mrg /* A subclass of rich_location for emitting a diagnostic
    958  1.12  mrg    at the current location of the reader, but flagging
    959  1.12  mrg    it with set_escape_on_output (true).  */
    960  1.12  mrg class encoding_rich_location : public rich_location
    961  1.12  mrg {
    962  1.12  mrg  public:
    963  1.12  mrg   encoding_rich_location (cpp_reader *pfile)
    964  1.12  mrg   : rich_location (pfile->line_table,
    965  1.12  mrg 		   cpp_diagnostic_get_current_location (pfile))
    966  1.12  mrg   {
    967  1.12  mrg     set_escape_on_output (true);
    968  1.12  mrg   }
    969  1.12  mrg 
    970  1.12  mrg   encoding_rich_location (cpp_reader *pfile, location_t loc)
    971  1.12  mrg   : rich_location (pfile->line_table, loc)
    972  1.12  mrg   {
    973  1.12  mrg     set_escape_on_output (true);
    974  1.12  mrg   }
    975  1.12  mrg };
    976  1.12  mrg 
    977   1.1  mrg #ifdef __cplusplus
    978   1.1  mrg }
    979   1.1  mrg #endif
    980   1.1  mrg 
    981   1.1  mrg #endif /* ! LIBCPP_INTERNAL_H */
    982