From: Joel Rosdahl Date: Sun, 26 Sep 2021 19:54:03 +0000 (+0200) Subject: refactor: Move included_pch_file from Context to ArgsInfo X-Git-Tag: v4.4.2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e1260404cb3ad3ebe543e36a99b0d28c884c08fb;p=thirdparty%2Fccache.git refactor: Move included_pch_file from Context to ArgsInfo --- diff --git a/src/ArgsInfo.hpp b/src/ArgsInfo.hpp index 6e9ea823b..41b18740b 100644 --- a/src/ArgsInfo.hpp +++ b/src/ArgsInfo.hpp @@ -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; diff --git a/src/Context.hpp b/src/Context.hpp index 547db9d3c..b681ddeaf 100644 --- a/src/Context.hpp +++ b/src/Context.hpp @@ -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 ignore_header_paths; diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index c77dd1125..3c94b6f47 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -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; } diff --git a/src/ccache.cpp b/src/ccache.cpp index 1d73e4dc0..93b860a63 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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); }