diff options
author | Mike Stump <mrs@apple.com> | 2005-12-13 21:13:56 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2005-12-13 21:13:56 +0000 |
commit | 7fb2ce80480c167147cd68af5b9cbb22ed514163 (patch) | |
tree | 038cb5f47a2a2e25dedcea77c1d36707a5c74119 | |
parent | c0c7a876e0702c6c9b373783bdb7993a658afab2 (diff) |
* Revert 2005-12-07 Devang Patel <dpatel@apple.com> Radar 4137741apple/gcc-5309
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/apple-local-200502-branch@108484 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog.apple-ppc | 4 | ||||
-rw-r--r-- | gcc/Makefile.in | 8 | ||||
-rw-r--r-- | gcc/c-lex.c | 26 | ||||
-rw-r--r-- | gcc/cp/ChangeLog.apple-ppc | 4 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 7 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 5 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 285 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 11 | ||||
-rw-r--r-- | gcc/langhooks.c | 16 | ||||
-rw-r--r-- | gcc/langhooks.h | 5 | ||||
-rw-r--r-- | libcpp/ChangeLog.apple-ppc | 4 | ||||
-rw-r--r-- | libcpp/directives.c | 47 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 14 | ||||
-rw-r--r-- | libcpp/init.c | 7 | ||||
-rw-r--r-- | libcpp/internal.h | 8 | ||||
-rw-r--r-- | libcpp/lex.c | 47 |
17 files changed, 291 insertions, 211 deletions
diff --git a/gcc/ChangeLog.apple-ppc b/gcc/ChangeLog.apple-ppc index 8ea28596ac0..a5ade7787a2 100644 --- a/gcc/ChangeLog.apple-ppc +++ b/gcc/ChangeLog.apple-ppc @@ -1,3 +1,7 @@ +2005-12-13 Mike Stump <mrs@apple.com> + + * Revert 2005-12-07 Devang Patel <dpatel@apple.com> Radar 4137741 + 2005-12-13 Stuart Hastings <stuart@apple.com> * config/rs6000/rs6000.c (macho_branch_islands): Add APPLE LOCAL. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 0012d2c6409..da5cc5c97b0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1430,10 +1430,12 @@ c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ c-objc-common.h c-pragma.h stub-objc.o : stub-objc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \ $(GGC_H) $(C_COMMON_H) +# APPLE LOCAL begin 4133801 c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(RTL_H) debug.h $(C_TREE_H) $(C_COMMON_H) real.h c-incpath.h cppdefault.h \ $(C_PRAGMA_H) input.h intl.h $(FLAGS_H) toplev.h output.h \ - $(CPPLIB_H) $(EXPR_H) $(TM_P_H) + $(CPPLIB_H) $(EXPR_H) $(TM_P_H) langhooks.h +# APPLE LOCAL end 4133801 # APPLE LOCAL AltiVec c-lex.o: $(TARGET_H) ../libcpp/internal.h c-ppoutput.o : c-ppoutput.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ @@ -1645,9 +1647,11 @@ prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) Makefile prefix.h convert.o: convert.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(FLAGS_H) \ convert.h toplev.h langhooks.h c-tree.h c-common.h # APPLE LOCAL end AltiVec +# APPLE LOCAL begin 4133801 langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) toplev.h \ tree-inline.h $(RTL_H) insn-config.h $(INTEGRATE_H) langhooks.h \ - $(LANGHOOKS_DEF_H) $(FLAGS_H) $(GGC_H) diagnostic.h intl.h + $(LANGHOOKS_DEF_H) $(FLAGS_H) $(GGC_H) diagnostic.h intl.h debug.h +# APPLE LOCAL end 4133801 tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(FLAGS_H) function.h $(PARAMS_H) \ toplev.h $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h \ diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 5a87b05819f..e4c8afdbd74 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -39,6 +39,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "intl.h" #include "tm_p.h" #include "splay-tree.h" +/* APPLE LOCAL 4133801 */ +#include "langhooks.h" #include "debug.h" /* APPLE LOCAL AltiVec */ #include "../libcpp/internal.h" @@ -283,11 +285,8 @@ fe_file_change (const struct line_map *new_map) input_line = included_at; push_srcloc (new_map->to_file, 1); #endif - /* APPLE LOCAL begin 4137741 */ - /* Call through the debug hook, unless this is being deferred. */ - if (!CPP_OPTION (parse_in, defer_file_change_debug_hooks)) - (*debug_hooks->start_source_file) (included_at, new_map->to_file); - /* APPLE LOCAL end 4137741 */ + /* APPLE LOCAL 4133801 */ + lang_hooks.start_source_file (included_at, new_map->to_file); #ifndef NO_IMPLICIT_EXTERN_C if (c_header_level) ++c_header_level; @@ -310,12 +309,8 @@ fe_file_change (const struct line_map *new_map) } #endif pop_srcloc (); - - /* APPLE LOCAL begin 4137741 */ - /* Call through the debug hook, unless this is being deferred. */ - if (!CPP_OPTION (parse_in, defer_file_change_debug_hooks)) - (*debug_hooks->end_source_file) (new_map->to_line); - /* APPLE LOCAL end 4137741 */ + /* APPLE LOCAL 4133801 */ + lang_hooks.end_source_file (new_map->to_line, new_map->to_file); } update_header_times (new_map->to_file); @@ -707,16 +702,7 @@ c_lex_with_flags (tree *value, unsigned char *cpp_flags) *value = NULL_TREE; break; /* APPLE LOCAL end CW asm blocks */ - /* APPLE LOCAL begin 4137741 */ - /* For CPP_BINCL and CPP_EINCL tokens, we shall need to propagate - line number information; the location field shall already include - the desired file name. */ - case CPP_BINCL: - case CPP_EINCL: - *value = build_int_cst (integer_type_node, (HOST_WIDE_INT) tok->src_loc); - break; - /* APPLE LOCAL end 4137741 */ /* These tokens should not be visible outside cpplib. */ case CPP_HEADER_NAME: case CPP_COMMENT: diff --git a/gcc/cp/ChangeLog.apple-ppc b/gcc/cp/ChangeLog.apple-ppc index 94428569e67..af80406c727 100644 --- a/gcc/cp/ChangeLog.apple-ppc +++ b/gcc/cp/ChangeLog.apple-ppc @@ -1,3 +1,7 @@ +2005-12-13 Mike Stump <mrs@apple.com> + + * Revert 2005-12-07 Devang Patel <dpatel@apple.com> Radar 4137741 + 2005-12-08 Mike Stump <mrs@apple.com> Radar 4371551 diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 90d093f5d85..e3f69d6d931 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -162,4 +162,11 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, #define LANG_HOOKS_VTABLE_P cp_vtable_p /* APPLE LOCAL end kext identify vtables */ +/* APPLE LOCAL begin 4133801 */ +#undef LANG_HOOKS_START_SOURCE_FILE +#define LANG_HOOKS_START_SOURCE_FILE cp_start_source_file +#undef LANG_HOOKS_END_SOURCE_FILE +#define LANG_HOOKS_END_SOURCE_FILE cp_end_source_file +/* APPLE LOCAL end 4133801 */ + #endif /* GCC_CP_OBJCP_COMMON */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e5324c3b794..59f009adb80 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4436,6 +4436,11 @@ extern void cp_genericize (tree); extern tree cw_asm_cp_build_component_ref (tree, tree); /* APPLE LOCAL end CW asm blocks */ +/* APPLE LOCAL begin 4133801 */ +extern void cp_start_source_file (int, const char *); +extern void cp_end_source_file (int, const char *); +extern void cp_flush_lexer_file_stack (void); +/* APPLE LOCAL end 4133801 */ /* -- end of C++ */ /* In order for the format checking to accept the C++ frontend diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d928ccce344..e2d67ff74c9 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2766,6 +2766,10 @@ cp_finish_file (void) if (! global_bindings_p () || current_class_type || decl_namespace_list) return; + /* APPLE LOCAL begin 4133801 */ + cp_flush_lexer_file_stack (); + /* APPLE LOCAL end 4133801 */ + if (pch_file) c_common_write_pch (); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 848c1eee5ac..9ff66350f58 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -134,6 +134,35 @@ typedef struct cp_token_cache GTY(()) cp_token * GTY ((skip)) last; } cp_token_cache; +/* APPLE LOCAL begin 4133801 */ +typedef enum cp_file_entry_kind + { + CP_FILE_BEGIN = 0, + CP_FILE_END + } cp_file_entry_kind; + +/* cp_lexer_file is a collection of file begins (and ends) observed + by lexer while collecting tokens for arser. */ + +typedef struct cp_lexer_file +{ + enum cp_file_entry_kind kind; + + /* line number and file names */ + int line; + const char *file; + + struct cp_lexer_file *next; +} cp_lexer_file; + +static cp_lexer_file *cp_lexer_file_stack; +static cp_lexer_file *last_cp_lexer_file; + +static void cp_add_lexer_file (int, const char *, cp_file_entry_kind); +static void cp_lexer_copy_token (cp_token *, cp_token *); +static void cp_parser_bincl_eincl (cp_lexer *lexer); +/* APPLE LOCAL end 4133801 */ + /* Prototypes. */ static cp_lexer *cp_lexer_new_main @@ -166,8 +195,7 @@ static void cp_lexer_purge_token (cp_lexer *); static void cp_lexer_purge_tokens_after (cp_lexer *, cp_token_position); -/* APPLE LOCAL 4137741 */ -static void cp_lexer_handle_pragma_etc +static void cp_lexer_handle_pragma (cp_lexer *); static void cp_lexer_save_tokens (cp_lexer *); @@ -244,11 +272,6 @@ cp_lexer_new_main (void) size_t alloc; size_t space; cp_token *buffer; - /* APPLE LOCAL begin 4137741 */ - - /* Tell cpplib we want CPP_BINCL and CPP_EINCL tokens. */ - cpp_get_options (parse_in)->defer_file_change_debug_hooks = true; - /* APPLE LOCAL end 4137741 */ /* It's possible that lexing the first token will load a PCH file, which is a GC collection point. So we have to grab the first @@ -282,10 +305,61 @@ cp_lexer_new_main (void) space = alloc; pos = buffer; *pos = first_token; - + + /* APPLE LOCAL begin 4133801 */ /* Get the remaining tokens from the preprocessor. */ while (pos->type != CPP_EOF) { + + /* Insert CP_BINCL/CP_EINCL tokens if file begin/end is already seen. */ + if (cp_lexer_file_stack) + { + cp_token saved_pos; + cp_lexer_file *tmp; + cp_lexer_file *fs = cp_lexer_file_stack; + /* APPLE LOCAL 4278470 */ + saved_pos.value = NULL_TREE; + /* Copy position content, so that it added into to the next position + afterwards. */ + cp_lexer_copy_token (&saved_pos, pos); + + while (fs) + { + /* Create new CP_BINCL/CP_EINCL token. */ + LOCATION_FILE (pos->location) = fs->file; + LOCATION_LINE (pos->location) = fs->line; + pos->keyword = 0; + pos->in_system_header = 0; + pos->implicit_extern_c = 0; + pos->value = NULL_TREE; + if (fs->kind == CP_FILE_BEGIN) + pos->type = CPP_BINCL; + else + pos->type = CPP_EINCL; + + /* Free this file entry. */ + tmp = fs; + fs = fs->next; + tmp = NULL; + pos++; + if (!--space) + { + space = alloc; + alloc *= 2; + buffer = ggc_realloc (buffer, alloc * sizeof (cp_token)); + pos = buffer + space; + } + + } + + /* Free file stack entirely. */ + last_cp_lexer_file = NULL; + cp_lexer_file_stack = NULL; + + /* Restore saved position. */ + cp_lexer_copy_token (pos, &saved_pos); + } + pos++; if (!--space) { @@ -296,6 +370,7 @@ cp_lexer_new_main (void) } cp_lexer_get_preprocessor_token (lexer, pos); } + /* APPLE LOCAL end 4133801 */ lexer->buffer = buffer; lexer->buffer_length = alloc - space; lexer->last_token = pos; @@ -463,6 +538,11 @@ cp_lexer_peek_token (cp_lexer *lexer) cp_lexer_print_token (cp_lexer_debug_stream, lexer->next_token); putc ('\n', cp_lexer_debug_stream); } + + /* APPLE LOCAL begin 4133801 */ + cp_parser_bincl_eincl (lexer); + /* APPLE LOCAL end 4133801 */ + return lexer->next_token; } @@ -523,9 +603,13 @@ cp_lexer_peek_nth_token (cp_lexer* lexer, size_t n) token = (cp_token *)&eof_token; break; } - - if (token->type != CPP_PURGED) + + /* APPLE LOCAL begin 4133801 */ + if (token->type != CPP_PURGED + && token->type != CPP_BINCL + && token->type != CPP_EINCL) --n; + /* APPLE LOCAL end 4133801 */ } if (cp_lexer_debugging_p (lexer)) @@ -623,43 +707,20 @@ cp_lexer_purge_tokens_after (cp_lexer *lexer, cp_token *tok) } } -/* APPLE LOCAL begin 4137741 */ -/* Consume and handle a pragma, BINCL or EINCL token. */ - +/* Consume and handle a pragma token. */ static void -cp_lexer_handle_pragma_etc (cp_lexer *lexer) -/* APPLE LOCAL end 4137741 */ +cp_lexer_handle_pragma (cp_lexer *lexer) { cpp_string s; cp_token *token = cp_lexer_consume_token (lexer); - /* APPLE LOCAL 4137741 */ - /* Assert removed. */ + gcc_assert (token->type == CPP_PRAGMA); gcc_assert (token->value); - /* APPLE LOCAL begin 4137741 */ - switch (token->type) - { - case CPP_PRAGMA: - s.len = TREE_STRING_LENGTH (token->value); - s.text = (const unsigned char *) TREE_STRING_POINTER (token->value); - - cpp_handle_deferred_pragma (parse_in, &s); - break; - - case CPP_BINCL: - (*debug_hooks->start_source_file) (TREE_INT_CST_LOW (token->value), - token->location.file); - break; - - case CPP_EINCL: - (*debug_hooks->end_source_file) (TREE_INT_CST_LOW (token->value)); - break; + s.len = TREE_STRING_LENGTH (token->value); + s.text = (const unsigned char *) TREE_STRING_POINTER (token->value); - default: - gcc_assert (false); - } + cpp_handle_deferred_pragma (parse_in, &s); - /* APPLE LOCAL end 4137741 */ /* Clearing token->value here means that we will get an ICE if we try to process this #pragma again (which should be impossible). */ token->value = NULL; @@ -678,6 +739,103 @@ cp_lexer_save_tokens (cp_lexer* lexer) VEC_safe_push (cp_token_position, lexer->saved_tokens, lexer->next_token); } +/* APPLE LOCAL begin 4133801 */ +/* Note down new file begin or end entry in cp_lexer_file */ +static void +cp_add_lexer_file (int n, const char *s, cp_file_entry_kind k) +{ + cp_lexer_file *lf = xmalloc (sizeof (cp_lexer_file)); + + /* Populate */ + lf->line = n; + lf->file = s; + lf->kind = k; + lf->next = NULL; + + /* Add in the list */ + if (last_cp_lexer_file) + last_cp_lexer_file->next = lf; + else + cp_lexer_file_stack = lf; + last_cp_lexer_file = lf; +} + +/* Lang hooks for begining of source file. */ + +void +cp_start_source_file (int n, const char *s) +{ + cp_add_lexer_file (n, s, CP_FILE_BEGIN); +} + +/* Lang hooks for end of source file. */ + +void +cp_end_source_file (int n, const char *s) +{ + cp_add_lexer_file (n, s, CP_FILE_END); +} + +/* At the end of compilation emit BINCL/EINCL for remaining entries. */ + +void +cp_flush_lexer_file_stack (void) +{ + if (cp_lexer_file_stack) + { + cp_lexer_file *lf = cp_lexer_file_stack; + while (lf) + { + cp_lexer_file *tmp; + if (lf->kind == CP_FILE_BEGIN) + (*debug_hooks->start_source_file) (lf->line, lf->file); + else if (lf->kind == CP_FILE_END) + (*debug_hooks->end_source_file) (lf->line); + tmp = lf; + lf = lf->next; + tmp = NULL; + } + last_cp_lexer_file = NULL; + cp_lexer_file_stack = NULL; + } +} + +/* Copy cp_token */ +static void +cp_lexer_copy_token (cp_token *to, cp_token *from) +{ + to->type = from->type; + to->keyword = from->keyword; + to->flags = from->flags; + to->in_system_header = from->in_system_header; + to->implicit_extern_c = from->implicit_extern_c; + to->value = from->value; + to->location = from->location; +} + +/* Handle CPP_BINCL and CPP_EINCL tokens. */ + +static void +cp_parser_bincl_eincl (cp_lexer *lexer) +{ + cp_token *token = lexer->next_token; + + /* If the next token is CPP_BINCL/CPP_EINCL then invoke debug info hook */ + while (token->type == CPP_BINCL || token->type == CPP_EINCL) + { + if (token->type == CPP_BINCL) + (*debug_hooks->start_source_file) (LOCATION_LINE (token->location), + LOCATION_FILE (token->location)); + else if (token->type == CPP_EINCL) + (*debug_hooks->end_source_file) (LOCATION_LINE (token->location)); + + cp_lexer_purge_token (lexer); + token = lexer->next_token; + } +} + +/* APPLE LOCAL end 4133801 */ + /* Commit to the portion of the token stream most recently saved. */ static void @@ -6360,14 +6518,9 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr) statement = cp_parser_compound_statement (parser, NULL, false); /* CPP_PRAGMA is a #pragma inside a function body, which constitutes a statement all its own. */ - /* APPLE LOCAL begin 4137741 */ - else if (token->type == CPP_PRAGMA - || token->type == CPP_BINCL - || token->type == CPP_EINCL) - /* APPLE LOCAL end 4137741 */ - { - /* APPLE LOCAL 4137741 */ - cp_lexer_handle_pragma_etc (parser->lexer); + else if (token->type == CPP_PRAGMA) + { + cp_lexer_handle_pragma (parser->lexer); return; } @@ -7192,18 +7345,13 @@ cp_parser_declaration_seq_opt (cp_parser* parser) parser->implicit_extern_c = false; } - /* APPLE LOCAL begin 4137741 */ - if (token->type == CPP_PRAGMA - || token->type == CPP_BINCL - || token->type == CPP_EINCL) - /* APPLE LOCAL end 4137741 */ + if (token->type == CPP_PRAGMA) { /* A top-level declaration can consist solely of a #pragma. A nested declaration cannot, so this is done here and not in cp_parser_declaration. (A #pragma at block scope is handled in cp_parser_statement.) */ - /* APPLE LOCAL 4137741 */ - cp_lexer_handle_pragma_etc (parser->lexer); + cp_lexer_handle_pragma (parser->lexer); continue; } @@ -13588,14 +13736,9 @@ cp_parser_member_specification_opt (cp_parser* parser) default: /* Accept #pragmas at class scope. */ - /* APPLE LOCAL begin 4137741 */ - if (token->type == CPP_PRAGMA - || token->type == CPP_BINCL - || token->type == CPP_EINCL) - /* APPLE LOCAL end 4137741 */ + if (token->type == CPP_PRAGMA) { - /* APPLE LOCAL 4137741 */ - cp_lexer_handle_pragma_etc (parser->lexer); + cp_lexer_handle_pragma (parser->lexer); break; } @@ -16744,10 +16887,8 @@ cp_parser_cw_asm_declaration_seq_opt (cp_parser* parser) /* CPP_PRAGMA is a #pragma inside a function body, which constitutes a declaration all its own. */ - if (token->type == CPP_PRAGMA - || token->type == CPP_BINCL - || token->type == CPP_EINCL) - cp_lexer_handle_pragma_etc (parser->lexer); + if (token->type == CPP_PRAGMA) + cp_lexer_handle_pragma (parser->lexer); if (cw_asm_state >= cw_asm_decls && (cp_lexer_cw_bol (parser->lexer) @@ -17030,11 +17171,9 @@ cp_parser_cw_asm_statement (cp_parser* parser) || cp_lexer_next_token_is (parser->lexer, CPP_EOF)) break; - if (cp_lexer_next_token_is (parser->lexer, CPP_PRAGMA) - || cp_lexer_next_token_is (parser->lexer, CPP_BINCL) - || cp_lexer_next_token_is (parser->lexer, CPP_EINCL)) + if (cp_lexer_next_token_is (parser->lexer, CPP_PRAGMA)) { - cp_lexer_handle_pragma_etc (parser->lexer); + cp_lexer_handle_pragma (parser->lexer); } else if (cp_lexer_next_token_is (parser->lexer, CPP_ATSIGN)) { @@ -18196,12 +18335,8 @@ cp_parser_objc_interstitial_code (cp_parser* parser) && cp_parser_is_string_literal (cp_lexer_peek_nth_token (parser->lexer, 2))) cp_parser_linkage_specification (parser); /* Handle #pragma, if any. */ - /* APPLE LOCAL begin 4137741 */ - else if (token->type == CPP_PRAGMA - || token->type == CPP_BINCL - || token->type == CPP_EINCL) - cp_lexer_handle_pragma_etc (parser->lexer); - /* APPLE LOCAL end 4137741 */ + else if (token->type == CPP_PRAGMA) + cp_lexer_handle_pragma (parser->lexer); /* Allow stray semicolons. */ else if (token->type == CPP_SEMICOLON) cp_lexer_consume_token (parser->lexer); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index d25b3721bde..4484f866d88 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -85,7 +85,12 @@ extern void lhd_tree_inlining_end_inlining (tree); extern tree lhd_tree_inlining_convert_parm_for_inlining (tree, tree, tree, int); extern void lhd_initialize_diagnostics (struct diagnostic_context *); extern tree lhd_callgraph_analyze_expr (tree *, int *, tree); - +/* APPLE LOCAL begin 4133801 */ +extern void lhd_start_source_file (int, const char *); +extern void lhd_end_source_file (int, const char *); +#define LANG_HOOKS_START_SOURCE_FILE lhd_start_source_file +#define LANG_HOOKS_END_SOURCE_FILE lhd_end_source_file +/* APPLE LOCAL end 4133801 */ /* Declarations for tree gimplification hooks. */ extern int lhd_gimplify_expr (tree *, tree *, tree *); @@ -310,6 +315,10 @@ extern tree lhd_make_node (enum tree_code); LANG_HOOKS_GIMPLIFY_EXPR, \ LANG_HOOKS_FOLD_OBJ_TYPE_REF, \ LANG_HOOKS_BUILTIN_FUNCTION, \ +/* APPLE LOCAL begin 4133801 */ \ + LANG_HOOKS_START_SOURCE_FILE, \ + LANG_HOOKS_END_SOURCE_FILE, \ +/* APPLE LOCAL end 4133801 */ \ } #endif /* GCC_LANG_HOOKS_DEF_H */ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index daf34e0fa1f..b8791e52b3a 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -34,6 +34,8 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "langhooks.h" #include "langhooks-def.h" +/* APPLE LOCAL 4133801 */ +#include "debug.h" #include "ggc.h" #include "diagnostic.h" @@ -560,3 +562,17 @@ lhd_to_target_charset (HOST_WIDE_INT c) { return c; } + +/* APPLE LOCAL begin 4133801 */ +void +lhd_start_source_file (int n, const char *s) +{ + (*debug_hooks->start_source_file) (n, s); +} + +void +lhd_end_source_file (int n, const char *s ATTRIBUTE_UNUSED) +{ + (*debug_hooks->end_source_file) (n); +} +/* APPLE LOCAL end 4133801 */ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index b48b2b4e535..c9dc5e51d24 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -434,6 +434,11 @@ struct lang_hooks enum built_in_class bt_class, const char *library_name, tree attrs); + /* APPLE LOCAL begin 4133801 */ + void (*start_source_file) (int n, const char *s); + void (*end_source_file) (int n, const char *s); + /* APPLE LOCAL end 4133801 */ + /* Whenever you add entries here, make sure you adjust langhooks-def.h and langhooks.c accordingly. */ }; diff --git a/libcpp/ChangeLog.apple-ppc b/libcpp/ChangeLog.apple-ppc index bc7243433b7..ecf7403a52c 100644 --- a/libcpp/ChangeLog.apple-ppc +++ b/libcpp/ChangeLog.apple-ppc @@ -1,3 +1,7 @@ +2005-12-13 Mike Stump <mrs@apple.com> + + * Revert 2005-12-07 Devang Patel <dpatel@apple.com> Radar 4137741 + 2005-12-09 Mike Stump <mrs@apple.com> Radar 4371958 diff --git a/libcpp/directives.c b/libcpp/directives.c index f173575ca9b..c356beda668 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -945,53 +945,6 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason, if (pfile->cb.file_change) pfile->cb.file_change (pfile, map); - /* APPLE LOCAL begin 4137741 */ - - /* If file change debug hook callbacks are being deferred, we will - need special CPP_BINCL and CPP_EINCL tokens to carry the information - to the front-end. */ - if (map && CPP_OPTION (pfile, defer_file_change_debug_hooks)) - { - cpp_token *tok; - - if ((reason == LC_ENTER && !MAIN_FILE_P (map))) - { - uchar *s; - cpp_string body; - - /* We can handle '#include' similarly to '#pragma'. */ - tok = &pfile->directive_result; - tok->type = CPP_BINCL; - body.len = strlen (map->to_file); - s = _cpp_unaligned_alloc (pfile, body.len + 1); - memcpy (s, map->to_file, body.len + 1); - body.text = s; - tok->val.str = body; -#ifdef USE_MAPPED_LOCATION - tok->src_loc = LAST_SOURCE_LINE_LOCATION (map - 1); -#else - tok->src_loc = LAST_SOURCE_LINE (map - 1); -#endif - } - else if (reason == LC_LEAVE) - { - /* Grow CPP_EINCL buffer if necessary. This should be extremely - rare, since it requires that more than 250 nested headers reach - end-of-file simultaneously. */ - if (pfile->end_eincl == pfile->cur_eincl->limit) - { - pfile->cur_eincl = _cpp_next_tokenrun (pfile->cur_eincl); - pfile->end_eincl = pfile->cur_eincl->base; - } - - tok = pfile->end_eincl++; - tok->type = CPP_EINCL; - tok->src_loc = map->to_line; - tok->flags = 0; - pfile->have_eincl = true; - } - } - /* APPLE LOCAL end 4137741 */ } /* Report a warning or error detected by the program we are diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 070b75bc7e9..76b0e2da07b 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -137,14 +137,14 @@ struct _cpp_file; TK(BOL, LITERAL) /* asm bol */ \ TK(EOL, LITERAL) /* asm eol */ \ /* APPLE LOCAL end CW asm blocks */ \ + /* APPLE LOCAL begin 4133801 */ \ + TK(BINCL, LITERAL) /* File begin */ \ + TK(EINCL, LITERAL) /* File end */ \ + /* APPLE LOCAL end 4133801 */ \ TK(COMMENT, LITERAL) /* Only if output comments. */ \ /* SPELL_LITERAL happens to DTRT. */ \ TK(MACRO_ARG, NONE) /* Macro argument. */ \ TK(PRAGMA, NONE) /* Only if deferring pragmas */ \ - /* APPLE LOCAL begin 4137741 */ \ - TK(BINCL, NONE) /* File begin */ \ - TK(EINCL, NONE) /* File end */ \ - /* APPLE LOCAL end 4137741 */ \ TK(PADDING, NONE) /* Whitespace for -E. */ #define OP(e, s) CPP_ ## e, @@ -497,12 +497,6 @@ struct cpp_options /* True means return pragmas as tokens rather than processing them directly. */ bool defer_pragmas; - /* APPLE LOCAL begin 4137741 */ - - /* True means return special CPP_BINCL and CPP_EINCL tokens instead - of firing off debug hooks when entering and exiting headers. */ - bool defer_file_change_debug_hooks; - /* APPLE LOCAL end 4137741 */ }; /* Callback for header lookup for HEADER, which is the name of a diff --git a/libcpp/init.c b/libcpp/init.c index 736e29f9ce4..3bb61ae1223 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -212,13 +212,6 @@ cpp_create_reader (enum c_lang lang, hash_table *table, _cpp_init_tokenrun (&pfile->base_run, 250); pfile->cur_run = &pfile->base_run; pfile->cur_token = pfile->base_run.base; - /* APPLE LOCAL begin 4137741 */ - - /* Initialize buffer for pending CPP_EINCL tokens. */ - _cpp_init_tokenrun (&pfile->base_eincl, 250); - pfile->cur_eincl = &pfile->base_eincl; - pfile->beg_eincl = pfile->end_eincl = pfile->base_eincl.base; - /* APPLE LOCAL end 4137741 */ /* Initialize the base context. */ pfile->context = &pfile->base_context; diff --git a/libcpp/internal.h b/libcpp/internal.h index 789bf4a2461..9c6951f0501 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -374,12 +374,6 @@ struct cpp_reader cpp_token *cur_token; tokenrun base_run, *cur_run; unsigned int lookaheads; - /* APPLE LOCAL begin 4137741 */ - /* Buffer of pending CPP_EINCL tokens. */ - cpp_token *beg_eincl, *end_eincl; - tokenrun base_eincl, *cur_eincl; - bool have_eincl; - /* APPLE LOCAL end 4137741 */ /* Nonzero prevents the lexer from re-using the token runs. */ unsigned int keep_tokens; @@ -552,8 +546,6 @@ 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); -/* APPLE LOCAL 4137741 */ -extern tokenrun *_cpp_next_tokenrun (tokenrun *); /* In init.c. */ extern void _cpp_maybe_push_include_file (cpp_reader *); diff --git a/libcpp/lex.c b/libcpp/lex.c index 13e2241ccaf..72c974a87e0 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -67,8 +67,7 @@ static void create_literal (cpp_reader *, cpp_token *, const uchar *, unsigned int, enum cpp_ttype); static bool warn_in_comment (cpp_reader *, _cpp_line_note *); static int name_p (cpp_reader *, const cpp_string *); -/* APPLE LOCAL 4137741 */ -/* 'next_tokenrun' made extern and renamed to '_cpp_next_tokenrun'. */ +static tokenrun *next_tokenrun (tokenrun *); static _cpp_buff *new_buff (size_t); @@ -734,10 +733,8 @@ _cpp_init_tokenrun (tokenrun *run, unsigned int count) } /* Returns the next tokenrun, or creates one if there is none. */ -/* APPLE LOCAL begin 4137741 */ -tokenrun * -_cpp_next_tokenrun (tokenrun *run) -/* APPLE LOCAL end 4137741 */ +static tokenrun * +next_tokenrun (tokenrun *run) { if (run->next == NULL) { @@ -808,10 +805,9 @@ _cpp_temp_token (cpp_reader *pfile) /* Any pre-existing lookaheads must not be clobbered. */ if (la) { - /* APPLE LOCAL begin 4137741 */ if (sz <= la) { - tokenrun *next = _cpp_next_tokenrun (pfile->cur_run); + tokenrun *next = next_tokenrun (pfile->cur_run); if (sz < la) memmove (next->base + 1, next->base, @@ -828,8 +824,7 @@ _cpp_temp_token (cpp_reader *pfile) if (!sz) /* APPLE LOCAL end AltiVec */ { - pfile->cur_run = _cpp_next_tokenrun (pfile->cur_run); - /* APPLE LOCAL end 4137741 */ + pfile->cur_run = next_tokenrun (pfile->cur_run); pfile->cur_token = pfile->cur_run->base; } @@ -850,8 +845,7 @@ _cpp_lex_token (cpp_reader *pfile) { if (pfile->cur_token == pfile->cur_run->limit) { - /* APPLE LOCAL 4137741 */ - pfile->cur_run = _cpp_next_tokenrun (pfile->cur_run); + pfile->cur_run = next_tokenrun (pfile->cur_run); pfile->cur_token = pfile->cur_run->base; } @@ -865,35 +859,6 @@ _cpp_lex_token (cpp_reader *pfile) if (result->flags & BOL) { - /* APPLE LOCAL begin 4137741 */ - /* If we have squirreled away a CPP_EINCL token, return it now. */ - if (pfile->have_eincl) - { - result = pfile->beg_eincl++; - - if (pfile->beg_eincl == pfile->end_eincl) - { - pfile->beg_eincl = pfile->end_eincl = pfile->base_eincl.base; - pfile->have_eincl = false; - } - else if (pfile->beg_eincl == pfile->cur_eincl->limit) - { - /* NB: This point will be reached only if there are more - than 250 nested headers that are _simultaneously_ - ending; a rare occurrence indeed. */ - pfile->cur_eincl = _cpp_next_tokenrun (pfile->cur_eincl); - pfile->beg_eincl = pfile->cur_eincl->base; - } - - /* Push back original return value; - we will retrieve it later. */ - pfile->lookaheads++; - pfile->cur_token--; - - return result; - } - - /* APPLE LOCAL end 4137741 */ /* Is this a directive. If _cpp_handle_directive returns false, it is an assembler #. */ if (result->type == CPP_HASH |