From: Thomas Otto Date: Sat, 25 Jan 2020 09:54:50 +0000 (+0100) Subject: Context: move g_included_files X-Git-Tag: v4.0~613^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35bcc8dc7a91d8f0dee45ec0a5fdcf0affe0c93f;p=thirdparty%2Fccache.git Context: move g_included_files --- diff --git a/src/Context.hpp b/src/Context.hpp index 9335e80ab..cb60dcb6e 100644 --- a/src/Context.hpp +++ b/src/Context.hpp @@ -23,9 +23,11 @@ #include "ArgsInfo.hpp" #include "Config.hpp" #include "NonCopyable.hpp" +#include "hash.hpp" + +#include struct args; -struct digest; struct Context : NonCopyable { @@ -63,4 +65,8 @@ struct Context : NonCopyable // Time of compilation. Used to see if include files have changed after // compilation. time_t time_of_compilation = 0; + + // Files included by the preprocessor and their hashes. + // Key: file path. Value: struct digest. + std::unordered_map included_files; }; diff --git a/src/ccache.cpp b/src/ccache.cpp index ed8ba7440..7a0ce2259 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -441,7 +441,7 @@ do_remember_include_file(Context& ctx, return true; } - if (g_included_files.find(path) != g_included_files.end()) { + if (ctx.included_files.find(path) != ctx.included_files.end()) { // Already known include file. return true; } @@ -566,7 +566,7 @@ do_remember_include_file(Context& ctx, digest d; hash_result_as_bytes(fhash, &d); - g_included_files.emplace(path, d); + ctx.included_files.emplace(path, d); if (depend_mode_hash) { hash_delimiter(depend_mode_hash, "include"); @@ -597,9 +597,9 @@ remember_include_file(Context& ctx, } static void -print_included_files(FILE* fp) +print_included_files(Context& ctx, FILE* fp) { - for (const auto& item : g_included_files) { + for (const auto& item : ctx.included_files) { fprintf(fp, "%s\n", item.first.c_str()); } } @@ -876,7 +876,7 @@ process_preprocessed_file(Context& ctx, bool debug_included = getenv("CCACHE_DEBUG_INCLUDED"); if (debug_included) { - print_included_files(stdout); + print_included_files(ctx, stdout); } return true; @@ -1014,7 +1014,7 @@ result_name_from_depfile(Context& ctx, struct hash* hash) bool debug_included = getenv("CCACHE_DEBUG_INCLUDED"); if (debug_included) { - print_included_files(stdout); + print_included_files(ctx, stdout); } auto d = static_cast(x_malloc(sizeof(digest))); @@ -1054,7 +1054,7 @@ update_manifest_file(Context& ctx) if (!manifest_put(ctx.config, ctx.manifest_path, *ctx.result_name, - g_included_files, + ctx.included_files, ctx.time_of_compilation, save_timestamp)) { cc_log("Failed to add result name to %s", ctx.manifest_path.c_str()); @@ -3531,7 +3531,6 @@ cc_reset() } free_and_nullify(ignore_headers); ignore_headers_len = 0; - g_included_files.clear(); 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 db97e16d5..7c91213de 100644 --- a/src/legacy_globals.cpp +++ b/src/legacy_globals.cpp @@ -18,10 +18,6 @@ #include "legacy_globals.hpp" -// Files included by the preprocessor and their hashes. Key: file path. Value: -// struct digest. -std::unordered_map g_included_files; - // Uses absolute path for some include files. bool has_absolute_include_headers = false; diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp index 707cd6224..2e065b8d7 100644 --- a/src/legacy_globals.hpp +++ b/src/legacy_globals.hpp @@ -30,8 +30,6 @@ extern unsigned lock_staleness_limit; -extern std::unordered_map g_included_files; - extern bool has_absolute_include_headers; extern char** ignore_headers;