From: Joel Rosdahl Date: Sat, 8 Jun 2024 18:57:13 +0000 (+0200) Subject: refactor: Clean up some fs::path usage X-Git-Tag: v4.11~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=082eb41d72b36ad0abe5ceb98c751bf2708f4118;p=thirdparty%2Fccache.git refactor: Clean up some fs::path usage --- diff --git a/src/ccache/argprocessing.cpp b/src/ccache/argprocessing.cpp index be335d1f..8ecd6c54 100644 --- a/src/ccache/argprocessing.cpp +++ b/src/ccache/argprocessing.cpp @@ -918,7 +918,7 @@ process_option_arg(const Context& ctx, } state.common_args.push_back(args[i]); auto relpath = core::make_relative_path(ctx, args[i + 1]); - state.common_args.push_back(util::pstr(relpath)); + state.common_args.push_back(relpath); i++; return Statistic::none; } @@ -1125,7 +1125,7 @@ process_option_arg(const Context& ctx, if (next == 2) { dest_args.push_back(args[i + 1]); } - dest_args.push_back(util::pstr(relpath)); + dest_args.push_back(relpath); i += next; return Statistic::none; @@ -1595,7 +1595,7 @@ process_args(Context& ctx) } if (!args_info.dependency_target) { - std::string dep_target = util::pstr(args_info.orig_output_obj); + fs::path dep_target = args_info.orig_output_obj; // GCC and Clang behave differently when "-Wp,-M[M]D,wp.d" is used with // "-o" but with neither "-MMD" nor "-MT"/"-MQ": GCC uses a dependency @@ -1609,9 +1609,9 @@ process_args(Context& ctx) } else if (config.compiler_type() == CompilerType::gcc) { // GCC strangely uses the base name of the source file but with a .o // extension. - dep_target = util::pstr(util::with_extension( - args_info.orig_input_file.filename(), - get_default_object_file_extension(ctx.config))); + dep_target = + util::with_extension(args_info.orig_input_file.filename(), + get_default_object_file_extension(ctx.config)); } else { // How other compilers behave is currently unknown, so bail out. LOG_RAW( @@ -1621,7 +1621,8 @@ process_args(Context& ctx) } } - args_info.dependency_target = Depfile::escape_filename(dep_target); + args_info.dependency_target = + Depfile::escape_filename(util::pstr(dep_target).str()); } } diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index b5a26391..a250d4c4 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -1553,10 +1553,9 @@ hash_common_info(const Context& ctx, // even without debug flags. Hashing the directory should be enough since the // filename is included in the hash anyway. if (ctx.config.is_compiler_group_msvc() && ctx.config.hash_dir()) { - const std::string output_obj_dir = - args_info.output_obj.is_absolute() - ? args_info.output_obj.parent_path().string() - : util::pstr(ctx.actual_cwd); + const fs::path& output_obj_dir = args_info.output_obj.is_absolute() + ? args_info.output_obj.parent_path() + : ctx.actual_cwd; LOG("Hashing object file directory {}", output_obj_dir); hash.hash_delimiter("source path"); hash.hash(output_obj_dir);