cpplib.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. /* Definitions for CPP library.
  2. Copyright (C) 1995-2015 Free Software Foundation, Inc.
  3. Written by Per Bothner, 1994-95.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 3, or (at your option) any
  7. later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>.
  15. In other words, you are welcome to use, share and improve this program.
  16. You are forbidden to forbid anyone else to use, share and improve
  17. what you give them. Help stamp out software-hoarding! */
  18. #ifndef LIBCPP_CPPLIB_H
  19. #define LIBCPP_CPPLIB_H
  20. #include <sys/types.h>
  21. #include "symtab.h"
  22. #include "line-map.h"
  23. typedef struct cpp_reader cpp_reader;
  24. typedef struct cpp_buffer cpp_buffer;
  25. typedef struct cpp_options cpp_options;
  26. typedef struct cpp_token cpp_token;
  27. typedef struct cpp_string cpp_string;
  28. typedef struct cpp_hashnode cpp_hashnode;
  29. typedef struct cpp_macro cpp_macro;
  30. typedef struct cpp_callbacks cpp_callbacks;
  31. typedef struct cpp_dir cpp_dir;
  32. struct answer;
  33. struct _cpp_file;
  34. /* The first three groups, apart from '=', can appear in preprocessor
  35. expressions (+= and -= are used to indicate unary + and - resp.).
  36. This allows a lookup table to be implemented in _cpp_parse_expr.
  37. The first group, to CPP_LAST_EQ, can be immediately followed by an
  38. '='. The lexer needs operators ending in '=', like ">>=", to be in
  39. the same order as their counterparts without the '=', like ">>".
  40. See the cpp_operator table optab in expr.c if you change the order or
  41. add or remove anything in the first group. */
  42. #define TTYPE_TABLE \
  43. OP(EQ, "=") \
  44. OP(NOT, "!") \
  45. OP(GREATER, ">") /* compare */ \
  46. OP(LESS, "<") \
  47. OP(PLUS, "+") /* math */ \
  48. OP(MINUS, "-") \
  49. OP(MULT, "*") \
  50. OP(DIV, "/") \
  51. OP(MOD, "%") \
  52. OP(AND, "&") /* bit ops */ \
  53. OP(OR, "|") \
  54. OP(XOR, "^") \
  55. OP(RSHIFT, ">>") \
  56. OP(LSHIFT, "<<") \
  57. \
  58. OP(COMPL, "~") \
  59. OP(AND_AND, "&&") /* logical */ \
  60. OP(OR_OR, "||") \
  61. OP(QUERY, "?") \
  62. OP(COLON, ":") \
  63. OP(COMMA, ",") /* grouping */ \
  64. OP(OPEN_PAREN, "(") \
  65. OP(CLOSE_PAREN, ")") \
  66. TK(EOF, NONE) \
  67. OP(EQ_EQ, "==") /* compare */ \
  68. OP(NOT_EQ, "!=") \
  69. OP(GREATER_EQ, ">=") \
  70. OP(LESS_EQ, "<=") \
  71. \
  72. /* These two are unary + / - in preprocessor expressions. */ \
  73. OP(PLUS_EQ, "+=") /* math */ \
  74. OP(MINUS_EQ, "-=") \
  75. \
  76. OP(MULT_EQ, "*=") \
  77. OP(DIV_EQ, "/=") \
  78. OP(MOD_EQ, "%=") \
  79. OP(AND_EQ, "&=") /* bit ops */ \
  80. OP(OR_EQ, "|=") \
  81. OP(XOR_EQ, "^=") \
  82. OP(RSHIFT_EQ, ">>=") \
  83. OP(LSHIFT_EQ, "<<=") \
  84. /* Digraphs together, beginning with CPP_FIRST_DIGRAPH. */ \
  85. OP(HASH, "#") /* digraphs */ \
  86. OP(PASTE, "##") \
  87. OP(OPEN_SQUARE, "[") \
  88. OP(CLOSE_SQUARE, "]") \
  89. OP(OPEN_BRACE, "{") \
  90. OP(CLOSE_BRACE, "}") \
  91. /* The remainder of the punctuation. Order is not significant. */ \
  92. OP(SEMICOLON, ";") /* structure */ \
  93. OP(ELLIPSIS, "...") \
  94. OP(PLUS_PLUS, "++") /* increment */ \
  95. OP(MINUS_MINUS, "--") \
  96. OP(DEREF, "->") /* accessors */ \
  97. OP(DOT, ".") \
  98. OP(SCOPE, "::") \
  99. OP(DEREF_STAR, "->*") \
  100. OP(DOT_STAR, ".*") \
  101. OP(ATSIGN, "@") /* used in Objective-C */ \
  102. \
  103. TK(NAME, IDENT) /* word */ \
  104. TK(AT_NAME, IDENT) /* @word - Objective-C */ \
  105. TK(NUMBER, LITERAL) /* 34_be+ta */ \
  106. \
  107. TK(CHAR, LITERAL) /* 'char' */ \
  108. TK(WCHAR, LITERAL) /* L'char' */ \
  109. TK(CHAR16, LITERAL) /* u'char' */ \
  110. TK(CHAR32, LITERAL) /* U'char' */ \
  111. TK(OTHER, LITERAL) /* stray punctuation */ \
  112. \
  113. TK(STRING, LITERAL) /* "string" */ \
  114. TK(WSTRING, LITERAL) /* L"string" */ \
  115. TK(STRING16, LITERAL) /* u"string" */ \
  116. TK(STRING32, LITERAL) /* U"string" */ \
  117. TK(UTF8STRING, LITERAL) /* u8"string" */ \
  118. TK(OBJC_STRING, LITERAL) /* @"string" - Objective-C */ \
  119. TK(HEADER_NAME, LITERAL) /* <stdio.h> in #include */ \
  120. \
  121. TK(CHAR_USERDEF, LITERAL) /* 'char'_suffix - C++-0x */ \
  122. TK(WCHAR_USERDEF, LITERAL) /* L'char'_suffix - C++-0x */ \
  123. TK(CHAR16_USERDEF, LITERAL) /* u'char'_suffix - C++-0x */ \
  124. TK(CHAR32_USERDEF, LITERAL) /* U'char'_suffix - C++-0x */ \
  125. TK(STRING_USERDEF, LITERAL) /* "string"_suffix - C++-0x */ \
  126. TK(WSTRING_USERDEF, LITERAL) /* L"string"_suffix - C++-0x */ \
  127. TK(STRING16_USERDEF, LITERAL) /* u"string"_suffix - C++-0x */ \
  128. TK(STRING32_USERDEF, LITERAL) /* U"string"_suffix - C++-0x */ \
  129. TK(UTF8STRING_USERDEF,LITERAL) /* u8"string"_suffix - C++-0x */ \
  130. \
  131. TK(COMMENT, LITERAL) /* Only if output comments. */ \
  132. /* SPELL_LITERAL happens to DTRT. */ \
  133. TK(MACRO_ARG, NONE) /* Macro argument. */ \
  134. TK(PRAGMA, NONE) /* Only for deferred pragmas. */ \
  135. TK(PRAGMA_EOL, NONE) /* End-of-line for deferred pragmas. */ \
  136. TK(PADDING, NONE) /* Whitespace for -E. */
  137. #define OP(e, s) CPP_ ## e,
  138. #define TK(e, s) CPP_ ## e,
  139. enum cpp_ttype
  140. {
  141. TTYPE_TABLE
  142. N_TTYPES,
  143. /* A token type for keywords, as opposed to ordinary identifiers. */
  144. CPP_KEYWORD,
  145. /* Positions in the table. */
  146. CPP_LAST_EQ = CPP_LSHIFT,
  147. CPP_FIRST_DIGRAPH = CPP_HASH,
  148. CPP_LAST_PUNCTUATOR= CPP_ATSIGN,
  149. CPP_LAST_CPP_OP = CPP_LESS_EQ
  150. };
  151. #undef OP
  152. #undef TK
  153. /* C language kind, used when calling cpp_create_reader. */
  154. enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11,
  155. CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11,
  156. CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
  157. CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX1Z, CLK_CXX1Z, CLK_ASM};
  158. /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */
  159. struct GTY(()) cpp_string {
  160. unsigned int len;
  161. const unsigned char *text;
  162. };
  163. /* Flags for the cpp_token structure. */
  164. #define PREV_WHITE (1 << 0) /* If whitespace before this token. */
  165. #define DIGRAPH (1 << 1) /* If it was a digraph. */
  166. #define STRINGIFY_ARG (1 << 2) /* If macro argument to be stringified. */
  167. #define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */
  168. #define NAMED_OP (1 << 4) /* C++ named operators. */
  169. #define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */
  170. #define BOL (1 << 6) /* Token at beginning of line. */
  171. #define PURE_ZERO (1 << 7) /* Single 0 digit, used by the C++ frontend,
  172. set in c-lex.c. */
  173. #define SP_DIGRAPH (1 << 8) /* # or ## token was a digraph. */
  174. #define SP_PREV_WHITE (1 << 9) /* If whitespace before a ##
  175. operator, or before this token
  176. after a # operator. */
  177. /* Specify which field, if any, of the cpp_token union is used. */
  178. enum cpp_token_fld_kind {
  179. CPP_TOKEN_FLD_NODE,
  180. CPP_TOKEN_FLD_SOURCE,
  181. CPP_TOKEN_FLD_STR,
  182. CPP_TOKEN_FLD_ARG_NO,
  183. CPP_TOKEN_FLD_TOKEN_NO,
  184. CPP_TOKEN_FLD_PRAGMA,
  185. CPP_TOKEN_FLD_NONE
  186. };
  187. /* A macro argument in the cpp_token union. */
  188. struct GTY(()) cpp_macro_arg {
  189. /* Argument number. */
  190. unsigned int arg_no;
  191. /* The original spelling of the macro argument token. */
  192. cpp_hashnode *
  193. GTY ((nested_ptr (union tree_node,
  194. "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
  195. "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
  196. spelling;
  197. };
  198. /* An identifier in the cpp_token union. */
  199. struct GTY(()) cpp_identifier {
  200. /* The canonical (UTF-8) spelling of the identifier. */
  201. cpp_hashnode *
  202. GTY ((nested_ptr (union tree_node,
  203. "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
  204. "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
  205. node;
  206. /* The original spelling of the identifier. */
  207. cpp_hashnode *
  208. GTY ((nested_ptr (union tree_node,
  209. "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
  210. "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
  211. spelling;
  212. };
  213. /* A preprocessing token. This has been carefully packed and should
  214. occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */
  215. struct GTY(()) cpp_token {
  216. source_location src_loc; /* Location of first char of token. */
  217. ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */
  218. unsigned short flags; /* flags - see above */
  219. union cpp_token_u
  220. {
  221. /* An identifier. */
  222. struct cpp_identifier GTY ((tag ("CPP_TOKEN_FLD_NODE"))) node;
  223. /* Inherit padding from this token. */
  224. cpp_token * GTY ((tag ("CPP_TOKEN_FLD_SOURCE"))) source;
  225. /* A string, or number. */
  226. struct cpp_string GTY ((tag ("CPP_TOKEN_FLD_STR"))) str;
  227. /* Argument no. (and original spelling) for a CPP_MACRO_ARG. */
  228. struct cpp_macro_arg GTY ((tag ("CPP_TOKEN_FLD_ARG_NO"))) macro_arg;
  229. /* Original token no. for a CPP_PASTE (from a sequence of
  230. consecutive paste tokens in a macro expansion). */
  231. unsigned int GTY ((tag ("CPP_TOKEN_FLD_TOKEN_NO"))) token_no;
  232. /* Caller-supplied identifier for a CPP_PRAGMA. */
  233. unsigned int GTY ((tag ("CPP_TOKEN_FLD_PRAGMA"))) pragma;
  234. } GTY ((desc ("cpp_token_val_index (&%1)"))) val;
  235. };
  236. /* Say which field is in use. */
  237. extern enum cpp_token_fld_kind cpp_token_val_index (const cpp_token *tok);
  238. /* A type wide enough to hold any multibyte source character.
  239. cpplib's character constant interpreter requires an unsigned type.
  240. Also, a typedef for the signed equivalent.
  241. The width of this type is capped at 32 bits; there do exist targets
  242. where wchar_t is 64 bits, but only in a non-default mode, and there
  243. would be no meaningful interpretation for a wchar_t value greater
  244. than 2^32 anyway -- the widest wide-character encoding around is
  245. ISO 10646, which stops at 2^31. */
  246. #if CHAR_BIT * SIZEOF_INT >= 32
  247. # define CPPCHAR_SIGNED_T int
  248. #elif CHAR_BIT * SIZEOF_LONG >= 32
  249. # define CPPCHAR_SIGNED_T long
  250. #else
  251. # error "Cannot find a least-32-bit signed integer type"
  252. #endif
  253. typedef unsigned CPPCHAR_SIGNED_T cppchar_t;
  254. typedef CPPCHAR_SIGNED_T cppchar_signed_t;
  255. /* Style of header dependencies to generate. */
  256. enum cpp_deps_style { DEPS_NONE = 0, DEPS_USER, DEPS_SYSTEM };
  257. /* The possible normalization levels, from most restrictive to least. */
  258. enum cpp_normalize_level {
  259. /* In NFKC. */
  260. normalized_KC = 0,
  261. /* In NFC. */
  262. normalized_C,
  263. /* In NFC, except for subsequences where being in NFC would make
  264. the identifier invalid. */
  265. normalized_identifier_C,
  266. /* Not normalized at all. */
  267. normalized_none
  268. };
  269. /* This structure is nested inside struct cpp_reader, and
  270. carries all the options visible to the command line. */
  271. struct cpp_options
  272. {
  273. /* Characters between tab stops. */
  274. unsigned int tabstop;
  275. /* The language we're preprocessing. */
  276. enum c_lang lang;
  277. /* Nonzero means use extra default include directories for C++. */
  278. unsigned char cplusplus;
  279. /* Nonzero means handle cplusplus style comments. */
  280. unsigned char cplusplus_comments;
  281. /* Nonzero means define __OBJC__, treat @ as a special token, use
  282. the OBJC[PLUS]_INCLUDE_PATH environment variable, and allow
  283. "#import". */
  284. unsigned char objc;
  285. /* Nonzero means don't copy comments into the output file. */
  286. unsigned char discard_comments;
  287. /* Nonzero means don't copy comments into the output file during
  288. macro expansion. */
  289. unsigned char discard_comments_in_macro_exp;
  290. /* Nonzero means process the ISO trigraph sequences. */
  291. unsigned char trigraphs;
  292. /* Nonzero means process the ISO digraph sequences. */
  293. unsigned char digraphs;
  294. /* Nonzero means to allow hexadecimal floats and LL suffixes. */
  295. unsigned char extended_numbers;
  296. /* Nonzero means process u/U prefix literals (UTF-16/32). */
  297. unsigned char uliterals;
  298. /* Nonzero means process r/R raw strings. If this is set, uliterals
  299. must be set as well. */
  300. unsigned char rliterals;
  301. /* Nonzero means print names of header files (-H). */
  302. unsigned char print_include_names;
  303. /* Nonzero means complain about deprecated features. */
  304. unsigned char cpp_warn_deprecated;
  305. /* Nonzero means warn if slash-star appears in a comment. */
  306. unsigned char warn_comments;
  307. /* Nonzero means to warn about __DATA__, __TIME__ and __TIMESTAMP__ usage. */
  308. unsigned char warn_date_time;
  309. /* Nonzero means warn if a user-supplied include directory does not
  310. exist. */
  311. unsigned char warn_missing_include_dirs;
  312. /* Nonzero means warn if there are any trigraphs. */
  313. unsigned char warn_trigraphs;
  314. /* Nonzero means warn about multicharacter charconsts. */
  315. unsigned char warn_multichar;
  316. /* Nonzero means warn about various incompatibilities with
  317. traditional C. */
  318. unsigned char cpp_warn_traditional;
  319. /* Nonzero means warn about long long numeric constants. */
  320. unsigned char cpp_warn_long_long;
  321. /* Nonzero means warn about text after an #endif (or #else). */
  322. unsigned char warn_endif_labels;
  323. /* Nonzero means warn about implicit sign changes owing to integer
  324. promotions. */
  325. unsigned char warn_num_sign_change;
  326. /* Zero means don't warn about __VA_ARGS__ usage in c89 pedantic mode.
  327. Presumably the usage is protected by the appropriate #ifdef. */
  328. unsigned char warn_variadic_macros;
  329. /* Nonzero means warn about builtin macros that are redefined or
  330. explicitly undefined. */
  331. unsigned char warn_builtin_macro_redefined;
  332. /* Nonzero means we should look for header.gcc files that remap file
  333. names. */
  334. unsigned char remap;
  335. /* Zero means dollar signs are punctuation. */
  336. unsigned char dollars_in_ident;
  337. /* Nonzero means UCNs are accepted in identifiers. */
  338. unsigned char extended_identifiers;
  339. /* True if we should warn about dollars in identifiers or numbers
  340. for this translation unit. */
  341. unsigned char warn_dollars;
  342. /* Nonzero means warn if undefined identifiers are evaluated in an #if. */
  343. unsigned char warn_undef;
  344. /* Nonzero means warn of unused macros from the main file. */
  345. unsigned char warn_unused_macros;
  346. /* Nonzero for the 1999 C Standard, including corrigenda and amendments. */
  347. unsigned char c99;
  348. /* Nonzero if we are conforming to a specific C or C++ standard. */
  349. unsigned char std;
  350. /* Nonzero means give all the error messages the ANSI standard requires. */
  351. unsigned char cpp_pedantic;
  352. /* Nonzero means we're looking at already preprocessed code, so don't
  353. bother trying to do macro expansion and whatnot. */
  354. unsigned char preprocessed;
  355. /* Nonzero means we are going to emit debugging logs during
  356. preprocessing. */
  357. unsigned char debug;
  358. /* Nonzero means we are tracking locations of tokens involved in
  359. macro expansion. 1 Means we track the location in degraded mode
  360. where we do not track locations of tokens resulting from the
  361. expansion of arguments of function-like macro. 2 Means we do
  362. track all macro expansions. This last option is the one that
  363. consumes the highest amount of memory. */
  364. unsigned char track_macro_expansion;
  365. /* Nonzero means handle C++ alternate operator names. */
  366. unsigned char operator_names;
  367. /* Nonzero means warn about use of C++ alternate operator names. */
  368. unsigned char warn_cxx_operator_names;
  369. /* True for traditional preprocessing. */
  370. unsigned char traditional;
  371. /* Nonzero for C++ 2011 Standard user-defined literals. */
  372. unsigned char user_literals;
  373. /* Nonzero means warn when a string or character literal is followed by a
  374. ud-suffix which does not beging with an underscore. */
  375. unsigned char warn_literal_suffix;
  376. /* Nonzero means interpret imaginary, fixed-point, or other gnu extension
  377. literal number suffixes as user-defined literal number suffixes. */
  378. unsigned char ext_numeric_literals;
  379. /* Nonzero means extended identifiers allow the characters specified
  380. in C11 and C++11. */
  381. unsigned char c11_identifiers;
  382. /* Nonzero for C++ 2014 Standard binary constants. */
  383. unsigned char binary_constants;
  384. /* Nonzero for C++ 2014 Standard digit separators. */
  385. unsigned char digit_separators;
  386. /* Holds the name of the target (execution) character set. */
  387. const char *narrow_charset;
  388. /* Holds the name of the target wide character set. */
  389. const char *wide_charset;
  390. /* Holds the name of the input character set. */
  391. const char *input_charset;
  392. /* The minimum permitted level of normalization before a warning
  393. is generated. See enum cpp_normalize_level. */
  394. int warn_normalize;
  395. /* True to warn about precompiled header files we couldn't use. */
  396. bool warn_invalid_pch;
  397. /* True if dependencies should be restored from a precompiled header. */
  398. bool restore_pch_deps;
  399. /* True if warn about differences between C90 and C99. */
  400. signed char cpp_warn_c90_c99_compat;
  401. /* Dependency generation. */
  402. struct
  403. {
  404. /* Style of header dependencies to generate. */
  405. enum cpp_deps_style style;
  406. /* Assume missing files are generated files. */
  407. bool missing_files;
  408. /* Generate phony targets for each dependency apart from the first
  409. one. */
  410. bool phony_targets;
  411. /* If true, no dependency is generated on the main file. */
  412. bool ignore_main_file;
  413. /* If true, intend to use the preprocessor output (e.g., for compilation)
  414. in addition to the dependency info. */
  415. bool need_preprocessor_output;
  416. } deps;
  417. /* Target-specific features set by the front end or client. */
  418. /* Precision for target CPP arithmetic, target characters, target
  419. ints and target wide characters, respectively. */
  420. size_t precision, char_precision, int_precision, wchar_precision;
  421. /* True means chars (wide chars) are unsigned. */
  422. bool unsigned_char, unsigned_wchar;
  423. /* True if the most significant byte in a word has the lowest
  424. address in memory. */
  425. bool bytes_big_endian;
  426. /* Nonzero means __STDC__ should have the value 0 in system headers. */
  427. unsigned char stdc_0_in_system_headers;
  428. /* True disables tokenization outside of preprocessing directives. */
  429. bool directives_only;
  430. /* True enables canonicalization of system header file paths. */
  431. bool canonical_system_headers;
  432. };
  433. /* Callback for header lookup for HEADER, which is the name of a
  434. source file. It is used as a method of last resort to find headers
  435. that are not otherwise found during the normal include processing.
  436. The return value is the malloced name of a header to try and open,
  437. if any, or NULL otherwise. This callback is called only if the
  438. header is otherwise unfound. */
  439. typedef const char *(*missing_header_cb)(cpp_reader *, const char *header, cpp_dir **);
  440. /* Call backs to cpplib client. */
  441. struct cpp_callbacks
  442. {
  443. /* Called when a new line of preprocessed output is started. */
  444. void (*line_change) (cpp_reader *, const cpp_token *, int);
  445. /* Called when switching to/from a new file.
  446. The line_map is for the new file. It is NULL if there is no new file.
  447. (In C this happens when done with <built-in>+<command line> and also
  448. when done with a main file.) This can be used for resource cleanup. */
  449. void (*file_change) (cpp_reader *, const struct line_map *);
  450. void (*dir_change) (cpp_reader *, const char *);
  451. void (*include) (cpp_reader *, source_location, const unsigned char *,
  452. const char *, int, const cpp_token **);
  453. void (*define) (cpp_reader *, source_location, cpp_hashnode *);
  454. void (*undef) (cpp_reader *, source_location, cpp_hashnode *);
  455. void (*ident) (cpp_reader *, source_location, const cpp_string *);
  456. void (*def_pragma) (cpp_reader *, source_location);
  457. int (*valid_pch) (cpp_reader *, const char *, int);
  458. void (*read_pch) (cpp_reader *, const char *, int, const char *);
  459. missing_header_cb missing_header;
  460. /* Context-sensitive macro support. Returns macro (if any) that should
  461. be expanded. */
  462. cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *);
  463. /* Called to emit a diagnostic. This callback receives the
  464. translated message. */
  465. bool (*error) (cpp_reader *, int, int, source_location, unsigned int,
  466. const char *, va_list *)
  467. ATTRIBUTE_FPTR_PRINTF(6,0);
  468. /* Callbacks for when a macro is expanded, or tested (whether
  469. defined or not at the time) in #ifdef, #ifndef or "defined". */
  470. void (*used_define) (cpp_reader *, source_location, cpp_hashnode *);
  471. void (*used_undef) (cpp_reader *, source_location, cpp_hashnode *);
  472. /* Called before #define and #undef or other macro definition
  473. changes are processed. */
  474. void (*before_define) (cpp_reader *);
  475. /* Called whenever a macro is expanded or tested.
  476. Second argument is the location of the start of the current expansion. */
  477. void (*used) (cpp_reader *, source_location, cpp_hashnode *);
  478. /* Callback to identify whether an attribute exists. */
  479. int (*has_attribute) (cpp_reader *);
  480. /* Callback that can change a user builtin into normal macro. */
  481. bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
  482. };
  483. #ifdef VMS
  484. #define INO_T_CPP ino_t ino[3]
  485. #else
  486. #define INO_T_CPP ino_t ino
  487. #endif
  488. /* Chain of directories to look for include files in. */
  489. struct cpp_dir
  490. {
  491. /* NULL-terminated singly-linked list. */
  492. struct cpp_dir *next;
  493. /* NAME of the directory, NUL-terminated. */
  494. char *name;
  495. unsigned int len;
  496. /* One if a system header, two if a system header that has extern
  497. "C" guards for C++. */
  498. unsigned char sysp;
  499. /* Is this a user-supplied directory? */
  500. bool user_supplied_p;
  501. /* The canonicalized NAME as determined by lrealpath. This field
  502. is only used by hosts that lack reliable inode numbers. */
  503. char *canonical_name;
  504. /* Mapping of file names for this directory for MS-DOS and related
  505. platforms. A NULL-terminated array of (from, to) pairs. */
  506. const char **name_map;
  507. /* Routine to construct pathname, given the search path name and the
  508. HEADER we are trying to find, return a constructed pathname to
  509. try and open. If this is NULL, the constructed pathname is as
  510. constructed by append_file_to_dir. */
  511. char *(*construct) (const char *header, cpp_dir *dir);
  512. /* The C front end uses these to recognize duplicated
  513. directories in the search path. */
  514. INO_T_CPP;
  515. dev_t dev;
  516. };
  517. /* The structure of a node in the hash table. The hash table has
  518. entries for all identifiers: either macros defined by #define
  519. commands (type NT_MACRO), assertions created with #assert
  520. (NT_ASSERTION), or neither of the above (NT_VOID). Builtin macros
  521. like __LINE__ are flagged NODE_BUILTIN. Poisoned identifiers are
  522. flagged NODE_POISONED. NODE_OPERATOR (C++ only) indicates an
  523. identifier that behaves like an operator such as "xor".
  524. NODE_DIAGNOSTIC is for speed in lex_token: it indicates a
  525. diagnostic may be required for this node. Currently this only
  526. applies to __VA_ARGS__, poisoned identifiers, and -Wc++-compat
  527. warnings about NODE_OPERATOR. */
  528. /* Hash node flags. */
  529. #define NODE_OPERATOR (1 << 0) /* C++ named operator. */
  530. #define NODE_POISONED (1 << 1) /* Poisoned identifier. */
  531. #define NODE_BUILTIN (1 << 2) /* Builtin macro. */
  532. #define NODE_DIAGNOSTIC (1 << 3) /* Possible diagnostic when lexed. */
  533. #define NODE_WARN (1 << 4) /* Warn if redefined or undefined. */
  534. #define NODE_DISABLED (1 << 5) /* A disabled macro. */
  535. #define NODE_MACRO_ARG (1 << 6) /* Used during #define processing. */
  536. #define NODE_USED (1 << 7) /* Dumped with -dU. */
  537. #define NODE_CONDITIONAL (1 << 8) /* Conditional macro */
  538. #define NODE_WARN_OPERATOR (1 << 9) /* Warn about C++ named operator. */
  539. /* Different flavors of hash node. */
  540. enum node_type
  541. {
  542. NT_VOID = 0, /* No definition yet. */
  543. NT_MACRO, /* A macro of some form. */
  544. NT_ASSERTION /* Predicate for #assert. */
  545. };
  546. /* Different flavors of builtin macro. _Pragma is an operator, but we
  547. handle it with the builtin code for efficiency reasons. */
  548. enum cpp_builtin_type
  549. {
  550. BT_SPECLINE = 0, /* `__LINE__' */
  551. BT_DATE, /* `__DATE__' */
  552. BT_FILE, /* `__FILE__' */
  553. BT_BASE_FILE, /* `__BASE_FILE__' */
  554. BT_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
  555. BT_TIME, /* `__TIME__' */
  556. BT_STDC, /* `__STDC__' */
  557. BT_PRAGMA, /* `_Pragma' operator */
  558. BT_TIMESTAMP, /* `__TIMESTAMP__' */
  559. BT_COUNTER, /* `__COUNTER__' */
  560. BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */
  561. BT_FIRST_USER, /* User defined builtin macros. */
  562. BT_LAST_USER = BT_FIRST_USER + 31
  563. };
  564. #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE))
  565. #define HT_NODE(NODE) ((ht_identifier *) (NODE))
  566. #define NODE_LEN(NODE) HT_LEN (&(NODE)->ident)
  567. #define NODE_NAME(NODE) HT_STR (&(NODE)->ident)
  568. /* Specify which field, if any, of the union is used. */
  569. enum {
  570. NTV_MACRO,
  571. NTV_ANSWER,
  572. NTV_BUILTIN,
  573. NTV_ARGUMENT,
  574. NTV_NONE
  575. };
  576. #define CPP_HASHNODE_VALUE_IDX(HNODE) \
  577. ((HNODE.flags & NODE_MACRO_ARG) ? NTV_ARGUMENT \
  578. : HNODE.type == NT_MACRO ? ((HNODE.flags & NODE_BUILTIN) \
  579. ? NTV_BUILTIN : NTV_MACRO) \
  580. : HNODE.type == NT_ASSERTION ? NTV_ANSWER \
  581. : NTV_NONE)
  582. /* The common part of an identifier node shared amongst all 3 C front
  583. ends. Also used to store CPP identifiers, which are a superset of
  584. identifiers in the grammatical sense. */
  585. union GTY(()) _cpp_hashnode_value {
  586. /* If a macro. */
  587. cpp_macro * GTY((tag ("NTV_MACRO"))) macro;
  588. /* Answers to an assertion. */
  589. struct answer * GTY ((tag ("NTV_ANSWER"))) answers;
  590. /* Code for a builtin macro. */
  591. enum cpp_builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin;
  592. /* Macro argument index. */
  593. unsigned short GTY ((tag ("NTV_ARGUMENT"))) arg_index;
  594. };
  595. struct GTY(()) cpp_hashnode {
  596. struct ht_identifier ident;
  597. unsigned int is_directive : 1;
  598. unsigned int directive_index : 7; /* If is_directive,
  599. then index into directive table.
  600. Otherwise, a NODE_OPERATOR. */
  601. unsigned char rid_code; /* Rid code - for front ends. */
  602. ENUM_BITFIELD(node_type) type : 6; /* CPP node type. */
  603. unsigned int flags : 10; /* CPP flags. */
  604. union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value;
  605. };
  606. /* Call this first to get a handle to pass to other functions.
  607. If you want cpplib to manage its own hashtable, pass in a NULL
  608. pointer. Otherwise you should pass in an initialized hash table
  609. that cpplib will share; this technique is used by the C front
  610. ends. */
  611. extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *,
  612. struct line_maps *);
  613. /* Reset the cpp_reader's line_map. This is only used after reading a
  614. PCH file. */
  615. extern void cpp_set_line_map (cpp_reader *, struct line_maps *);
  616. /* Call this to change the selected language standard (e.g. because of
  617. command line options). */
  618. extern void cpp_set_lang (cpp_reader *, enum c_lang);
  619. /* Set the include paths. */
  620. extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int);
  621. /* Provide src:dst pair for __FILE__ remapping. */
  622. extern void add_cpp_remap_path (const char *);
  623. /* Call these to get pointers to the options, callback, and deps
  624. structures for a given reader. These pointers are good until you
  625. call cpp_finish on that reader. You can either edit the callbacks
  626. through the pointer returned from cpp_get_callbacks, or set them
  627. with cpp_set_callbacks. */
  628. extern cpp_options *cpp_get_options (cpp_reader *);
  629. extern cpp_callbacks *cpp_get_callbacks (cpp_reader *);
  630. extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
  631. extern struct deps *cpp_get_deps (cpp_reader *);
  632. /* This function reads the file, but does not start preprocessing. It
  633. returns the name of the original file; this is the same as the
  634. input file, except for preprocessed input. This will generate at
  635. least one file change callback, and possibly a line change callback
  636. too. If there was an error opening the file, it returns NULL. */
  637. extern const char *cpp_read_main_file (cpp_reader *, const char *);
  638. /* Set up built-ins with special behavior. Use cpp_init_builtins()
  639. instead unless your know what you are doing. */
  640. extern void cpp_init_special_builtins (cpp_reader *);
  641. /* Set up built-ins like __FILE__. */
  642. extern void cpp_init_builtins (cpp_reader *, int);
  643. /* This is called after options have been parsed, and partially
  644. processed. */
  645. extern void cpp_post_options (cpp_reader *);
  646. /* Set up translation to the target character set. */
  647. extern void cpp_init_iconv (cpp_reader *);
  648. /* Call this to finish preprocessing. If you requested dependency
  649. generation, pass an open stream to write the information to,
  650. otherwise NULL. It is your responsibility to close the stream. */
  651. extern void cpp_finish (cpp_reader *, FILE *deps_stream);
  652. /* Call this to release the handle at the end of preprocessing. Any
  653. use of the handle after this function returns is invalid. */
  654. extern void cpp_destroy (cpp_reader *);
  655. extern unsigned int cpp_token_len (const cpp_token *);
  656. extern unsigned char *cpp_token_as_text (cpp_reader *, const cpp_token *);
  657. extern unsigned char *cpp_spell_token (cpp_reader *, const cpp_token *,
  658. unsigned char *, bool);
  659. extern void cpp_register_pragma (cpp_reader *, const char *, const char *,
  660. void (*) (cpp_reader *), bool);
  661. extern void cpp_register_deferred_pragma (cpp_reader *, const char *,
  662. const char *, unsigned, bool, bool);
  663. extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
  664. const cpp_token *);
  665. extern const cpp_token *cpp_get_token (cpp_reader *);
  666. extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
  667. source_location *);
  668. extern const unsigned char *cpp_macro_definition (cpp_reader *,
  669. cpp_hashnode *);
  670. extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
  671. extern const cpp_token *cpp_peek_token (cpp_reader *, int);
  672. /* Evaluate a CPP_*CHAR* token. */
  673. extern cppchar_t cpp_interpret_charconst (cpp_reader *, const cpp_token *,
  674. unsigned int *, int *);
  675. /* Evaluate a vector of CPP_*STRING* tokens. */
  676. extern bool cpp_interpret_string (cpp_reader *,
  677. const cpp_string *, size_t,
  678. cpp_string *, enum cpp_ttype);
  679. extern bool cpp_interpret_string_notranslate (cpp_reader *,
  680. const cpp_string *, size_t,
  681. cpp_string *, enum cpp_ttype);
  682. /* Convert a host character constant to the execution character set. */
  683. extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);
  684. /* Used to register macros and assertions, perhaps from the command line.
  685. The text is the same as the command line argument. */
  686. extern void cpp_define (cpp_reader *, const char *);
  687. extern void cpp_define_formatted (cpp_reader *pfile,
  688. const char *fmt, ...) ATTRIBUTE_PRINTF_2;
  689. extern void cpp_assert (cpp_reader *, const char *);
  690. extern void cpp_undef (cpp_reader *, const char *);
  691. extern void cpp_unassert (cpp_reader *, const char *);
  692. /* Undefine all macros and assertions. */
  693. extern void cpp_undef_all (cpp_reader *);
  694. extern cpp_buffer *cpp_push_buffer (cpp_reader *, const unsigned char *,
  695. size_t, int);
  696. extern int cpp_defined (cpp_reader *, const unsigned char *, int);
  697. /* A preprocessing number. Code assumes that any unused high bits of
  698. the double integer are set to zero. */
  699. /* This type has to be equal to unsigned HOST_WIDE_INT, see
  700. gcc/c-family/c-lex.c. */
  701. typedef uint64_t cpp_num_part;
  702. typedef struct cpp_num cpp_num;
  703. struct cpp_num
  704. {
  705. cpp_num_part high;
  706. cpp_num_part low;
  707. bool unsignedp; /* True if value should be treated as unsigned. */
  708. bool overflow; /* True if the most recent calculation overflowed. */
  709. };
  710. /* cpplib provides two interfaces for interpretation of preprocessing
  711. numbers.
  712. cpp_classify_number categorizes numeric constants according to
  713. their field (integer, floating point, or invalid), radix (decimal,
  714. octal, hexadecimal), and type suffixes. */
  715. #define CPP_N_CATEGORY 0x000F
  716. #define CPP_N_INVALID 0x0000
  717. #define CPP_N_INTEGER 0x0001
  718. #define CPP_N_FLOATING 0x0002
  719. #define CPP_N_WIDTH 0x00F0
  720. #define CPP_N_SMALL 0x0010 /* int, float, shrot _Fract/Accum */
  721. #define CPP_N_MEDIUM 0x0020 /* long, double, long _Fract/_Accum. */
  722. #define CPP_N_LARGE 0x0040 /* long long, long double,
  723. long long _Fract/Accum. */
  724. #define CPP_N_WIDTH_MD 0xF0000 /* machine defined. */
  725. #define CPP_N_MD_W 0x10000
  726. #define CPP_N_MD_Q 0x20000
  727. #define CPP_N_RADIX 0x0F00
  728. #define CPP_N_DECIMAL 0x0100
  729. #define CPP_N_HEX 0x0200
  730. #define CPP_N_OCTAL 0x0400
  731. #define CPP_N_BINARY 0x0800
  732. #define CPP_N_UNSIGNED 0x1000 /* Properties. */
  733. #define CPP_N_IMAGINARY 0x2000
  734. #define CPP_N_DFLOAT 0x4000
  735. #define CPP_N_DEFAULT 0x8000
  736. #define CPP_N_FRACT 0x100000 /* Fract types. */
  737. #define CPP_N_ACCUM 0x200000 /* Accum types. */
  738. #define CPP_N_USERDEF 0x1000000 /* C++0x user-defined literal. */
  739. /* Classify a CPP_NUMBER token. The return value is a combination of
  740. the flags from the above sets. */
  741. extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *,
  742. const char **, source_location);
  743. /* Return the classification flags for a float suffix. */
  744. extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
  745. size_t);
  746. /* Return the classification flags for an int suffix. */
  747. extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *,
  748. size_t);
  749. /* Evaluate a token classified as category CPP_N_INTEGER. */
  750. extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
  751. unsigned int);
  752. /* Sign extend a number, with PRECISION significant bits and all
  753. others assumed clear, to fill out a cpp_num structure. */
  754. cpp_num cpp_num_sign_extend (cpp_num, size_t);
  755. /* Diagnostic levels. To get a diagnostic without associating a
  756. position in the translation unit with it, use cpp_error_with_line
  757. with a line number of zero. */
  758. enum {
  759. /* Warning, an error with -Werror. */
  760. CPP_DL_WARNING = 0,
  761. /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
  762. CPP_DL_WARNING_SYSHDR,
  763. /* Warning, an error with -pedantic-errors or -Werror. */
  764. CPP_DL_PEDWARN,
  765. /* An error. */
  766. CPP_DL_ERROR,
  767. /* An internal consistency check failed. Prints "internal error: ",
  768. otherwise the same as CPP_DL_ERROR. */
  769. CPP_DL_ICE,
  770. /* An informative note following a warning. */
  771. CPP_DL_NOTE,
  772. /* A fatal error. */
  773. CPP_DL_FATAL
  774. };
  775. /* Warning reason codes. Use a reason code of zero for unclassified warnings
  776. and errors that are not warnings. */
  777. enum {
  778. CPP_W_NONE = 0,
  779. CPP_W_DEPRECATED,
  780. CPP_W_COMMENTS,
  781. CPP_W_MISSING_INCLUDE_DIRS,
  782. CPP_W_TRIGRAPHS,
  783. CPP_W_MULTICHAR,
  784. CPP_W_TRADITIONAL,
  785. CPP_W_LONG_LONG,
  786. CPP_W_ENDIF_LABELS,
  787. CPP_W_NUM_SIGN_CHANGE,
  788. CPP_W_VARIADIC_MACROS,
  789. CPP_W_BUILTIN_MACRO_REDEFINED,
  790. CPP_W_DOLLARS,
  791. CPP_W_UNDEF,
  792. CPP_W_UNUSED_MACROS,
  793. CPP_W_CXX_OPERATOR_NAMES,
  794. CPP_W_NORMALIZE,
  795. CPP_W_INVALID_PCH,
  796. CPP_W_WARNING_DIRECTIVE,
  797. CPP_W_LITERAL_SUFFIX,
  798. CPP_W_DATE_TIME,
  799. CPP_W_PEDANTIC,
  800. CPP_W_C90_C99_COMPAT
  801. };
  802. /* Output a diagnostic of some kind. */
  803. extern bool cpp_error (cpp_reader *, int, const char *msgid, ...)
  804. ATTRIBUTE_PRINTF_3;
  805. extern bool cpp_warning (cpp_reader *, int, const char *msgid, ...)
  806. ATTRIBUTE_PRINTF_3;
  807. extern bool cpp_pedwarning (cpp_reader *, int, const char *msgid, ...)
  808. ATTRIBUTE_PRINTF_3;
  809. extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...)
  810. ATTRIBUTE_PRINTF_3;
  811. /* Output a diagnostic with "MSGID: " preceding the
  812. error string of errno. No location is printed. */
  813. extern bool cpp_errno (cpp_reader *, int, const char *msgid);
  814. /* Similarly, but with "FILENAME: " instead of "MSGID: ", where
  815. the filename is not localized. */
  816. extern bool cpp_errno_filename (cpp_reader *, int, const char *filename);
  817. /* Same as cpp_error, except additionally specifies a position as a
  818. (translation unit) physical line and physical column. If the line is
  819. zero, then no location is printed. */
  820. extern bool cpp_error_with_line (cpp_reader *, int, source_location,
  821. unsigned, const char *msgid, ...)
  822. ATTRIBUTE_PRINTF_5;
  823. extern bool cpp_warning_with_line (cpp_reader *, int, source_location,
  824. unsigned, const char *msgid, ...)
  825. ATTRIBUTE_PRINTF_5;
  826. extern bool cpp_pedwarning_with_line (cpp_reader *, int, source_location,
  827. unsigned, const char *msgid, ...)
  828. ATTRIBUTE_PRINTF_5;
  829. extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location,
  830. unsigned, const char *msgid, ...)
  831. ATTRIBUTE_PRINTF_5;
  832. /* In lex.c */
  833. extern int cpp_ideq (const cpp_token *, const char *);
  834. extern void cpp_output_line (cpp_reader *, FILE *);
  835. extern unsigned char *cpp_output_line_to_string (cpp_reader *,
  836. const unsigned char *);
  837. extern void cpp_output_token (const cpp_token *, FILE *);
  838. extern const char *cpp_type2name (enum cpp_ttype, unsigned char flags);
  839. /* Returns the value of an escape sequence, truncated to the correct
  840. target precision. PSTR points to the input pointer, which is just
  841. after the backslash. LIMIT is how much text we have. WIDE is true
  842. if the escape sequence is part of a wide character constant or
  843. string literal. Handles all relevant diagnostics. */
  844. extern cppchar_t cpp_parse_escape (cpp_reader *, const unsigned char ** pstr,
  845. const unsigned char *limit, int wide);
  846. /* Structure used to hold a comment block at a given location in the
  847. source code. */
  848. typedef struct
  849. {
  850. /* Text of the comment including the terminators. */
  851. char *comment;
  852. /* source location for the given comment. */
  853. source_location sloc;
  854. } cpp_comment;
  855. /* Structure holding all comments for a given cpp_reader. */
  856. typedef struct
  857. {
  858. /* table of comment entries. */
  859. cpp_comment *entries;
  860. /* number of actual entries entered in the table. */
  861. int count;
  862. /* number of entries allocated currently. */
  863. int allocated;
  864. } cpp_comment_table;
  865. /* Returns the table of comments encountered by the preprocessor. This
  866. table is only populated when pfile->state.save_comments is true. */
  867. extern cpp_comment_table *cpp_get_comments (cpp_reader *);
  868. /* In hash.c */
  869. /* Lookup an identifier in the hashtable. Puts the identifier in the
  870. table if it is not already there. */
  871. extern cpp_hashnode *cpp_lookup (cpp_reader *, const unsigned char *,
  872. unsigned int);
  873. typedef int (*cpp_cb) (cpp_reader *, cpp_hashnode *, void *);
  874. extern void cpp_forall_identifiers (cpp_reader *, cpp_cb, void *);
  875. /* In macro.c */
  876. extern void cpp_scan_nooutput (cpp_reader *);
  877. extern int cpp_sys_macro_p (cpp_reader *);
  878. extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
  879. unsigned int);
  880. /* In files.c */
  881. extern bool cpp_included (cpp_reader *, const char *);
  882. extern bool cpp_included_before (cpp_reader *, const char *, source_location);
  883. extern void cpp_make_system_header (cpp_reader *, int, int);
  884. extern bool cpp_push_include (cpp_reader *, const char *);
  885. extern bool cpp_push_default_include (cpp_reader *, const char *);
  886. extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
  887. extern const char *cpp_get_path (struct _cpp_file *);
  888. extern cpp_dir *cpp_get_dir (struct _cpp_file *);
  889. extern cpp_buffer *cpp_get_buffer (cpp_reader *);
  890. extern struct _cpp_file *cpp_get_file (cpp_buffer *);
  891. extern cpp_buffer *cpp_get_prev (cpp_buffer *);
  892. extern void cpp_clear_file_cache (cpp_reader *);
  893. /* In pch.c */
  894. struct save_macro_data;
  895. extern int cpp_save_state (cpp_reader *, FILE *);
  896. extern int cpp_write_pch_deps (cpp_reader *, FILE *);
  897. extern int cpp_write_pch_state (cpp_reader *, FILE *);
  898. extern int cpp_valid_state (cpp_reader *, const char *, int);
  899. extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **);
  900. extern int cpp_read_state (cpp_reader *, const char *, FILE *,
  901. struct save_macro_data *);
  902. /* In lex.c */
  903. extern void cpp_force_token_locations (cpp_reader *, source_location *);
  904. extern void cpp_stop_forcing_token_locations (cpp_reader *);
  905. /* In expr.c */
  906. extern enum cpp_ttype cpp_userdef_string_remove_type
  907. (enum cpp_ttype type);
  908. extern enum cpp_ttype cpp_userdef_string_add_type
  909. (enum cpp_ttype type);
  910. extern enum cpp_ttype cpp_userdef_char_remove_type
  911. (enum cpp_ttype type);
  912. extern enum cpp_ttype cpp_userdef_char_add_type
  913. (enum cpp_ttype type);
  914. extern bool cpp_userdef_string_p
  915. (enum cpp_ttype type);
  916. extern bool cpp_userdef_char_p
  917. (enum cpp_ttype type);
  918. extern const char * cpp_get_userdef_suffix
  919. (const cpp_token *);
  920. #endif /* ! LIBCPP_CPPLIB_H */