]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Move Util::is_precompiled_header to argprocessing
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 17 Jul 2023 13:38:57 +0000 (15:38 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 18 Jul 2023 19:37:06 +0000 (21:37 +0200)
src/Util.cpp
src/Util.hpp
src/argprocessing.cpp
src/argprocessing.hpp
src/ccache.cpp

index 54c9fed30bf2cac73a6a148b5d66d5886b9d0e47..8282835a886c33001a3ad675b75cfa9a4cbf8adb 100644 (file)
@@ -363,14 +363,6 @@ is_ccache_executable(const std::string_view path)
   return util::starts_with(name, "ccache");
 }
 
-bool
-is_precompiled_header(std::string_view path)
-{
-  std::string_view ext = get_extension(path);
-  return ext == ".gch" || ext == ".pch" || ext == ".pth"
-         || get_extension(dir_name(path)) == ".gch";
-}
-
 std::optional<tm>
 localtime(std::optional<util::TimePoint> time)
 {
index 74d29c4444ec902294beb62645a48e27b8d0636a..01c826a55ea5e32e12c6f500361b3f9d1cb0c5db 100644 (file)
@@ -93,10 +93,6 @@ is_dir_separator(char ch)
     ;
 }
 
-// Return whether `path` represents a precompiled header (see "Precompiled
-// Headers" in GCC docs).
-bool is_precompiled_header(std::string_view path);
-
 // Thread-safe version of `localtime(3)`. If `time` is not specified the current
 // time of day is used.
 std::optional<tm> localtime(std::optional<util::TimePoint> time = {});
index cecd904f16f03963b5f65b64b5abdc498980df94..25d2c8b80d1d52d5331702d22e9354f1c80aba8d 100644 (file)
@@ -1289,7 +1289,7 @@ process_args(Context& ctx)
 
   args_info.output_is_precompiled_header =
     args_info.actual_language.find("-header") != std::string::npos
-    || Util::is_precompiled_header(args_info.output_obj);
+    || 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 + ".gch";
@@ -1584,6 +1584,14 @@ process_args(Context& ctx)
   };
 }
 
+bool
+is_precompiled_header(std::string_view path)
+{
+  std::string_view ext = Util::get_extension(path);
+  return ext == ".gch" || ext == ".pch" || ext == ".pth"
+         || Util::get_extension(Util::dir_name(path)) == ".gch";
+}
+
 bool
 option_should_be_ignored(const std::string& arg,
                          const std::vector<std::string>& patterns)
index 8375b361eeb5447f4cbe220b2d245039e29bd005..bb114c6819c8df1adf39b8607755d48dae6d616d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <optional>
 #include <string>
+#include <string_view>
 #include <vector>
 
 class Context;
@@ -71,5 +72,9 @@ inline ProcessArgsResult::ProcessArgsResult(const Args& preprocessor_args_,
 
 ProcessArgsResult process_args(Context& ctx);
 
+// Return whether `path` represents a precompiled header (see "Precompiled
+// Headers" in GCC docs).
+bool is_precompiled_header(std::string_view path);
+
 bool option_should_be_ignored(const std::string& arg,
                               const std::vector<std::string>& patterns);
index 6e0ace62d1e5c2b341fcfc89e27ebd04decb0b79..d581c1de4dfc81b3a100618460e6ca00717dbc92 100644 (file)
@@ -370,7 +370,7 @@ do_remember_include_file(Context& ctx,
     }
   }
 
-  const bool is_pch = Util::is_precompiled_header(path);
+  const bool is_pch = is_precompiled_header(path);
   const bool too_new = include_file_too_new(ctx, path, st);
 
   if (too_new) {
@@ -447,7 +447,7 @@ remember_include_file(Context& ctx,
 {
   if (!do_remember_include_file(
         ctx, path, cpp_hash, system, depend_mode_hash)) {
-    if (Util::is_precompiled_header(path)) {
+    if (is_precompiled_header(path)) {
       return RememberIncludeFileResult::cannot_use_pch;
     } else if (ctx.config.direct_mode()) {
       LOG_RAW("Disabling direct mode");