]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: move g_included_files
authorThomas Otto <thomas.otto@pdv-fs.de>
Sat, 25 Jan 2020 09:54:50 +0000 (10:54 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Mon, 17 Feb 2020 20:54:58 +0000 (21:54 +0100)
src/Context.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp

index 9335e80abefc8565369df6e1e8791ce8a6a10e48..cb60dcb6e80debcfdd8a7d063f84673270a48d6f 100644 (file)
 #include "ArgsInfo.hpp"
 #include "Config.hpp"
 #include "NonCopyable.hpp"
+#include "hash.hpp"
+
+#include <unordered_map>
 
 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<std::string, digest> included_files;
 };
index ed8ba7440292c2de70f1a126b8307dec43b1792c..7a0ce22590978cbb21689365f06d50b079067c89 100644 (file)
@@ -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<digest*>(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);
index db97e16d52a45457a1b54efc9fef56633329970b..7c91213de5c59484a6e14b07ecec0dec946328b2 100644 (file)
 
 #include "legacy_globals.hpp"
 
-// Files included by the preprocessor and their hashes. Key: file path. Value:
-// struct digest.
-std::unordered_map<std::string, digest> g_included_files;
-
 // Uses absolute path for some include files.
 bool has_absolute_include_headers = false;
 
index 707cd62249271e1fa00f2e12de9647e55093a11b..2e065b8d75d576d483f5f04a4e999f30ca3b30e6 100644 (file)
@@ -30,8 +30,6 @@
 
 extern unsigned lock_staleness_limit;
 
-extern std::unordered_map<std::string, digest> g_included_files;
-
 extern bool has_absolute_include_headers;
 
 extern char** ignore_headers;