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

index c8969a8c4146db05d62f7e6eb74a1b5cd80500c8..d093982721f23d44a20a7b8733037d2adb45e390 100644 (file)
@@ -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;
index 5792a13f2c56f94d133a0b4c81981bc6fdb2e786..2473c9dc63c21d7e32a08cb01e817839d11ddee2 100644 (file)
@@ -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): "
         "{}",
index b2fb27bfc86a059eef28461913b0415a923b7597..4f6a4cf9cc586e70d0da283b460ebb3755ea6926 100644 (file)
@@ -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));
   }