From: Joel Rosdahl Date: Thu, 6 Jun 2024 10:54:12 +0000 (+0200) Subject: refactor: Convert ArgsInfo::included_pch_file to fs::path X-Git-Tag: v4.11~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=840a55f5402b4d0c948425fcb171381849de295e;p=thirdparty%2Fccache.git refactor: Convert ArgsInfo::included_pch_file to fs::path --- diff --git a/src/ccache/ArgsInfo.hpp b/src/ccache/ArgsInfo.hpp index c8969a8c..d0939827 100644 --- a/src/ccache/ArgsInfo.hpp +++ b/src/ccache/ArgsInfo.hpp @@ -75,7 +75,7 @@ struct ArgsInfo std::filesystem::path orig_included_pch_file; // The .gch/.pch/.pth file or directory used for compilation. - std::string included_pch_file; + std::filesystem::path included_pch_file; // Language to use for the compilation target (see language.c). std::string actual_language; diff --git a/src/ccache/argprocessing.cpp b/src/ccache/argprocessing.cpp index 5792a13f..2473c9dc 100644 --- a/src/ccache/argprocessing.cpp +++ b/src/ccache/argprocessing.cpp @@ -79,7 +79,7 @@ struct ArgumentProcessingState bool found_fpch_preprocess = false; bool found_Yu = false; bool found_Yc = false; - std::string found_Fp_file; + std::filesystem::path found_Fp_file; bool found_valid_Fp = false; bool found_syntax_only = false; ColorDiagnostics color_diagnostics = ColorDiagnostics::automatic; @@ -157,7 +157,7 @@ detect_pch(const std::string& option, // If the option is an option for Clang (is_cc1_option), don't accept // anything just because it has a corresponding precompiled header, // because Clang doesn't behave that way either. - std::string pch_file; + std::filesystem::path pch_file; if (option == "-Yc") { state.found_Yc = true; args_info.generating_pch = true; @@ -176,7 +176,7 @@ detect_pch(const std::string& option, fs::path file = util::with_extension(arg, ".pch"); if (fs::is_regular_file(file)) { LOG("Detected use of precompiled header: {}", file); - pch_file = util::pstr(file); + pch_file = file; } } } else if (option == "-Fp") { @@ -1374,9 +1374,9 @@ process_args(Context& ctx) } if (included_pch_file_by_source && !args_info.input_file.empty()) { - args_info.included_pch_file = util::pstr( + args_info.included_pch_file = util::with_extension(fs::path(args_info.input_file).filename(), - get_default_pch_file_extension(ctx.config))); + get_default_pch_file_extension(ctx.config)); LOG( "Setting PCH filepath from the base source file (during generating): " "{}", diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index b2fb27bf..4f6a4cf9 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -644,8 +644,8 @@ process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path) // mention of it in the preprocessed output. if (!ctx.args_info.included_pch_file.empty() && !ctx.args_info.generating_pch) { - std::string pch_path = util::pstr( - core::make_relative_path(ctx, ctx.args_info.included_pch_file)); + fs::path pch_path = + core::make_relative_path(ctx, ctx.args_info.included_pch_file); hash.hash(pch_path); TRY(remember_include_file(ctx, pch_path, hash, false, nullptr)); }