]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Convert ArgsInfo::orig_input_file to fs::path
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 1 Jun 2024 10:57:23 +0000 (12:57 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 30 Jun 2024 15:18:49 +0000 (17:18 +0200)
src/ccache/ArgsInfo.hpp
src/ccache/argprocessing.cpp

index b9c7ac2deb6ee462c918b7e81c4c4f9ae4840446..607466ee043223edfb5659732819c29a66a64393 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <ccache/Args.hpp>
 
+#include <filesystem>
 #include <optional>
 #include <string>
 #include <unordered_map>
@@ -29,7 +30,7 @@
 struct ArgsInfo
 {
   // The source file path.
-  std::string orig_input_file;
+  std::filesystem::path orig_input_file;
 
   // The source file path, potentially rewritten into relative.
   std::string input_file;
index 08835e609cb248b706258f375b40410db75163d8..9e6dc8f7dfdda56891017effaaf1791168fb92ea 100644 (file)
@@ -1308,7 +1308,7 @@ process_args(Context& ctx)
     }
   }
 
-  args_info.orig_input_file = util::pstr(state.input_files.front());
+  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));
@@ -1453,8 +1453,8 @@ process_args(Context& ctx)
     || is_precompiled_header(args_info.output_obj);
 
   if (args_info.output_is_precompiled_header && output_obj_by_source) {
-    args_info.orig_output_obj =
-      args_info.orig_input_file + get_default_pch_file_extension(config);
+    args_info.orig_output_obj = util::pstr(util::add_extension(
+      args_info.orig_input_file, get_default_pch_file_extension(config)));
     args_info.output_obj =
       util::pstr(core::make_relative_path(ctx, args_info.orig_output_obj));
   }
@@ -1615,7 +1615,7 @@ process_args(Context& ctx)
           // GCC strangely uses the base name of the source file but with a .o
           // extension.
           dep_target = util::pstr(util::with_extension(
-            fs::path(args_info.orig_input_file).filename(),
+            args_info.orig_input_file.filename(),
             get_default_object_file_extension(ctx.config)));
         } else {
           // How other compilers behave is currently unknown, so bail out.
@@ -1645,8 +1645,8 @@ process_args(Context& ctx)
   }
 
   if (args_info.generating_ipa_clones) {
-    fs::path ipa_path(args_info.orig_input_file + ".000i.ipa-clones");
-    args_info.output_ipa = util::pstr(core::make_relative_path(ctx, ipa_path));
+    args_info.output_ipa = util::pstr(core::make_relative_path(
+      ctx, util::add_extension(args_info.orig_input_file, ".000i.ipa-clones")));
   }
 
   Args compiler_args = state.common_args;