From 6fffc6478a34dae931de47ab78e915dd485f2a42 Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Sat, 25 Jan 2020 10:55:49 +0100 Subject: [PATCH] Context: move has_absolute_include_headers --- src/Context.hpp | 3 +++ src/ccache.cpp | 11 +++++------ src/legacy_globals.cpp | 3 --- src/legacy_globals.hpp | 2 -- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Context.hpp b/src/Context.hpp index cb60dcb6e..4931ebc63 100644 --- a/src/Context.hpp +++ b/src/Context.hpp @@ -69,4 +69,7 @@ struct Context : NonCopyable // Files included by the preprocessor and their hashes. // Key: file path. Value: struct digest. std::unordered_map included_files; + + // Uses absolute path for some include files. + bool has_absolute_include_headers = false; }; diff --git a/src/ccache.cpp b/src/ccache.cpp index 7a0ce2259..a15b58d63 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -806,8 +806,8 @@ process_preprocessed_file(Context& ctx, } // p and q span the include file path. char* inc_path = x_strndup(p, q - p); - if (!has_absolute_include_headers) { - has_absolute_include_headers = is_absolute_path(inc_path); + if (!ctx.has_absolute_include_headers) { + ctx.has_absolute_include_headers = is_absolute_path(inc_path); } char* saved_inc_path = inc_path; inc_path = x_strdup(make_relative_path(ctx, inc_path).c_str()); @@ -892,7 +892,7 @@ use_relative_paths_in_depfile(const Context& ctx) cc_log("Base dir not set, skip using relative paths"); return; // nothing to do } - if (!has_absolute_include_headers) { + if (!ctx.has_absolute_include_headers) { cc_log( "No absolute path for included files found, skip using relative" " paths"); @@ -994,8 +994,8 @@ result_name_from_depfile(Context& ctx, struct hash* hash) if (str_endswith(token, ":") || str_eq(token, "\\")) { continue; } - if (!has_absolute_include_headers) { - has_absolute_include_headers = is_absolute_path(token); + if (!ctx.has_absolute_include_headers) { + ctx.has_absolute_include_headers = is_absolute_path(token); } std::string path = make_relative_path(ctx, token); remember_include_file(ctx, path, hash, false, hash); @@ -3531,7 +3531,6 @@ cc_reset() } free_and_nullify(ignore_headers); ignore_headers_len = 0; - has_absolute_include_headers = false; i_tmpfile = NULL; free_and_nullify(cpp_stderr); } diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp index 7c91213de..80898479c 100644 --- a/src/legacy_globals.cpp +++ b/src/legacy_globals.cpp @@ -18,9 +18,6 @@ #include "legacy_globals.hpp" -// Uses absolute path for some include files. -bool has_absolute_include_headers = false; - // List of headers to ignore. char** ignore_headers; diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp index 2e065b8d7..eba4d1400 100644 --- a/src/legacy_globals.hpp +++ b/src/legacy_globals.hpp @@ -30,8 +30,6 @@ extern unsigned lock_staleness_limit; -extern bool has_absolute_include_headers; - extern char** ignore_headers; extern size_t ignore_headers_len; -- 2.47.2