From: Joel Rosdahl Date: Sat, 1 Jun 2024 11:05:32 +0000 (+0200) Subject: refactor: Convert ArgsInfo::input_file to fs::path X-Git-Tag: v4.11~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a269308743a02593c4c90cb4b1ffbfe7ef53d396;p=thirdparty%2Fccache.git refactor: Convert ArgsInfo::input_file to fs::path --- diff --git a/src/ccache/ArgsInfo.hpp b/src/ccache/ArgsInfo.hpp index 607466ee..642c1c2d 100644 --- a/src/ccache/ArgsInfo.hpp +++ b/src/ccache/ArgsInfo.hpp @@ -33,7 +33,7 @@ struct ArgsInfo std::filesystem::path orig_input_file; // The source file path, potentially rewritten into relative. - std::string input_file; + std::filesystem::path input_file; // Prefix to the input file when adding it to a command line. std::string input_file_prefix; diff --git a/src/ccache/argprocessing.cpp b/src/ccache/argprocessing.cpp index 9e6dc8f7..337975ae 100644 --- a/src/ccache/argprocessing.cpp +++ b/src/ccache/argprocessing.cpp @@ -1311,7 +1311,7 @@ process_args(Context& ctx) args_info.orig_input_file = state.input_files.front(); // Rewrite to relative to increase hit rate. args_info.input_file = - util::pstr(core::make_relative_path(ctx, args_info.orig_input_file)); + core::make_relative_path(ctx, args_info.orig_input_file); // Bail out on too hard combinations of options. if (state.found_mf_opt && state.found_wp_md_or_mmd_opt) { @@ -1474,10 +1474,11 @@ process_args(Context& ctx) LOG_RAW("No -c option found"); // Having a separate statistic for autoconf tests is useful, as they are // the dominant form of "called for link" in many cases. - return tl::unexpected(args_info.input_file.find("conftest.") - != std::string::npos - ? Statistic::autoconf_test - : Statistic::called_for_link); + return tl::unexpected( + util::pstr(args_info.input_file).str().find("conftest.") + != std::string::npos + ? Statistic::autoconf_test + : Statistic::called_for_link); } } diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index cc2e99d1..8d3607b4 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -1285,7 +1285,7 @@ get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash) if (ctx.args_info.direct_i_file) { // We are compiling a .i or .ii file - that means we can skip the cpp stage // and directly form the correct i_tmpfile. - preprocessed_path = ctx.args_info.input_file; + preprocessed_path = util::pstr(ctx.args_info.input_file); } else { // Run cpp on the input file to obtain the .i.