diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-10-11 18:09:59 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-10-11 18:09:59 +0000 |
commit | b90c93381261e3c7fff0bf25fad4c22407ab9b73 (patch) | |
tree | 9ea0969a69bf3e506dfd77d4a35fb7ef8c761a34 /gcc/incpath.c | |
parent | 42851ff81dbe1ccaa16dbcc070513c181ff61eb7 (diff) | |
download | gcc-b90c93381261e3c7fff0bf25fad4c22407ab9b73.zip gcc-b90c93381261e3c7fff0bf25fad4c22407ab9b73.tar.gz gcc-b90c93381261e3c7fff0bf25fad4c22407ab9b73.tar.bz2 |
[PATCH] Include path enumeration
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00693.html
gcc/
* incpath.h (enum incpath_kind): Name enum, prefix values.
(add_path, add_cpp_dir_path, get_added_cpp_dirs): Use incpath_kind.
* incpath.c (heads, tails): Use INC_MAX.
(add_env_var_paths, add_standard_paths): Use incpath_kind.
(merge_include_chains, split_quote_chain,
register_include_chains): Update incpath_kind names.
(add_cpp_dir_path, add_path, get_added_cpp_dirs): Use incpath_kind.
* config/darwin-c.c (add_system_framework_path): Update incpath_kind
names.
(add_framework_path, darwin_register_objc_includes): Likewise.
* config/vms/vms-c.c (vms_c_register_includes): Likewise.
gcc/c-family/
* c-opts.c (add_prefixed_path): Change chain to incpath_kind.
(c_common_handle_option): Update incpath_kind names.
gcc/fortran/
* cpp.c (gfc_cpp_add_include_path): Update incpath_e names.
(gfc_cpp_add_include_path_after): Likewise.
From-SVN: r253654
Diffstat (limited to 'gcc/incpath.c')
-rw-r--r-- | gcc/incpath.c | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/gcc/incpath.c b/gcc/incpath.c index 47942e2..a2ee69f 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -46,7 +46,7 @@ static const char dir_separator_str[] = { DIR_SEPARATOR, 0 }; -static void add_env_var_paths (const char *, int); +static void add_env_var_paths (const char *, incpath_kind); static void add_standard_paths (const char *, const char *, const char *, int); static void free_path (struct cpp_dir *, int); static void merge_include_chains (const char *, cpp_reader *, int); @@ -56,8 +56,9 @@ static struct cpp_dir *remove_duplicates (cpp_reader *, struct cpp_dir *, struct cpp_dir *, int); /* Include chains heads and tails. */ -static struct cpp_dir *heads[4]; -static struct cpp_dir *tails[4]; +static struct cpp_dir *heads[INC_MAX]; +static struct cpp_dir *tails[INC_MAX]; + static bool quote_ignores_source_dir; enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS }; @@ -92,7 +93,7 @@ free_path (struct cpp_dir *path, int reason) /* Read ENV_VAR for a PATH_SEPARATOR-separated list of file names; and append all the names to the search path CHAIN. */ static void -add_env_var_paths (const char *env_var, int chain) +add_env_var_paths (const char *env_var, incpath_kind chain) { char *p, *q, *path; @@ -116,7 +117,7 @@ add_env_var_paths (const char *env_var, int chain) path[q - p] = '\0'; } - add_path (path, chain, chain == SYSTEM, false); + add_path (path, chain, chain == INC_SYSTEM, false); } } @@ -159,7 +160,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, str = reconcat (str, str, dir_separator_str, imultiarch, NULL); } - add_path (str, SYSTEM, p->cxx_aware, false); + add_path (str, INC_SYSTEM, p->cxx_aware, false); } } } @@ -225,7 +226,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, str = reconcat (str, str, dir_separator_str, imultiarch, NULL); } - add_path (str, SYSTEM, p->cxx_aware, false); + add_path (str, INC_SYSTEM, p->cxx_aware, false); } } } @@ -349,29 +350,32 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) /* Add the sysroot to user-supplied paths starting with "=". */ if (sysroot) { - add_sysroot_to_chain (sysroot, QUOTE); - add_sysroot_to_chain (sysroot, BRACKET); - add_sysroot_to_chain (sysroot, SYSTEM); - add_sysroot_to_chain (sysroot, AFTER); + add_sysroot_to_chain (sysroot, INC_QUOTE); + add_sysroot_to_chain (sysroot, INC_BRACKET); + add_sysroot_to_chain (sysroot, INC_SYSTEM); + add_sysroot_to_chain (sysroot, INC_AFTER); } /* Join the SYSTEM and AFTER chains. Remove duplicates in the resulting SYSTEM chain. */ - if (heads[SYSTEM]) - tails[SYSTEM]->next = heads[AFTER]; + if (heads[INC_SYSTEM]) + tails[INC_SYSTEM]->next = heads[INC_AFTER]; else - heads[SYSTEM] = heads[AFTER]; - heads[SYSTEM] = remove_duplicates (pfile, heads[SYSTEM], 0, 0, verbose); + heads[INC_SYSTEM] = heads[INC_AFTER]; + heads[INC_SYSTEM] + = remove_duplicates (pfile, heads[INC_SYSTEM], 0, 0, verbose); /* Remove duplicates from BRACKET that are in itself or SYSTEM, and join it to SYSTEM. */ - heads[BRACKET] = remove_duplicates (pfile, heads[BRACKET], heads[SYSTEM], - heads[SYSTEM], verbose); + heads[INC_BRACKET] + = remove_duplicates (pfile, heads[INC_BRACKET], heads[INC_SYSTEM], + heads[INC_SYSTEM], verbose); /* Remove duplicates from QUOTE that are in itself or SYSTEM, and join it to BRACKET. */ - heads[QUOTE] = remove_duplicates (pfile, heads[QUOTE], heads[SYSTEM], - heads[BRACKET], verbose); + heads[INC_QUOTE] + = remove_duplicates (pfile, heads[INC_QUOTE], heads[INC_SYSTEM], + heads[INC_BRACKET], verbose); /* If verbose, print the list of dirs to search. */ if (verbose) @@ -379,9 +383,9 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) struct cpp_dir *p; fprintf (stderr, _("#include \"...\" search starts here:\n")); - for (p = heads[QUOTE];; p = p->next) + for (p = heads[INC_QUOTE];; p = p->next) { - if (p == heads[BRACKET]) + if (p == heads[INC_BRACKET]) fprintf (stderr, _("#include <...> search starts here:\n")); if (!p) break; @@ -398,14 +402,14 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) void split_quote_chain (void) { - if (heads[QUOTE]) - free_path (heads[QUOTE], REASON_QUIET); - if (tails[QUOTE]) - free_path (tails[QUOTE], REASON_QUIET); - heads[QUOTE] = heads[BRACKET]; - tails[QUOTE] = tails[BRACKET]; - heads[BRACKET] = NULL; - tails[BRACKET] = NULL; + if (heads[INC_QUOTE]) + free_path (heads[INC_QUOTE], REASON_QUIET); + if (tails[INC_QUOTE]) + free_path (tails[INC_QUOTE], REASON_QUIET); + heads[INC_QUOTE] = heads[INC_BRACKET]; + tails[INC_QUOTE] = tails[INC_BRACKET]; + heads[INC_BRACKET] = NULL; + tails[INC_BRACKET] = NULL; /* This is NOT redundant. */ quote_ignores_source_dir = true; } @@ -413,7 +417,7 @@ split_quote_chain (void) /* Add P to the chain specified by CHAIN. */ void -add_cpp_dir_path (cpp_dir *p, int chain) +add_cpp_dir_path (cpp_dir *p, incpath_kind chain) { if (tails[chain]) tails[chain]->next = p; @@ -425,7 +429,7 @@ add_cpp_dir_path (cpp_dir *p, int chain) /* Add PATH to the include chain CHAIN. PATH must be malloc-ed and NUL-terminated. */ void -add_path (char *path, int chain, int cxx_aware, bool user_supplied_p) +add_path (char *path, incpath_kind chain, int cxx_aware, bool user_supplied_p) { cpp_dir *p; @@ -450,7 +454,7 @@ add_path (char *path, int chain, int cxx_aware, bool user_supplied_p) #ifndef INO_T_EQ p->canonical_name = lrealpath (path); #endif - if (chain == SYSTEM || chain == AFTER) + if (chain == INC_SYSTEM || chain == INC_AFTER) p->sysp = 1 + !cxx_aware; else p->sysp = 0; @@ -480,8 +484,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, /* CPATH and language-dependent environment variables may add to the include chain. */ - add_env_var_paths ("CPATH", BRACKET); - add_env_var_paths (lang_env_vars[idx], SYSTEM); + add_env_var_paths ("CPATH", INC_BRACKET); + add_env_var_paths (lang_env_vars[idx], INC_SYSTEM); target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc); @@ -493,14 +497,14 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, merge_include_chains (sysroot, pfile, verbose); - cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET], + cpp_set_include_chains (pfile, heads[INC_QUOTE], heads[INC_BRACKET], quote_ignores_source_dir); } /* Return the current chain of cpp dirs. */ struct cpp_dir * -get_added_cpp_dirs (int chain) +get_added_cpp_dirs (incpath_kind chain) { return heads[chain]; } |