0823efedd0
Merge from cxx-conversion branch (http://gcc.gnu.org/wiki/cxx-conversion). As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html, this patch changes the default bootstrap process so that stage 1 always builds with a C++ compiler. Other than the bootstrap change, the patch makes no functional changes to the compiler. Everything should build as it does now in trunk. The main changes in this patch are: 1- Configuration changes. 2- Re-write of VEC. 3- Re-write of gengtype to support C++ templates and user-provided marking functions. 4- New hash table class. 5- Re-write double_int. 6- Implement tree macros as inline functions so they can be called from gdb. As discussed before, several of these changes do not fully change the call sites to use the new APIs. The bootstrap changes have already been tested on a wide range of targets (http://gcc.gnu.org/wiki/CppBuildStatus). Additionally, I have tested the merged trunk on: x86_64-unknown-linux-gnu, mips64el-unknown-linux-gnu, powerpc64-unknown-linux-gnu, i686-pc-linux-gnu, and ia64-unknown-linux-gnu. ChangeLog 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. * Makefile.tpl (STAGE[+id+]_CXXFLAGS): Remove POSTSTAGE1_CONFIGURE_FLAGS. * Makefile.in: Regenerate. * configure.ac (ENABLE_BUILD_WITH_CXX): Remove. Update all users. Force C++ when bootstrapping. * configure: Regenerate. libcpp/ChangeLog 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. Configury. * Makefile.in: Remove all handlers of ENABLE_BUILD_WITH_CXX. * configure.ac: Likewise. * configure: Regenerate. 2012-08-14 Lawrence Crowl <crowl@google.com> Merge from cxx-conversion branch. New C++ hash table. * include/symtab.h (typedef struct ht hash_table): Change the typedef name to cpp_hash_table. Update all users of the typedef. gcc/ChangeLog 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. Configury. * configure.ac (CXX_FOR_BUILD): Define and substitute. (BUILD_CXXFLAGS): Define. Remove all handlers of ENABLE_BUILD_WITH_CXX. Force all build to be with C++. * Makefile.in (BUILD_CXXFLAGS): Use it. Remove all handlers of ENABLE_BUILD_WITH_CXX. * configure: Regenerate. * config.in: Regenerate. * doc/install.texi: Remove documentation for --enable-build-with-cxx and --enable-build-poststage1-with-cxx. 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. Re-implement VEC in C++. * vec.c (vec_heap_free): Convert into a template function. (vec_gc_o_reserve_1): Make extern. (vec_gc_p_reserve): Remove. (vec_gc_p_reserve_exact): Remove. (vec_gc_o_reserve): Remove. (vec_gc_o_reserve_exact): Remove. (vec_heap_o_reserve_1): Make extern. (vec_heap_p_reserve): Remove. (vec_heap_p_reserve_exact): Remove. (vec_heap_o_reserve): Remove. (vec_heap_o_reserve_exact): Remove. (vec_stack_p_reserve): Remove. (vec_stack_p_reserve_exact): Remove. * vec.h (VEC_CHECK_INFO, VEC_CHECK_DECL, VEC_CHECK_PASS, VEC_ASSERT, VEC_ASSERT_FAIL, vec_assert_fail): Move earlier in the file. (VEC): Define to vec_t<T>. (vec_allocation_t): Define. (struct vec_prefix): Move earlier in the file. (vec_t<T>): New template. (DEF_VEC_I, DEF_VECL_ALLOC_I, DEF_VEC_P, DEF_VEC_ALLOC_P, DEF_VEC_O, DEF_VEC_ALLOC_P, DEF_VEC_O, DEF_VEC_ALLOC_O, DEF_VEC_ALLOC_P_STACK, DEF_VEC_ALLOC_O_STACK, DEF_VEC_ALLOC_I_STACK): Expand to 'struct vec_swallow_trailing_semi'. (DEF_VEC_A): Provide template instantiations for GC/PCH markers that do not traverse the vector. (vec_stack_p_reserve): Remove. (vec_stack_p_reserve_exact): Remove. (vec_stack_p_reserve_exact_1): Remove. (vec_stack_o_reserve): Remove. (vec_stack_o_reserve_exact): Remove. (vec_stack_free): Re-write as a template function. (vec_reserve): New template function. (vec_reserve_exact): New template function. (vec_heap_free): New template function if GATHER_STATISTICS is defined. Otherwise, macro that expands to free(). (VEC_length_1): New template function. (VEC_length): Call it. (VEC_empty_1): New template function. (VEC_empty): Call it. (VEC_address_1): New template function. (VEC_address): Call it. (VEC_last_1): New template function. (VEC_last): Call it. Change return type to T&. Change all users that used VEC_Os. (VEC_index_1): New template function. (VEC_index): Call it. Return a T& instead of a T*. Update all callers that were using VEC_O before. (VEC_iterate_1): New template function. (VEC_iterate): Call it. (VEC_embedded_size_1): New template function. (VEC_embedded_size): Call it. (VEC_embedded_init_1): New template function. (VEC_embedded_init): Call it. (VEC_alloc_1): New template function. (VEC_alloc): Call it. If A is 'stack', call XALLOCAVAR to do the allocation. (VEC_free_1): New template function. (VEC_free): Call it. (VEC_copy_1): New template function. (VEC_copy): Call it. (VEC_space_1): New template function (VEC_space): Call it. (VEC_reserve_1): New template function. (VEC_reserve): Call it. (VEC_reserve_exact_1): New template function. (VEC_reserve_exact): Call it. (VEC_splice_1): New template function. (VEC_splice): Call it. (VEC_safe_splice_1): New template function. (VEC_safe_splice): Call it. (VEC_quick_push_1): New template function. Create two overloads, one accepting T, the other accepting T *. Update all callers where T and T * are ambiguous. (VEC_quick_push): Call it. (VEC_safe_push_1): New template function. Create two overloads, one accepting T, the other accepting T *. Update all callers where T and T * are ambiguous. (VEC_safe_push): Call it. (VEC_pop_1): New template function. (VEC_pop): Call it. (VEC_truncate_1): New template function. (VEC_truncate): Call it. (VEC_safe_grow_1): New template function. (VEC_safe_grow): Call it. (VEC_safe_grow_cleared_1): New template function. (VEC_safe_grow_cleared): Call it. (VEC_replace_1): New template function. (VEC_replace): Call it. Always accept T instead of T*. Update all callers that used VEC_Os. (VEC_quick_insert_1): New template function. (VEC_quick_insert): Call it. (VEC_safe_insert_1): New template function. (VEC_safe_insert): Call it. (VEC_ordered_remove_1): New template function. (VEC_ordered_remove): Call it. (VEC_unordered_remove_1): New template function. (VEC_unordered_remove): Call it. (VEC_block_remove_1): New template function. (VEC_block_remove): Call it. (VEC_lower_bound_1): New template function. (VEC_lower_bound): Call it. (VEC_OP): Remove. (DEF_VEC_FUNC_P): Remove. (DEF_VEC_ALLOC_FUNC_P): Remove. (DEF_VEC_NONALLOC_FUNCS_P): Remove. (DEF_VEC_FUNC_O): Remove. (DEF_VEC_ALLOC_FUNC_O): Remove. (DEF_VEC_NONALLOC_FUNCS_O): Remove. (DEF_VEC_ALLOC_FUNC_I): Remove. (DEF_VEC_NONALLOC_FUNCS_I): Remove. (DEF_VEC_ALLOC_FUNC_P_STACK): Remove. (DEF_VEC_ALLOC_FUNC_O_STACK): Remove. (DEF_VEC_ALLOC_FUNC_I_STACK): Remove. (vec_reserve_exact): New template function. * gengtype-lex.l (DEF_VEC_ALLOC_[IOP]/{EOID}): Remove. * gengtype-parse.c (token_names): Remove DEF_VEC_ALLOC_[IOP]. (typedef_name): Emit vec_t<C1> instead of VEC_C1_C2. (def_vec_alloc): Remove. Update all callers. * gengtype.c (filter_type_name): New. (output_mangled_typename): Call it. (write_func_for_structure): Likewise. (write_types): Likewise. (write_root): Likewise. (write_typed_alloc_def): Likewise. (note_def_vec): Emit vec_t<TYPE_NAME> instead of VEC_TYPE_NAME_base. (note_def_vec_alloc): Remove. * gengtype.h (note_def_vec_alloc): Remove. (DEFVEC_ALLOC): Remove token code. * df-scan.c (df_bb_verify): Remove call to df_free_collection_rec inside the insn traversal loop. * gimplify.c (gimplify_compound_lval): Rename STACK to EXPR_STACK. * ipa-inline.c (inline_small_functions): Rename HEAP to EDGE_HEAP. * reg-stack.c (stack): Rename to STACK_PTR. Update all users. * tree-vrp.c (stack): Rename to EQUIV_STACK. Update all users. * config/bfin/bfin.c (hwloop_optimize): Update some calls to VEC_* for vectors of non-pointers. * config/c6x/c6x.c (try_rename_operands): Likewise. (reshuffle_units): Likewise. * config/mips/mips.c (mips_multi_start): Likewise. (mips_multi_add): Likewise. (mips_multi_copy_insn): Likewise. (mips_multi_set_operand): Likewise. * hw-doloop.c (discover_loop): Likewise. (discover_loops): Likewise. (reorg_loops): Likewise. 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. C++ support in gengtype. * coretypes.h (gt_pointer_operator): Move from ... * ggc.h: ... here. * doc/gty.texi: Document support for C++ templates and user-provided markers. * gcc/gengtype-lex.l: Update copyright year. Remove support for recognizing DEF_VEC_O, DEF_VEC_P and DEFVEC_I. * gengtype-parse.c: Update copyright year. (token_names): Remove DEF_VEC_O, DEF_VEC_P and DEF_VEC_I. (require_template_declaration): New. (typedef_name): Call it. (type): Replace IS_UNION with KIND. Replace all users. (def_vec): Remove. Update all users. * gengtype-state.c (type_lineloc): Handle TYPE_USER_STRUCT. (write_state_user_struct_type): New. (write_state_type): Call it. (read_state_user_struct_type): New. (read_state_type): Call it. * gengtype.c: Update copyright year. (dump_pair): Move declaration to the top. (dump_type): Likewise. (dump_type_list): Likewise. (dbgprint_count_type_at): Handle TYPE_USER_STRUCT. (create_user_defined_type): New. (resolve_typedef): Call it. (new_structure): Replace argument ISUNION with KIND. Change users to refer to KIND directly. Update all callers. (find_structure): Likewise. (set_gc_used_type): Handle TYPE_USER_STRUCT. (create_file): Update HDR to include new copyright year. (struct walk_type_data): Add field IN_PTR_FIELD. (output_mangled_typename): Handle TYPE_USER_STRUCT. (walk_type): Set D->IN_PTR_FIELD when walking a TYPE_POINTER. Clear it afterwards. Handle TYPE_USER_STRUCT. (write_types_process_field): Handle TYPE_USER_STRUCT. (get_type_specifier): Move earlier in the file. (write_type_decl): New. (write_marker_function_name): New. (write_user_func_for_structure_ptr): New. (write_user_func_for_structure_body): New. (write_user_marking_functions): New. (write_func_for_structure): Call write_marker_function_name and write_type_decl. Do not call walk_type for TYPE_USER_STRUCT. Emit a call to the user function directly. Call write_user_marking_functions on TYPE_USER_STRUCTs. (write_types_local_user_process_field): New. (write_pch_user_walking_for_structure_body): New. (write_pch_user_walking_functions): New. (write_types_local_process_field): Handle TYPE_USER_STRUCT. (write_local_func_for_structure): Do not call walk_type for TYPE_USER_STRUCT. Instead, emit the call to gt_pch_nx directly. Call write_pch_user_walking_functions for TYPE_USER_STRUCTs. (write_root): Handle TYPE_USER_STRUCT. (vec_prefix_type): Remove. Update all users. (note_def_vec): Remove. Update all users. (dump_typekind): Handle TYPE_USER_STRUCT. (dump_type): Initialize SEEN_TYPES, if needed. Handle TYPE_USER_STRUCT. (dump_everything): Do not initialize SEEN_TYPES. * gengtype.h: Update copyright year. (enum typekind): Add TYPE_USER_STRUCT. (union_or_struct_p): Rename from UNION_OR_STRUCT_P. Convert into function. Add an overload taking const_type_p. Update all callers. (new_structure): Change second field to type enum typekind. Update all users. (find_structure): Likewise. (note_def_vec): Remove. (DEFVEC_OP): Remove. (DEFVEC_I): Remove. * ggc-page.c (gt_ggc_mx): Add entry points for marking 'const char *&', 'unsigned char *&' and 'unsigned char&'. * ggc-zone.c (gt_ggc_mx): Add entry points for marking 'const char *&' and 'unsigned char *&'. * stringpool.c (gt_pch_nx): Add entry points for marking 'const char *&', 'unsigned char *&' and 'unsigned char&'. Add an entry point for the overload taking arguments 'unsigned char *', 'gt_pointer_operator' and 'void *'. * vec.h (struct vec_prefix): Remove GTY marker. (struct vec_t): Remove GTY((length)) attribute from field 'vec'. (gt_ggc_mx (vec_t<T> *)): New template function. (gt_pch_nx (vec_t<T> *)): New template function. (gt_pch_nx (vec_t<T *> *, gt_pointer_operator, void *)): New template function. (gt_pch_nx (vec_t<T> *, gt_pointer_operator, void *)): New template function. * basic-block.h (struct edge_def): Mark GTY((user)). Remove all GTY markers from fields. (gt_ggc_mx): Declare. (gt_pch_nx): Declare. * tree-cfg.c (gt_ggc_mx): New. (gt_pch_nx): New. * gengtype-lex.l (USER_GTY): Add pattern for "user". * gengtype-parse.c (option): Handle USER_GTY. (opts_have): New. (type): Call it. If the keyword 'user' is used, do not walk the fields of the structure. * gengtype.h (USER_GTY): Add. * doc/gty.texi: Update. 2012-08-14 Lawrence Crowl <crowl@google.com> Merge cxx-conversion branch. Implement C++ hash table. * hash-table.h: New. Implementation borrowed from libiberty/hashtab.c. * hash-table.c: Likewise. * tree-ssa-tail-merge.c: Include hash-table.h instead of hashtab.h. (static htab_t same_succ_htab): Change type to hash_table; move specification of helper functions from create call to declaration. Change users to invoke member functions. (same_succ_print_traverse): Make extern ssa_.... Change callers. Remove void* casting. (same_succ_hash): Likewise. (same_succ_equal): Likewise. (same_succ_delete): Likewise. * tree-ssa-threadupdate.c: Include hash-table.h. (struct local_info): Rename to ssa_local_info_t to avoid overloading the type name local_info with the variable name local_info. (static htab_t redirection_data): Change type to hash_table. Move specification of helper functions from create call to declaration. Change users to invoke member functions. (redirection_data_hash): Make extern ssa_.... Change callers. Remove void* casting. (redirection_data_eq): Likewise. (fix_duplicate_block_edges): Likewise. (create_duplicates): Likewise. (fixup_template_block): Likewise. (redirect_edges): Likewise. (lookup_redirection_data): Change types associated with the hash table from void* to their actual type. Remove unnecessary casts. * tree-ssa-ccp.c: Include hash-table.h. (typedef gimple_htab): New. Uses hash_table. Replace specific uses of htab_t with gimple_htab. Change users to invoke member functions. Move specification of helper functions from create call to declaration. * tree-ssa-coalesce.c: Include hash-table.h instead of hashtab.h. (hash_ssa_name_by_var): Make extern. Remove void* casting. (eq_ssa_name_by_var): Likewise. (coalesce_ssa_name): Change type of local static htab_t ssa_name_hash to hash_table. Change users to invoke member functions. Move specification of helper functions from create call to declaration. * coverage.c: Include hash-table.h instead of hashtab.h. (static htab_t counts_hash): Change type to hash_table; move specification of helper functions from create call to declaration. Change users to invoke member functions. (htab_counts_entry_hash): Make extern. Rename with coverage_... instead of htab_... Remove void* casting. (htab_counts_entry_eq): Likewise. (htab_counts_entry_del): Likewise. * tree-ssa-pre.c: Include hash-table.h instead of hashtab.h. (static htab_t expression_to_id): Change type to hash_table. Move specification of helper functions from create call to declaration. Change users to invoke member functions. (static htab_t phi_translate_table): Likewise. (pre_expr_eq): Make extern ssa_.... Change callers. Remove void* casting. (pre_expr_hash): Likewise. (expr_pred_trans_hash): Likewise. (expr_pred_trans_eq): Likewise. (alloc_expression_id): Change types associated with the hash table from void* to their actual type. Remove unnecessary casts. (lookup_expression_id): Likewise. (phi_trans_lookup): Likewise. (phi_trans_add): Likewise. * stringpool.c: Rename uses of libcpp typedef hash_table to cpp_hash_table. * Makefile.in: Add hash-table.o to OBJS-libcommon-target. Add $(HASH_TABLE_H). Add new dependences on $(HASH_TABLE_H). 2012-08-14 Lawrence Crowl <crowl@google.com> Merge from cxx-conversion branch. Re-write double_int in C++. * hash-table.h (typedef double_int): Change to struct (POD). (double_int::make): New overloads for int to double-int conversion. (double_int::mask): New. (double_int::max_value): New. (double_int::min_value): New. (double_int::operator ++): New. (double_int::operator --): New. (double_int::operator *=): New. (double_int::operator +=): New. (double_int::operator -=): New. (double_int::to_signed): New. (double_int::to_unsigned): New. (double_int::fits_unsigned): New. (double_int::fits_signed): New. (double_int::fits): New. (double_int::trailing_zeros): New. (double_int::popcount): New. (double_int::multiple_of): New. (double_int::set_bit): New. (double_int::mul_with_sign): New. (double_int::operator * (binary)): New. (double_int::operator + (binary)): New. (double_int::operator - (binary)): New. (double_int::operator - (unary)): New. (double_int::operator ~ (unary)): New. (double_int::operator & (binary)): New. (double_int::operator | (binary)): New. (double_int::operator ^ (binary)): New. (double_int::and_not): New. (double_int::lshift): New. (double_int::rshift): New. (double_int::alshift): New. (double_int::arshift): New. (double_int::llshift): New. (double_int::lrshift): New. (double_int::lrotate): New. (double_int::rrotate): New. (double_int::div): New. (double_int::sdiv): New. (double_int::udiv): New. (double_int::mod): New. (double_int::smod): New. (double_int::umod): New. (double_int::divmod): New. (double_int::sdivmod): New. (double_int::udivmod): New. (double_int::ext): New. (double_int::zext): New. (double_int::sext): New. (double_int::is_zero): New. (double_int::is_one): New. (double_int::is_minus_one): New. (double_int::is_negative): New. (double_int::cmp): New. (double_int::ucmp): New. (double_int::scmp): New. (double_int::ult): New. (double_int::ugt): New. (double_int::slt): New. (double_int::sgt): New. (double_int::max): New. (double_int::smax): New. (double_int::umax): New. (double_int::min): New. (double_int::smin): New. (double_int::umin): New. (double_int::operator ==): New. (double_int::operator !=): New. (shwi_to_double_int): Change implementation to use member function. (double_int_minus_one): Likewise. (double_int_zero): Likewise. (double_int_one): Likewise. (double_int_two): Likewise. (double_int_ten): Likewise. (uhwi_to_double_int): Likewise. (double_int_to_shwi): Likewise. (double_int_to_uhwi): Likewise. (double_int_fits_in_uhwi_p): Likewise. (double_int_fits_in_shwi_p): Likewise. (double_int_fits_in_hwi_p): Likewise. (double_int_mul): Likewise. (double_int_mul_with_sign): Likewise. (double_int_add): Likewise. (double_int_sub): Likewise. (double_int_neg): Likewise. (double_int_div): Likewise. (double_int_sdiv): Likewise. (double_int_udiv): Likewise. (double_int_mod): Likewise. (double_int_smod): Likewise. (double_int_umod): Likewise. (double_int_divmod): Likewise. (double_int_sdivmod): Likewise. (double_int_udivmod): Likewise. (double_int_multiple_of): Likewise. (double_int_setbit): Likewise. (double_int_ctz): Likewise. (double_int_not): Likewise. (double_int_ior): Likewise. (double_int_and): Likewise. (double_int_and_not): Likewise. (double_int_xor): Likewise. (double_int_lshift): Likewise. (double_int_rshift): Likewise. (double_int_lrotate): Likewise. (double_int_rrotate): Likewise. (double_int_cmp): Likewise. (double_int_scmp): Likewise. (double_int_ucmp): Likewise. (double_int_max): Likewise. (double_int_smax): Likewise. (double_int_umax): Likewise. (double_int_min): Likewise. (double_int_smin): Likewise. (double_int_umin): Likewise. (double_int_ext): Likewise. (double_int_sext): Likewise. (double_int_zext): Likewise. (double_int_mask): Likewise. (double_int_max_value): Likewise. (double_int_min_value): Likewise. (double_int_zero_p): Likewise. (double_int_one_p): Likewise. (double_int_minus_one_p): Likewise. (double_int_equal_p): Likewise. (double_int_popcount): Likewise. * hash-table.c (double_int_mask): Reuse implementation for double_int::mask. (double_int_max_value): Likewise. (double_int_min_value): Likewise. (double_int_ext): Likewise. (double_int_zext): Likewise. (double_int_sext): Likewise. (double_int_mul_with_sign): Likewise. (double_int_divmod): Likewise. (double_int_sdivmod): Likewise. (double_int_udivmod): Likewise. (double_int_div): Likewise. (double_int_sdiv): Likewise. (double_int_udiv): Likewise. (double_int_mod): Likewise. (double_int_smod): Likewise. (double_int_umod): Likewise. (double_int_multiple_of): Likewise. (double_int_lshift): Likewise. (double_int_rshift): Likewise. (double_int_lrotate): Likewise. (double_int_rrotate): Likewise. (double_int_cmp): Likewise. (double_int_ucmp): Likewise. (double_int_scmp): Likewise. (double_int_max): Likewise. (double_int_smax): Likewise. (double_int_umax): Likewise. (double_int_min): Likewise. (double_int_smin): Likewise. (double_int_umin): Likewise. (double_int_min): Likewise. (double_int_min): Likewise. (double_int_min): Likewise. (double_int_min): Likewise. (double_int_min): Likewise. (double_int_min): Likewise. (double_int::alshift): New. (double_int::arshift): New. (double_int::llshift): New. (double_int::lrshift): New. (double_int::ult): New. (double_int::ugt): New. (double_int::slt): New. (double_int::sgt): New. (double_int_setbit): Reuse implementation for double_int::set_bit, which avoids a name conflict with a macro. (double_int_double_int_ctz): Reuse implementation for double_int::trailing_zeros. (double_int_fits_in_shwi_p): Reuse implementation for double_int::fits_signed. (double_int_fits_in_hwi_p): Reuse implementation for double_int::fits. (double_int_mul): Reuse implementation for binary double_int::operator *. (double_int_add): Likewise. (double_int_sub): Likewise. (double_int_neg): Reuse implementation for unary double_int::operator -. (double_int_max_value): Likewise. * fixed-value.c: Change to use member functions introduced above. 2012-08-14 Lawrence Crowl <crowl@google.com> Merge cxx-conversion branch. Support tree macro calling from gdb. * tree.h (tree_check): New. (TREE_CHECK): Use inline function above instead of __extension__. (tree_not_check): New. (TREE_NOT_CHECK): Use inline function above instead of __extension__. (tree_check2): New. (TREE_CHECK2): Use inline function above instead of __extension__. (tree_not_check2): New. (TREE_NOT_CHECK2): Use inline function above instead of __extension__. (tree_check3): New. (TREE_CHECK3): Use inline function above instead of __extension__. (tree_not_check3): New. (TREE_NOT_CHECK3): Use inline function above instead of __extension__. (tree_check4): New. (TREE_CHECK4): Use inline function above instead of __extension__. (tree_not_check4): New. (TREE_NOT_CHECK4): Use inline function above instead of __extension__. (tree_check5): New. (TREE_CHECK5): Use inline function above instead of __extension__. (tree_not_check5): New. (TREE_NOT_CHECK5): Use inline function above instead of __extension__. (contains_struct_check): New. (CONTAINS_STRUCT_CHECK): Use inline function above instead of __extension__. (tree_class_check): New. (TREE_CLASS_CHECK): Use inline function above instead of __extension__. (tree_range_check): New. (TREE_RANGE_CHECK): Use inline function above instead of __extension__. (omp_clause_subcode_check): New. (OMP_CLAUSE_SUBCODE_CHECK): Use inline function above instead of __extension__. (omp_clause_range_check): New. (OMP_CLAUSE_RANGE_CHECK): Use inline function above instead of __extension__. (expr_check): New. (EXPR_CHECK): Use inline function above instead of __extension__. (non_type_check): New. (NON_TYPE_CHECK): Use inline function above instead of __extension__. (tree_vec_elt_check): New. (TREE_VEC_ELT_CHECK): Use inline function above instead of __extension__. (omp_clause_elt_check): New. (OMP_CLAUSE_ELT_CHECK): Use inline function above instead of __extension__. (tree_operand_check): New. (TREE_OPERAND_CHECK): Use inline function above instead of __extension__. (tree_operand_check_code): New. (TREE_OPERAND_CHECK_CODE): Use inline function above instead of __extension__. (TREE_CHAIN): Simplify implementation. (TREE_TYPE): Simplify implementation. (tree_operand_length): Move for compilation dependences. * gdbinit.in: (macro define __FILE__): New. (macro define __LINE__): New. (skip "tree.h"): New. gcc/cp/ChangeLog 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. Re-write VEC in C++. * call.c (add_function_candidate): Remove const qualifier from call to VEC_index. 2012-08-14 Diego Novillo <dnovillo@google.com> Merge from cxx-conversion branch. Configury. * go-c.h: Remove all handlers of ENABLE_BUILD_WITH_CXX. * go-gcc.cc: Likewise. * go-system.h: Likewise. From-SVN: r190402
872 lines
29 KiB
C
872 lines
29 KiB
C
/* Part of CPP library.
|
|
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
|
|
2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the
|
|
Free Software Foundation; either version 3, or (at your option) any
|
|
later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* This header defines all the internal data structures and functions
|
|
that need to be visible across files. It should not be used outside
|
|
cpplib. */
|
|
|
|
#ifndef LIBCPP_INTERNAL_H
|
|
#define LIBCPP_INTERNAL_H
|
|
|
|
#include "symtab.h"
|
|
#include "cpp-id-data.h"
|
|
|
|
#if HAVE_ICONV
|
|
#include <iconv.h>
|
|
#else
|
|
#define HAVE_ICONV 0
|
|
typedef int iconv_t; /* dummy */
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct directive; /* Deliberately incomplete. */
|
|
struct pending_option;
|
|
struct op;
|
|
struct _cpp_strbuf;
|
|
|
|
typedef bool (*convert_f) (iconv_t, const unsigned char *, size_t,
|
|
struct _cpp_strbuf *);
|
|
struct cset_converter
|
|
{
|
|
convert_f func;
|
|
iconv_t cd;
|
|
int width;
|
|
};
|
|
|
|
#define BITS_PER_CPPCHAR_T (CHAR_BIT * sizeof (cppchar_t))
|
|
|
|
/* Test if a sign is valid within a preprocessing number. */
|
|
#define VALID_SIGN(c, prevc) \
|
|
(((c) == '+' || (c) == '-') && \
|
|
((prevc) == 'e' || (prevc) == 'E' \
|
|
|| (((prevc) == 'p' || (prevc) == 'P') \
|
|
&& CPP_OPTION (pfile, extended_numbers))))
|
|
|
|
#define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
|
|
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
|
|
#define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base)
|
|
#define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur)
|
|
|
|
#define CPP_INCREMENT_LINE(PFILE, COLS_HINT) do { \
|
|
const struct line_maps *line_table = PFILE->line_table; \
|
|
const struct line_map *map = \
|
|
LINEMAPS_LAST_ORDINARY_MAP (line_table); \
|
|
linenum_type line = SOURCE_LINE (map, line_table->highest_line); \
|
|
linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \
|
|
} while (0)
|
|
|
|
/* Maximum nesting of cpp_buffers. We use a static limit, partly for
|
|
efficiency, and partly to limit runaway recursion. */
|
|
#define CPP_STACK_MAX 200
|
|
|
|
/* Host alignment handling. */
|
|
struct dummy
|
|
{
|
|
char c;
|
|
union
|
|
{
|
|
double d;
|
|
int *p;
|
|
} u;
|
|
};
|
|
|
|
#define DEFAULT_ALIGNMENT offsetof (struct dummy, u)
|
|
#define CPP_ALIGN2(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
|
|
#define CPP_ALIGN(size) CPP_ALIGN2 (size, DEFAULT_ALIGNMENT)
|
|
|
|
#define _cpp_mark_macro_used(NODE) do { \
|
|
if ((NODE)->type == NT_MACRO && !((NODE)->flags & NODE_BUILTIN)) \
|
|
(NODE)->value.macro->used = 1; } while (0)
|
|
|
|
/* A generic memory buffer, and operations on it. */
|
|
typedef struct _cpp_buff _cpp_buff;
|
|
struct _cpp_buff
|
|
{
|
|
struct _cpp_buff *next;
|
|
unsigned char *base, *cur, *limit;
|
|
};
|
|
|
|
extern _cpp_buff *_cpp_get_buff (cpp_reader *, size_t);
|
|
extern void _cpp_release_buff (cpp_reader *, _cpp_buff *);
|
|
extern void _cpp_extend_buff (cpp_reader *, _cpp_buff **, size_t);
|
|
extern _cpp_buff *_cpp_append_extend_buff (cpp_reader *, _cpp_buff *, size_t);
|
|
extern void _cpp_free_buff (_cpp_buff *);
|
|
extern unsigned char *_cpp_aligned_alloc (cpp_reader *, size_t);
|
|
extern unsigned char *_cpp_unaligned_alloc (cpp_reader *, size_t);
|
|
|
|
#define BUFF_ROOM(BUFF) (size_t) ((BUFF)->limit - (BUFF)->cur)
|
|
#define BUFF_FRONT(BUFF) ((BUFF)->cur)
|
|
#define BUFF_LIMIT(BUFF) ((BUFF)->limit)
|
|
|
|
/* #include types. */
|
|
enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE};
|
|
|
|
union utoken
|
|
{
|
|
const cpp_token *token;
|
|
const cpp_token **ptoken;
|
|
};
|
|
|
|
/* A "run" of tokens; part of a chain of runs. */
|
|
typedef struct tokenrun tokenrun;
|
|
struct tokenrun
|
|
{
|
|
tokenrun *next, *prev;
|
|
cpp_token *base, *limit;
|
|
};
|
|
|
|
/* Accessor macros for struct cpp_context. */
|
|
#define FIRST(c) ((c)->u.iso.first)
|
|
#define LAST(c) ((c)->u.iso.last)
|
|
#define CUR(c) ((c)->u.trad.cur)
|
|
#define RLIMIT(c) ((c)->u.trad.rlimit)
|
|
|
|
/* This describes some additional data that is added to the macro
|
|
token context of type cpp_context, when -ftrack-macro-expansion is
|
|
on. */
|
|
typedef struct
|
|
{
|
|
/* The node of the macro we are referring to. */
|
|
cpp_hashnode *macro_node;
|
|
/* This buffer contains an array of virtual locations. The virtual
|
|
location at index 0 is the virtual location of the token at index
|
|
0 in the current instance of cpp_context; similarly for all the
|
|
other virtual locations. */
|
|
source_location *virt_locs;
|
|
/* This is a pointer to the current virtual location. This is used
|
|
to iterate over the virtual locations while we iterate over the
|
|
tokens they belong to. */
|
|
source_location *cur_virt_loc;
|
|
} macro_context;
|
|
|
|
/* The kind of tokens carried by a cpp_context. */
|
|
enum context_tokens_kind {
|
|
/* This is the value of cpp_context::tokens_kind if u.iso.first
|
|
contains an instance of cpp_token **. */
|
|
TOKENS_KIND_INDIRECT,
|
|
/* This is the value of cpp_context::tokens_kind if u.iso.first
|
|
contains an instance of cpp_token *. */
|
|
TOKENS_KIND_DIRECT,
|
|
/* This is the value of cpp_context::tokens_kind when the token
|
|
context contains tokens resulting from macro expansion. In that
|
|
case struct cpp_context::macro points to an instance of struct
|
|
macro_context. This is used only when the
|
|
-ftrack-macro-expansion flag is on. */
|
|
TOKENS_KIND_EXTENDED
|
|
};
|
|
|
|
typedef struct cpp_context cpp_context;
|
|
struct cpp_context
|
|
{
|
|
/* Doubly-linked list. */
|
|
cpp_context *next, *prev;
|
|
|
|
union
|
|
{
|
|
/* For ISO macro expansion. Contexts other than the base context
|
|
are contiguous tokens. e.g. macro expansions, expanded
|
|
argument tokens. */
|
|
struct
|
|
{
|
|
union utoken first;
|
|
union utoken last;
|
|
} iso;
|
|
|
|
/* For traditional macro expansion. */
|
|
struct
|
|
{
|
|
const unsigned char *cur;
|
|
const unsigned char *rlimit;
|
|
} trad;
|
|
} u;
|
|
|
|
/* If non-NULL, a buffer used for storage related to this context.
|
|
When the context is popped, the buffer is released. */
|
|
_cpp_buff *buff;
|
|
|
|
/* If tokens_kind is TOKEN_KIND_EXTENDED, then (as we thus are in a
|
|
macro context) this is a pointer to an instance of macro_context.
|
|
Otherwise if tokens_kind is *not* TOKEN_KIND_EXTENDED, then, if
|
|
we are in a macro context, this is a pointer to an instance of
|
|
cpp_hashnode, representing the name of the macro this context is
|
|
for. If we are not in a macro context, then this is just NULL.
|
|
Note that when tokens_kind is TOKEN_KIND_EXTENDED, the memory
|
|
used by the instance of macro_context pointed to by this member
|
|
is de-allocated upon de-allocation of the instance of struct
|
|
cpp_context. */
|
|
union
|
|
{
|
|
macro_context *mc;
|
|
cpp_hashnode *macro;
|
|
} c;
|
|
|
|
/* This determines the type of tokens held by this context. */
|
|
enum context_tokens_kind tokens_kind;
|
|
};
|
|
|
|
struct lexer_state
|
|
{
|
|
/* Nonzero if first token on line is CPP_HASH. */
|
|
unsigned char in_directive;
|
|
|
|
/* Nonzero if in a directive that will handle padding tokens itself.
|
|
#include needs this to avoid problems with computed include and
|
|
spacing between tokens. */
|
|
unsigned char directive_wants_padding;
|
|
|
|
/* True if we are skipping a failed conditional group. */
|
|
unsigned char skipping;
|
|
|
|
/* Nonzero if in a directive that takes angle-bracketed headers. */
|
|
unsigned char angled_headers;
|
|
|
|
/* Nonzero if in a #if or #elif directive. */
|
|
unsigned char in_expression;
|
|
|
|
/* Nonzero to save comments. Turned off if discard_comments, and in
|
|
all directives apart from #define. */
|
|
unsigned char save_comments;
|
|
|
|
/* Nonzero if lexing __VA_ARGS__ is valid. */
|
|
unsigned char va_args_ok;
|
|
|
|
/* Nonzero if lexing poisoned identifiers is valid. */
|
|
unsigned char poisoned_ok;
|
|
|
|
/* Nonzero to prevent macro expansion. */
|
|
unsigned char prevent_expansion;
|
|
|
|
/* Nonzero when parsing arguments to a function-like macro. */
|
|
unsigned char parsing_args;
|
|
|
|
/* Nonzero if prevent_expansion is true only because output is
|
|
being discarded. */
|
|
unsigned char discarding_output;
|
|
|
|
/* Nonzero to skip evaluating part of an expression. */
|
|
unsigned int skip_eval;
|
|
|
|
/* Nonzero when handling a deferred pragma. */
|
|
unsigned char in_deferred_pragma;
|
|
|
|
/* Nonzero if the deferred pragma being handled allows macro expansion. */
|
|
unsigned char pragma_allow_expansion;
|
|
};
|
|
|
|
/* Special nodes - identifiers with predefined significance. */
|
|
struct spec_nodes
|
|
{
|
|
cpp_hashnode *n_defined; /* defined operator */
|
|
cpp_hashnode *n_true; /* C++ keyword true */
|
|
cpp_hashnode *n_false; /* C++ keyword false */
|
|
cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */
|
|
};
|
|
|
|
typedef struct _cpp_line_note _cpp_line_note;
|
|
struct _cpp_line_note
|
|
{
|
|
/* Location in the clean line the note refers to. */
|
|
const unsigned char *pos;
|
|
|
|
/* Type of note. The 9 'from' trigraph characters represent those
|
|
trigraphs, '\\' an escaped newline, ' ' an escaped newline with
|
|
intervening space, 0 represents a note that has already been handled,
|
|
and anything else is invalid. */
|
|
unsigned int type;
|
|
};
|
|
|
|
/* Represents the contents of a file cpplib has read in. */
|
|
struct cpp_buffer
|
|
{
|
|
const unsigned char *cur; /* Current location. */
|
|
const unsigned char *line_base; /* Start of current physical line. */
|
|
const unsigned char *next_line; /* Start of to-be-cleaned logical line. */
|
|
|
|
const unsigned char *buf; /* Entire character buffer. */
|
|
const unsigned char *rlimit; /* Writable byte at end of file. */
|
|
|
|
_cpp_line_note *notes; /* Array of notes. */
|
|
unsigned int cur_note; /* Next note to process. */
|
|
unsigned int notes_used; /* Number of notes. */
|
|
unsigned int notes_cap; /* Size of allocated array. */
|
|
|
|
struct cpp_buffer *prev;
|
|
|
|
/* Pointer into the file table; non-NULL if this is a file buffer.
|
|
Used for include_next and to record control macros. */
|
|
struct _cpp_file *file;
|
|
|
|
/* Saved value of __TIMESTAMP__ macro - date and time of last modification
|
|
of the assotiated file. */
|
|
const unsigned char *timestamp;
|
|
|
|
/* Value of if_stack at start of this file.
|
|
Used to prohibit unmatched #endif (etc) in an include file. */
|
|
struct if_stack *if_stack;
|
|
|
|
/* True if we need to get the next clean line. */
|
|
bool need_line;
|
|
|
|
/* True if we have already warned about C++ comments in this file.
|
|
The warning happens only for C89 extended mode with -pedantic on,
|
|
or for -Wtraditional, and only once per file (otherwise it would
|
|
be far too noisy). */
|
|
unsigned int warned_cplusplus_comments : 1;
|
|
|
|
/* True if we don't process trigraphs and escaped newlines. True
|
|
for preprocessed input, command line directives, and _Pragma
|
|
buffers. */
|
|
unsigned int from_stage3 : 1;
|
|
|
|
/* At EOF, a buffer is automatically popped. If RETURN_AT_EOF is
|
|
true, a CPP_EOF token is then returned. Otherwise, the next
|
|
token from the enclosing buffer is returned. */
|
|
unsigned int return_at_eof : 1;
|
|
|
|
/* One for a system header, two for a C system header file that therefore
|
|
needs to be extern "C" protected in C++, and zero otherwise. */
|
|
unsigned char sysp;
|
|
|
|
/* The directory of the this buffer's file. Its NAME member is not
|
|
allocated, so we don't need to worry about freeing it. */
|
|
struct cpp_dir dir;
|
|
|
|
/* Descriptor for converting from the input character set to the
|
|
source character set. */
|
|
struct cset_converter input_cset_desc;
|
|
};
|
|
|
|
/* The list of saved macros by push_macro pragma. */
|
|
struct def_pragma_macro {
|
|
/* Chain element to previous saved macro. */
|
|
struct def_pragma_macro *next;
|
|
/* Name of the macro. */
|
|
char *name;
|
|
/* The stored macro content. */
|
|
unsigned char *definition;
|
|
|
|
/* Definition line number. */
|
|
source_location line;
|
|
/* If macro defined in system header. */
|
|
unsigned int syshdr : 1;
|
|
/* Nonzero if it has been expanded or had its existence tested. */
|
|
unsigned int used : 1;
|
|
|
|
/* Mark if we save an undefined macro. */
|
|
unsigned int is_undef : 1;
|
|
};
|
|
|
|
/* A cpp_reader encapsulates the "state" of a pre-processor run.
|
|
Applying cpp_get_token repeatedly yields a stream of pre-processor
|
|
tokens. Usually, there is only one cpp_reader object active. */
|
|
struct cpp_reader
|
|
{
|
|
/* Top of buffer stack. */
|
|
cpp_buffer *buffer;
|
|
|
|
/* Overlaid buffer (can be different after processing #include). */
|
|
cpp_buffer *overlaid_buffer;
|
|
|
|
/* Lexer state. */
|
|
struct lexer_state state;
|
|
|
|
/* Source line tracking. */
|
|
struct line_maps *line_table;
|
|
|
|
/* The line of the '#' of the current directive. */
|
|
source_location directive_line;
|
|
|
|
/* Memory buffers. */
|
|
_cpp_buff *a_buff; /* Aligned permanent storage. */
|
|
_cpp_buff *u_buff; /* Unaligned permanent storage. */
|
|
_cpp_buff *free_buffs; /* Free buffer chain. */
|
|
|
|
/* Context stack. */
|
|
struct cpp_context base_context;
|
|
struct cpp_context *context;
|
|
|
|
/* If in_directive, the directive if known. */
|
|
const struct directive *directive;
|
|
|
|
/* Token generated while handling a directive, if any. */
|
|
cpp_token directive_result;
|
|
|
|
/* When expanding a macro at top-level, this is the location of the
|
|
macro invocation. */
|
|
source_location invocation_location;
|
|
|
|
/* Nonzero if we are about to expand a macro. Note that if we are
|
|
really expanding a macro, the function macro_of_context returns
|
|
the macro being expanded and this flag is set to false. Client
|
|
code should use the function in_macro_expansion_p to know if we
|
|
are either about to expand a macro, or are actually expanding
|
|
one. */
|
|
bool about_to_expand_macro_p;
|
|
|
|
/* Search paths for include files. */
|
|
struct cpp_dir *quote_include; /* "" */
|
|
struct cpp_dir *bracket_include; /* <> */
|
|
struct cpp_dir no_search_path; /* No path. */
|
|
|
|
/* Chain of all hashed _cpp_file instances. */
|
|
struct _cpp_file *all_files;
|
|
|
|
struct _cpp_file *main_file;
|
|
|
|
/* File and directory hash table. */
|
|
struct htab *file_hash;
|
|
struct htab *dir_hash;
|
|
struct file_hash_entry_pool *file_hash_entries;
|
|
|
|
/* Negative path lookup hash table. */
|
|
struct htab *nonexistent_file_hash;
|
|
struct obstack nonexistent_file_ob;
|
|
|
|
/* Nonzero means don't look for #include "foo" the source-file
|
|
directory. */
|
|
bool quote_ignores_source_dir;
|
|
|
|
/* Nonzero if any file has contained #pragma once or #import has
|
|
been used. */
|
|
bool seen_once_only;
|
|
|
|
/* Multiple include optimization. */
|
|
const cpp_hashnode *mi_cmacro;
|
|
const cpp_hashnode *mi_ind_cmacro;
|
|
bool mi_valid;
|
|
|
|
/* Lexing. */
|
|
cpp_token *cur_token;
|
|
tokenrun base_run, *cur_run;
|
|
unsigned int lookaheads;
|
|
|
|
/* Nonzero prevents the lexer from re-using the token runs. */
|
|
unsigned int keep_tokens;
|
|
|
|
/* Buffer to hold macro definition string. */
|
|
unsigned char *macro_buffer;
|
|
unsigned int macro_buffer_len;
|
|
|
|
/* Descriptor for converting from the source character set to the
|
|
execution character set. */
|
|
struct cset_converter narrow_cset_desc;
|
|
|
|
/* Descriptor for converting from the source character set to the
|
|
UTF-8 execution character set. */
|
|
struct cset_converter utf8_cset_desc;
|
|
|
|
/* Descriptor for converting from the source character set to the
|
|
UTF-16 execution character set. */
|
|
struct cset_converter char16_cset_desc;
|
|
|
|
/* Descriptor for converting from the source character set to the
|
|
UTF-32 execution character set. */
|
|
struct cset_converter char32_cset_desc;
|
|
|
|
/* Descriptor for converting from the source character set to the
|
|
wide execution character set. */
|
|
struct cset_converter wide_cset_desc;
|
|
|
|
/* Date and time text. Calculated together if either is requested. */
|
|
const unsigned char *date;
|
|
const unsigned char *time;
|
|
|
|
/* EOF token, and a token forcing paste avoidance. */
|
|
cpp_token avoid_paste;
|
|
cpp_token eof;
|
|
|
|
/* Opaque handle to the dependencies of mkdeps.c. */
|
|
struct deps *deps;
|
|
|
|
/* Obstack holding all macro hash nodes. This never shrinks.
|
|
See identifiers.c */
|
|
struct obstack hash_ob;
|
|
|
|
/* Obstack holding buffer and conditional structures. This is a
|
|
real stack. See directives.c. */
|
|
struct obstack buffer_ob;
|
|
|
|
/* Pragma table - dynamic, because a library user can add to the
|
|
list of recognized pragmas. */
|
|
struct pragma_entry *pragmas;
|
|
|
|
/* Call backs to cpplib client. */
|
|
struct cpp_callbacks cb;
|
|
|
|
/* Identifier hash table. */
|
|
struct ht *hash_table;
|
|
|
|
/* Expression parser stack. */
|
|
struct op *op_stack, *op_limit;
|
|
|
|
/* User visible options. */
|
|
struct cpp_options opts;
|
|
|
|
/* Special nodes - identifiers with predefined significance to the
|
|
preprocessor. */
|
|
struct spec_nodes spec_nodes;
|
|
|
|
/* Whether cpplib owns the hashtable. */
|
|
bool our_hashtable;
|
|
|
|
/* Traditional preprocessing output buffer (a logical line). */
|
|
struct
|
|
{
|
|
unsigned char *base;
|
|
unsigned char *limit;
|
|
unsigned char *cur;
|
|
source_location first_line;
|
|
} out;
|
|
|
|
/* Used for buffer overlays by traditional.c. */
|
|
const unsigned char *saved_cur, *saved_rlimit, *saved_line_base;
|
|
|
|
/* A saved list of the defined macros, for dependency checking
|
|
of precompiled headers. */
|
|
struct cpp_savedstate *savedstate;
|
|
|
|
/* Next value of __COUNTER__ macro. */
|
|
unsigned int counter;
|
|
|
|
/* Table of comments, when state.save_comments is true. */
|
|
cpp_comment_table comments;
|
|
|
|
/* List of saved macros by push_macro. */
|
|
struct def_pragma_macro *pushed_macros;
|
|
|
|
/* If non-null, the lexer will use this location for the next token
|
|
instead of getting a location from the linemap. */
|
|
source_location *forced_token_location_p;
|
|
};
|
|
|
|
/* Character classes. Based on the more primitive macros in safe-ctype.h.
|
|
If the definition of `numchar' looks odd to you, please look up the
|
|
definition of a pp-number in the C standard [section 6.4.8 of C99].
|
|
|
|
In the unlikely event that characters other than \r and \n enter
|
|
the set is_vspace, the macro handle_newline() in lex.c must be
|
|
updated. */
|
|
#define _dollar_ok(x) ((x) == '$' && CPP_OPTION (pfile, dollars_in_ident))
|
|
|
|
#define is_idchar(x) (ISIDNUM(x) || _dollar_ok(x))
|
|
#define is_numchar(x) ISIDNUM(x)
|
|
#define is_idstart(x) (ISIDST(x) || _dollar_ok(x))
|
|
#define is_numstart(x) ISDIGIT(x)
|
|
#define is_hspace(x) ISBLANK(x)
|
|
#define is_vspace(x) IS_VSPACE(x)
|
|
#define is_nvspace(x) IS_NVSPACE(x)
|
|
#define is_space(x) IS_SPACE_OR_NUL(x)
|
|
|
|
/* This table is constant if it can be initialized at compile time,
|
|
which is the case if cpp was compiled with GCC >=2.7, or another
|
|
compiler that supports C99. */
|
|
#if HAVE_DESIGNATED_INITIALIZERS
|
|
extern const unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
|
|
#else
|
|
extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
|
|
#endif
|
|
|
|
/* Macros. */
|
|
|
|
static inline int cpp_in_system_header (cpp_reader *);
|
|
static inline int
|
|
cpp_in_system_header (cpp_reader *pfile)
|
|
{
|
|
return pfile->buffer ? pfile->buffer->sysp : 0;
|
|
}
|
|
#define CPP_PEDANTIC(PF) CPP_OPTION (PF, cpp_pedantic)
|
|
#define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, cpp_warn_traditional)
|
|
|
|
static inline int cpp_in_primary_file (cpp_reader *);
|
|
static inline int
|
|
cpp_in_primary_file (cpp_reader *pfile)
|
|
{
|
|
return pfile->line_table->depth == 1;
|
|
}
|
|
|
|
/* In macro.c */
|
|
extern void _cpp_free_definition (cpp_hashnode *);
|
|
extern bool _cpp_create_definition (cpp_reader *, cpp_hashnode *);
|
|
extern void _cpp_pop_context (cpp_reader *);
|
|
extern void _cpp_push_text_context (cpp_reader *, cpp_hashnode *,
|
|
const unsigned char *, size_t);
|
|
extern bool _cpp_save_parameter (cpp_reader *, cpp_macro *, cpp_hashnode *);
|
|
extern bool _cpp_arguments_ok (cpp_reader *, cpp_macro *, const cpp_hashnode *,
|
|
unsigned int);
|
|
extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *,
|
|
cpp_hashnode *);
|
|
extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *);
|
|
extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *,
|
|
const cpp_token *, unsigned int);
|
|
extern void _cpp_backup_tokens_direct (cpp_reader *, unsigned int);
|
|
|
|
/* In identifiers.c */
|
|
extern void _cpp_init_hashtable (cpp_reader *, cpp_hash_table *);
|
|
extern void _cpp_destroy_hashtable (cpp_reader *);
|
|
|
|
/* In files.c */
|
|
typedef struct _cpp_file _cpp_file;
|
|
extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *,
|
|
bool, int);
|
|
extern bool _cpp_find_failed (_cpp_file *);
|
|
extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *);
|
|
extern void _cpp_fake_include (cpp_reader *, const char *);
|
|
extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, bool);
|
|
extern bool _cpp_stack_include (cpp_reader *, const char *, int,
|
|
enum include_type);
|
|
extern int _cpp_compare_file_date (cpp_reader *, const char *, int);
|
|
extern void _cpp_report_missing_guards (cpp_reader *);
|
|
extern void _cpp_init_files (cpp_reader *);
|
|
extern void _cpp_cleanup_files (cpp_reader *);
|
|
extern void _cpp_pop_file_buffer (cpp_reader *, struct _cpp_file *);
|
|
extern bool _cpp_save_file_entries (cpp_reader *pfile, FILE *f);
|
|
extern bool _cpp_read_file_entries (cpp_reader *, FILE *);
|
|
extern const char *_cpp_get_file_name (_cpp_file *);
|
|
extern struct stat *_cpp_get_file_stat (_cpp_file *);
|
|
|
|
/* In expr.c */
|
|
extern bool _cpp_parse_expr (cpp_reader *, bool);
|
|
extern struct op *_cpp_expand_op_stack (cpp_reader *);
|
|
|
|
/* In lex.c */
|
|
extern void _cpp_process_line_notes (cpp_reader *, int);
|
|
extern void _cpp_clean_line (cpp_reader *);
|
|
extern bool _cpp_get_fresh_line (cpp_reader *);
|
|
extern bool _cpp_skip_block_comment (cpp_reader *);
|
|
extern cpp_token *_cpp_temp_token (cpp_reader *);
|
|
extern const cpp_token *_cpp_lex_token (cpp_reader *);
|
|
extern cpp_token *_cpp_lex_direct (cpp_reader *);
|
|
extern int _cpp_equiv_tokens (const cpp_token *, const cpp_token *);
|
|
extern void _cpp_init_tokenrun (tokenrun *, unsigned int);
|
|
extern cpp_hashnode *_cpp_lex_identifier (cpp_reader *, const char *);
|
|
extern int _cpp_remaining_tokens_num_in_context (cpp_context *);
|
|
extern void _cpp_init_lexer (void);
|
|
|
|
/* In init.c. */
|
|
extern void _cpp_maybe_push_include_file (cpp_reader *);
|
|
extern const char *cpp_named_operator2name (enum cpp_ttype type);
|
|
|
|
/* In directives.c */
|
|
extern int _cpp_test_assertion (cpp_reader *, unsigned int *);
|
|
extern int _cpp_handle_directive (cpp_reader *, int);
|
|
extern void _cpp_define_builtin (cpp_reader *, const char *);
|
|
extern char ** _cpp_save_pragma_names (cpp_reader *);
|
|
extern void _cpp_restore_pragma_names (cpp_reader *, char **);
|
|
extern int _cpp_do__Pragma (cpp_reader *);
|
|
extern void _cpp_init_directives (cpp_reader *);
|
|
extern void _cpp_init_internal_pragmas (cpp_reader *);
|
|
extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
|
|
linenum_type, unsigned int);
|
|
extern void _cpp_pop_buffer (cpp_reader *);
|
|
|
|
/* In directives.c */
|
|
struct _cpp_dir_only_callbacks
|
|
{
|
|
/* Called to print a block of lines. */
|
|
void (*print_lines) (int, const void *, size_t);
|
|
void (*maybe_print_line) (source_location);
|
|
};
|
|
|
|
extern void _cpp_preprocess_dir_only (cpp_reader *,
|
|
const struct _cpp_dir_only_callbacks *);
|
|
|
|
/* In traditional.c. */
|
|
extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *);
|
|
extern bool _cpp_read_logical_line_trad (cpp_reader *);
|
|
extern void _cpp_overlay_buffer (cpp_reader *pfile, const unsigned char *,
|
|
size_t);
|
|
extern void _cpp_remove_overlay (cpp_reader *);
|
|
extern bool _cpp_create_trad_definition (cpp_reader *, cpp_macro *);
|
|
extern bool _cpp_expansions_different_trad (const cpp_macro *,
|
|
const cpp_macro *);
|
|
extern unsigned char *_cpp_copy_replacement_text (const cpp_macro *,
|
|
unsigned char *);
|
|
extern size_t _cpp_replacement_text_len (const cpp_macro *);
|
|
|
|
/* In charset.c. */
|
|
|
|
/* The normalization state at this point in the sequence.
|
|
It starts initialized to all zeros, and at the end
|
|
'level' is the normalization level of the sequence. */
|
|
|
|
struct normalize_state
|
|
{
|
|
/* The previous character. */
|
|
cppchar_t previous;
|
|
/* The combining class of the previous character. */
|
|
unsigned char prev_class;
|
|
/* The lowest normalization level so far. */
|
|
enum cpp_normalize_level level;
|
|
};
|
|
#define INITIAL_NORMALIZE_STATE { 0, 0, normalized_KC }
|
|
#define NORMALIZE_STATE_RESULT(st) ((st)->level)
|
|
|
|
/* We saw a character that matches ISIDNUM(), update a
|
|
normalize_state appropriately. */
|
|
#define NORMALIZE_STATE_UPDATE_IDNUM(st) \
|
|
((st)->previous = 0, (st)->prev_class = 0)
|
|
|
|
extern cppchar_t _cpp_valid_ucn (cpp_reader *, const unsigned char **,
|
|
const unsigned char *, int,
|
|
struct normalize_state *state);
|
|
extern void _cpp_destroy_iconv (cpp_reader *);
|
|
extern unsigned char *_cpp_convert_input (cpp_reader *, const char *,
|
|
unsigned char *, size_t, size_t,
|
|
const unsigned char **, off_t *);
|
|
extern const char *_cpp_default_encoding (void);
|
|
extern cpp_hashnode * _cpp_interpret_identifier (cpp_reader *pfile,
|
|
const unsigned char *id,
|
|
size_t len);
|
|
|
|
/* Utility routines and macros. */
|
|
#define DSC(str) (const unsigned char *)str, sizeof str - 1
|
|
|
|
/* These are inline functions instead of macros so we can get type
|
|
checking. */
|
|
static inline int ustrcmp (const unsigned char *, const unsigned char *);
|
|
static inline int ustrncmp (const unsigned char *, const unsigned char *,
|
|
size_t);
|
|
static inline size_t ustrlen (const unsigned char *);
|
|
static inline const unsigned char *uxstrdup (const unsigned char *);
|
|
static inline const unsigned char *ustrchr (const unsigned char *, int);
|
|
static inline int ufputs (const unsigned char *, FILE *);
|
|
|
|
/* Use a const char for the second parameter since it is usually a literal. */
|
|
static inline int ustrcspn (const unsigned char *, const char *);
|
|
|
|
static inline int
|
|
ustrcmp (const unsigned char *s1, const unsigned char *s2)
|
|
{
|
|
return strcmp ((const char *)s1, (const char *)s2);
|
|
}
|
|
|
|
static inline int
|
|
ustrncmp (const unsigned char *s1, const unsigned char *s2, size_t n)
|
|
{
|
|
return strncmp ((const char *)s1, (const char *)s2, n);
|
|
}
|
|
|
|
static inline int
|
|
ustrcspn (const unsigned char *s1, const char *s2)
|
|
{
|
|
return strcspn ((const char *)s1, s2);
|
|
}
|
|
|
|
static inline size_t
|
|
ustrlen (const unsigned char *s1)
|
|
{
|
|
return strlen ((const char *)s1);
|
|
}
|
|
|
|
static inline const unsigned char *
|
|
uxstrdup (const unsigned char *s1)
|
|
{
|
|
return (const unsigned char *) xstrdup ((const char *)s1);
|
|
}
|
|
|
|
static inline const unsigned char *
|
|
ustrchr (const unsigned char *s1, int c)
|
|
{
|
|
return (const unsigned char *) strchr ((const char *)s1, c);
|
|
}
|
|
|
|
static inline int
|
|
ufputs (const unsigned char *s, FILE *f)
|
|
{
|
|
return fputs ((const char *)s, f);
|
|
}
|
|
|
|
/* In line-map.c. */
|
|
|
|
/* Create a macro map. A macro map encodes source locations of tokens
|
|
that are part of a macro replacement-list, at a macro expansion
|
|
point. See the extensive comments of struct line_map and struct
|
|
line_map_macro, in line-map.h.
|
|
|
|
This map shall be created when the macro is expanded. The map
|
|
encodes the source location of the expansion point of the macro as
|
|
well as the "original" source location of each token that is part
|
|
of the macro replacement-list. If a macro is defined but never
|
|
expanded, it has no macro map. SET is the set of maps the macro
|
|
map should be part of. MACRO_NODE is the macro which the new macro
|
|
map should encode source locations for. EXPANSION is the location
|
|
of the expansion point of MACRO. For function-like macros
|
|
invocations, it's best to make it point to the closing parenthesis
|
|
of the macro, rather than the the location of the first character
|
|
of the macro. NUM_TOKENS is the number of tokens that are part of
|
|
the replacement-list of MACRO. */
|
|
const struct line_map *linemap_enter_macro (struct line_maps *,
|
|
struct cpp_hashnode*,
|
|
source_location,
|
|
unsigned int);
|
|
|
|
/* Create and return a virtual location for a token that is part of a
|
|
macro expansion-list at a macro expansion point. See the comment
|
|
inside struct line_map_macro to see what an expansion-list exactly
|
|
is.
|
|
|
|
A call to this function must come after a call to
|
|
linemap_enter_macro.
|
|
|
|
MAP is the map into which the source location is created. TOKEN_NO
|
|
is the index of the token in the macro replacement-list, starting
|
|
at number 0.
|
|
|
|
ORIG_LOC is the location of the token outside of this macro
|
|
expansion. If the token comes originally from the macro
|
|
definition, it is the locus in the macro definition; otherwise it
|
|
is a location in the context of the caller of this macro expansion
|
|
(which is a virtual location or a source location if the caller is
|
|
itself a macro expansion or not).
|
|
|
|
MACRO_DEFINITION_LOC is the location in the macro definition,
|
|
either of the token itself or of a macro parameter that it
|
|
replaces. */
|
|
source_location linemap_add_macro_token (const struct line_map *,
|
|
unsigned int,
|
|
source_location,
|
|
source_location);
|
|
|
|
/* Return the source line number corresponding to source location
|
|
LOCATION. SET is the line map set LOCATION comes from. If
|
|
LOCATION is the location of token that is part of the
|
|
expansion-list of a macro expansion return the line number of the
|
|
macro expansion point. */
|
|
int linemap_get_expansion_line (struct line_maps *,
|
|
source_location);
|
|
|
|
/* Return the path of the file corresponding to source code location
|
|
LOCATION.
|
|
|
|
If LOCATION is the location of a token that is part of the
|
|
replacement-list of a macro expansion return the file path of the
|
|
macro expansion point.
|
|
|
|
SET is the line map set LOCATION comes from. */
|
|
const char* linemap_get_expansion_filename (struct line_maps *,
|
|
source_location);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ! LIBCPP_INTERNAL_H */
|