]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Move included_pch_file from Context to ArgsInfo
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 26 Sep 2021 19:54:03 +0000 (21:54 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 26 Sep 2021 19:55:09 +0000 (21:55 +0200)
src/ArgsInfo.hpp
src/Context.hpp
src/argprocessing.cpp
src/ccache.cpp

index 6e9ea823b1f62bda816aa11747476feb2a5ffb85..41b18740b0ac8c99412eb8a02b53cc75171caaf2 100644 (file)
@@ -49,6 +49,9 @@ struct ArgsInfo
   // Split dwarf information (GCC 4.8 and up). Contains pathname if not empty.
   std::string output_dwo;
 
+  // The .gch/.pch/.pth file used for compilation.
+  std::string included_pch_file;
+
   // Language to use for the compilation target (see language.c).
   std::string actual_language;
 
index 547db9d3cf16d67d5f2f7909ee91c5a7e62c96e1..b681ddeafd8b34a5657b9657199fce2dd96b1be3 100644 (file)
@@ -83,9 +83,6 @@ public:
   // The name of the cpp stderr file.
   std::string cpp_stderr;
 
-  // The .gch/.pch/.pth file used for compilation.
-  std::string included_pch_file;
-
   // Headers (or directories with headers) to ignore in manifest mode.
   std::vector<std::string> ignore_header_paths;
 
index c77dd1125031e2c4357f4eae7c3eb1668d1810ab..3c94b6f47e1d03a8a55a3160cd37e790c41c59ee 100644 (file)
@@ -106,9 +106,9 @@ color_output_possible()
 }
 
 bool
-detect_pch(Context& ctx,
-           const std::string& option,
+detect_pch(const std::string& option,
            const std::string& arg,
+           std::string& included_pch_file,
            bool is_cc1_option,
            bool* found_pch)
 {
@@ -135,13 +135,13 @@ detect_pch(Context& ctx,
   }
 
   if (!pch_file.empty()) {
-    if (!ctx.included_pch_file.empty()) {
+    if (!included_pch_file.empty()) {
       LOG("Multiple precompiled headers used: {} and {}",
-          ctx.included_pch_file,
+          included_pch_file,
           pch_file);
       return false;
     }
-    ctx.included_pch_file = pch_file;
+    included_pch_file = pch_file;
     *found_pch = true;
   }
   return true;
@@ -821,8 +821,11 @@ process_arg(Context& ctx,
       next = 2;
     }
 
-    if (!detect_pch(
-          ctx, args[i], args[i + next], next == 2, &state.found_pch)) {
+    if (!detect_pch(args[i],
+                    args[i + next],
+                    args_info.included_pch_file,
+                    next == 2,
+                    &state.found_pch)) {
       return Statistic::bad_compiler_arguments;
     }
 
index 1d73e4dc0d6162c1fb9815b25e01b45672c8fc15..93b860a632d3aa2083bb2508ba7f02c45fd7841b 100644 (file)
@@ -355,7 +355,7 @@ do_remember_include_file(Context& ctx,
   Hash fhash;
 
   if (is_pch) {
-    if (ctx.included_pch_file.empty()) {
+    if (ctx.args_info.included_pch_file.empty()) {
       LOG("Detected use of precompiled header: {}", path);
     }
     bool using_pch_sum = false;
@@ -608,8 +608,9 @@ process_preprocessed_file(Context& ctx,
 
   // Explicitly check the .gch/.pch/.pth file as Clang does not include any
   // mention of it in the preprocessed output.
-  if (!ctx.included_pch_file.empty()) {
-    std::string pch_path = Util::make_relative_path(ctx, ctx.included_pch_file);
+  if (!ctx.args_info.included_pch_file.empty()) {
+    std::string pch_path =
+      Util::make_relative_path(ctx, ctx.args_info.included_pch_file);
     hash.hash(pch_path);
     remember_include_file(ctx, pch_path, hash, false, nullptr);
   }
@@ -649,8 +650,9 @@ result_key_from_depfile(Context& ctx, Hash& hash)
 
   // Explicitly check the .gch/.pch/.pth file as it may not be mentioned in the
   // dependencies output.
-  if (!ctx.included_pch_file.empty()) {
-    std::string pch_path = Util::make_relative_path(ctx, ctx.included_pch_file);
+  if (!ctx.args_info.included_pch_file.empty()) {
+    std::string pch_path =
+      Util::make_relative_path(ctx, ctx.args_info.included_pch_file);
     hash.hash(pch_path);
     remember_include_file(ctx, pch_path, hash, false, nullptr);
   }