diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
commit | a926878ddbd5a98b272c22171ce58663fc04c3e0 (patch) | |
tree | 86af256e5d9a9c06263c00adc90e5fe348008c43 /libcpp/files.c | |
parent | 542730f087133690b47e036dfd43eb0db8a650ce (diff) | |
parent | 07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff) | |
download | gcc-devel/autopar_devel.zip gcc-devel/autopar_devel.tar.gz gcc-devel/autopar_devel.tar.bz2 |
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'libcpp/files.c')
-rw-r--r-- | libcpp/files.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/libcpp/files.c b/libcpp/files.c index 260e787..3d48c38 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -496,21 +496,16 @@ _cpp_find_failed (_cpp_file *file) had previously been closed. To open it again pass the return value to open_file(). - If IMPLICIT_PREINCLUDE then it is OK for the file to be missing. - If present, it is OK for a precompiled header to be included after - it. + If KIND is _cpp_FFK_PRE_INCLUDE then it is OK for the file to be + missing. If present, it is OK for a precompiled header to be + included after it. Use LOC as the location for any errors. */ _cpp_file * _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, - int angle_brackets, - bool fake, bool implicit_preinclude, bool has_include, - location_t loc) + int angle_brackets, _cpp_find_file_kind kind, location_t loc) { - struct cpp_file_hash_entry *entry; - void **hash_slot; - _cpp_file *file; bool invalid_pch = false; bool saw_bracket_include = false; bool saw_quote_include = false; @@ -520,22 +515,22 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, if (start_dir == NULL) cpp_error_at (pfile, CPP_DL_ICE, loc, "NULL directory in find_file"); - hash_slot + void **hash_slot = htab_find_slot_with_hash (pfile->file_hash, fname, htab_hash_string (fname), INSERT); /* First check the cache before we resort to memory allocation. */ - entry = search_cache ((struct cpp_file_hash_entry *) *hash_slot, start_dir); + cpp_file_hash_entry *entry + = search_cache ((struct cpp_file_hash_entry *) *hash_slot, start_dir); if (entry) return entry->u.file; - file = make_cpp_file (pfile, start_dir, fname); + _cpp_file *file = make_cpp_file (pfile, start_dir, fname); file->implicit_preinclude - = (implicit_preinclude - || (pfile->buffer - && pfile->buffer->file->implicit_preinclude)); + = (kind == _cpp_FFK_PRE_INCLUDE + || (pfile->buffer && pfile->buffer->file->implicit_preinclude)); - if (!fake) + if (kind != _cpp_FFK_FAKE) /* Try each path in the include chain. */ for (;;) { @@ -580,7 +575,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, "use -Winvalid-pch for more information"); } - if (implicit_preinclude) + if (kind == _cpp_FFK_PRE_INCLUDE) { free ((char *) file->name); free (file); @@ -593,7 +588,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, return NULL; } - if (!has_include) + if (kind != _cpp_FFK_HAS_INCLUDE) open_file_failed (pfile, file, angle_brackets, loc); break; } @@ -635,7 +630,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, entry = new_file_hash_entry (pfile); entry->next = (struct cpp_file_hash_entry *) *hash_slot; entry->start_dir = start_dir; - entry->location = pfile->line_table->highest_location; + entry->location = loc; entry->u.file = file; *hash_slot = (void *) entry; @@ -648,7 +643,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, entry = new_file_hash_entry (pfile); entry->next = (struct cpp_file_hash_entry *) *hash_slot; entry->start_dir = pfile->bracket_include; - entry->location = pfile->line_table->highest_location; + entry->location = loc; entry->u.file = file; *hash_slot = (void *) entry; } @@ -659,7 +654,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, entry = new_file_hash_entry (pfile); entry->next = (struct cpp_file_hash_entry *) *hash_slot; entry->start_dir = pfile->quote_include; - entry->location = pfile->line_table->highest_location; + entry->location = loc; entry->u.file = file; *hash_slot = (void *) entry; } @@ -952,7 +947,11 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type, pfile->line_table->highest_location--; /* Add line map and do callbacks. */ - _cpp_do_file_change (pfile, LC_ENTER, file->path, 1, sysp); + _cpp_do_file_change (pfile, LC_ENTER, file->path, + /* With preamble injection, start on line zero, so + the preamble doesn't appear to have been + included from line 1. */ + type == IT_MAIN_INJECT ? 0 : 1, sysp); return true; } @@ -1049,7 +1048,8 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, return false; _cpp_file *file = _cpp_find_file (pfile, fname, dir, angle_brackets, - false, type == IT_DEFAULT, false, loc); + type == IT_DEFAULT ? _cpp_FFK_PRE_INCLUDE + : _cpp_FFK_NORMAL, loc); if (type == IT_DEFAULT && file == NULL) return false; @@ -1342,8 +1342,7 @@ cpp_clear_file_cache (cpp_reader *pfile) void _cpp_fake_include (cpp_reader *pfile, const char *fname) { - _cpp_find_file (pfile, fname, pfile->buffer->file->dir, - 0, true, false, false, 0); + _cpp_find_file (pfile, fname, pfile->buffer->file->dir, 0, _cpp_FFK_FAKE, 0); } /* Not everyone who wants to set system-header-ness on a buffer can @@ -1360,7 +1359,8 @@ cpp_make_system_header (cpp_reader *pfile, int syshdr, int externc) flags = 1 + (externc != 0); pfile->buffer->sysp = flags; _cpp_do_file_change (pfile, LC_RENAME, ORDINARY_MAP_FILE_NAME (map), - SOURCE_LINE (map, pfile->line_table->highest_line), flags); + SOURCE_LINE (map, pfile->line_table->highest_line), + flags); } /* Allow the client to change the current file. Used by the front end @@ -1461,8 +1461,7 @@ _cpp_compare_file_date (cpp_reader *pfile, const char *fname, if (!dir) return -1; - file = _cpp_find_file (pfile, fname, dir, angle_brackets, - false, false, false, 0); + file = _cpp_find_file (pfile, fname, dir, angle_brackets, _cpp_FFK_NORMAL, 0); if (file->err_no) return -1; @@ -1480,7 +1479,8 @@ _cpp_compare_file_date (cpp_reader *pfile, const char *fname, bool cpp_push_include (cpp_reader *pfile, const char *fname) { - return _cpp_stack_include (pfile, fname, false, IT_CMDLINE, 0); + return _cpp_stack_include (pfile, fname, false, IT_CMDLINE, + pfile->line_table->highest_line); } /* Pushes the given file, implicitly included at the start of a @@ -1489,7 +1489,8 @@ cpp_push_include (cpp_reader *pfile, const char *fname) bool cpp_push_default_include (cpp_reader *pfile, const char *fname) { - return _cpp_stack_include (pfile, fname, true, IT_DEFAULT, 0); + return _cpp_stack_include (pfile, fname, true, IT_DEFAULT, + pfile->line_table->highest_line); } /* Do appropriate cleanup when a file INC's buffer is popped off the @@ -2006,10 +2007,7 @@ _cpp_has_header (cpp_reader *pfile, const char *fname, int angle_brackets, { cpp_dir *start_dir = search_path_head (pfile, fname, angle_brackets, type); _cpp_file *file = _cpp_find_file (pfile, fname, start_dir, angle_brackets, - /*fake=*/false, - /*implicit_preinclude=*/false, - /*has_include=*/true, - 0); + _cpp_FFK_HAS_INCLUDE, 0); return file->err_no != ENOENT; } |