From: Joel Rosdahl Date: Mon, 17 Jul 2023 13:38:57 +0000 (+0200) Subject: refactor: Move Util::is_precompiled_header to argprocessing X-Git-Tag: v4.9~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8b54fc880cef198f98745230135c85d92250410;p=thirdparty%2Fccache.git refactor: Move Util::is_precompiled_header to argprocessing --- diff --git a/src/Util.cpp b/src/Util.cpp index 54c9fed30..8282835a8 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -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 localtime(std::optional time) { diff --git a/src/Util.hpp b/src/Util.hpp index 74d29c444..01c826a55 100644 --- a/src/Util.hpp +++ b/src/Util.hpp @@ -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 localtime(std::optional time = {}); diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index cecd904f1..25d2c8b80 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -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& patterns) diff --git a/src/argprocessing.hpp b/src/argprocessing.hpp index 8375b361e..bb114c681 100644 --- a/src/argprocessing.hpp +++ b/src/argprocessing.hpp @@ -24,6 +24,7 @@ #include #include +#include #include 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& patterns); diff --git a/src/ccache.cpp b/src/ccache.cpp index 6e0ace62d..d581c1de4 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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");