From: Joel Rosdahl Date: Thu, 3 Feb 2022 19:49:11 +0000 (+0100) Subject: style: Improve names related to clang-cl X-Git-Tag: v4.6~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=caa5bcbb8040323dd58459490af0737d69c106bc;p=thirdparty%2Fccache.git style: Improve names related to clang-cl --- diff --git a/src/Config.cpp b/src/Config.cpp index 55105a266..61e621647 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -242,7 +242,7 @@ parse_compiler_type(const std::string& value) if (value == "clang") { return CompilerType::clang; } else if (value == "clang-cl") { - return CompilerType::clangcl; + return CompilerType::clang_cl; } else if (value == "gcc") { return CompilerType::gcc; } else if (value == "msvc") { @@ -453,7 +453,7 @@ compiler_type_to_string(CompilerType compiler_type) return "auto"; CASE(clang); - CASE(clangcl); + CASE(clang_cl); CASE(gcc); CASE(msvc); CASE(nvcc); diff --git a/src/Config.hpp b/src/Config.hpp index d138e6dec..6275fa659 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -31,7 +31,7 @@ #include #include -enum class CompilerType { auto_guess, clang, clangcl, gcc, msvc, nvcc, other }; +enum class CompilerType { auto_guess, clang, clang_cl, gcc, msvc, nvcc, other }; std::string compiler_type_to_string(CompilerType compiler_type); @@ -48,10 +48,6 @@ public: const std::string& compiler() const; const std::string& compiler_check() const; CompilerType compiler_type() const; - // Returns true for clang or clangcl. - bool is_compiler_group_clang() const; - // Returns true for cl or clangcl. - bool is_compiler_group_cl() const; bool compression() const; int8_t compression_level() const; const std::string& cpp_extension() const; @@ -89,6 +85,12 @@ public: const std::string& temporary_dir() const; nonstd::optional umask() const; + // Return true for Clang and clang-cl. + bool is_compiler_group_clang() const; + + // Return true for MSVC (cl.exe) and clang-cl. + bool is_compiler_group_msvc() const; + void set_base_dir(const std::string& value); void set_cache_dir(const std::string& value); void set_compiler(const std::string& value); @@ -240,14 +242,14 @@ inline bool Config::is_compiler_group_clang() const { return m_compiler_type == CompilerType::clang - || m_compiler_type == CompilerType::clangcl; + || m_compiler_type == CompilerType::clang_cl; } inline bool -Config::is_compiler_group_cl() const +Config::is_compiler_group_msvc() const { return m_compiler_type == CompilerType::msvc - || m_compiler_type == CompilerType::clangcl; + || m_compiler_type == CompilerType::clang_cl; } inline bool diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index 345a4ddd2..3b09fbe1c 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -273,7 +273,7 @@ process_arg(const Context& ctx, } bool changed_from_slash = false; - if (ctx.config.is_compiler_group_cl() && util::starts_with(args[i], "/")) { + if (ctx.config.is_compiler_group_msvc() && util::starts_with(args[i], "/")) { // MSVC understands both /option and -option, so convert all /option to // -option to simplify our handling. args[i][0] = '-'; @@ -294,7 +294,7 @@ process_arg(const Context& ctx, return Statistic::called_for_preprocessing; } // MSVC -P is -E with output to a file. - if (args[i] == "-P" && ctx.config.is_compiler_group_cl()) { + if (args[i] == "-P" && ctx.config.is_compiler_group_msvc()) { return Statistic::called_for_preprocessing; } @@ -306,7 +306,7 @@ process_arg(const Context& ctx, ++argpath; } auto file_args = - Args::from_atfile(argpath, ctx.config.is_compiler_group_cl()); + Args::from_atfile(argpath, ctx.config.is_compiler_group_msvc()); if (!file_args) { LOG("Couldn't read arg file {}", argpath); return Statistic::bad_compiler_arguments; @@ -449,7 +449,7 @@ process_arg(const Context& ctx, } // MSVC -Fo with no space. - if (util::starts_with(args[i], "-Fo") && config.is_compiler_group_cl()) { + if (util::starts_with(args[i], "-Fo") && config.is_compiler_group_msvc()) { args_info.output_obj = Util::make_relative_path(ctx, string_view(args[i]).substr(3)); return nullopt; @@ -568,7 +568,7 @@ process_arg(const Context& ctx, // These options require special handling, because they behave differently // with gcc -E, when the output file is not specified. if ((args[i] == "-MD" || args[i] == "-MMD") - && !config.is_compiler_group_cl()) { + && !config.is_compiler_group_msvc()) { args_info.generating_dependencies = true; args_info.seen_MD_MMD = true; state.dep_args.push_back(args[i]); @@ -604,7 +604,7 @@ process_arg(const Context& ctx, } if ((util::starts_with(args[i], "-MQ") || util::starts_with(args[i], "-MT")) - && !config.is_compiler_group_cl()) { + && !config.is_compiler_group_msvc()) { args_info.dependency_target_specified = true; if (args[i].size() == 3) { @@ -628,7 +628,7 @@ process_arg(const Context& ctx, // MSVC -MD[d], -MT[d] and -LT[d] options are something different than GCC's // -MD etc. - if (config.is_compiler_group_cl() + if (config.is_compiler_group_msvc() && (util::starts_with(args[i], "-MD") || util::starts_with(args[i], "-MT") || util::starts_with(args[i], "-LD"))) { // These affect compiler but also #define some things. @@ -878,7 +878,7 @@ process_arg(const Context& ctx, } // MSVC -u is something else than GCC -u, handle it specially. - if (args[i] == "-u" && ctx.config.is_compiler_group_cl()) { + if (args[i] == "-u" && ctx.config.is_compiler_group_msvc()) { state.cpp_args.push_back(args[i]); return nullopt; } @@ -1128,7 +1128,7 @@ process_args(Context& ctx) string_view extension; if (state.found_S_opt) { extension = ".s"; - } else if (!ctx.config.is_compiler_group_cl()) { + } else if (!ctx.config.is_compiler_group_msvc()) { extension = ".o"; } else { extension = ".obj"; diff --git a/src/ccache.cpp b/src/ccache.cpp index 3170d3ca1..a822263d0 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -230,7 +230,7 @@ guess_compiler(string_view path) const auto name = Util::to_lowercase(Util::remove_extension(Util::base_name(compiler_path))); if (name.find("clang-cl") != nonstd::string_view::npos) { - return CompilerType::clangcl; + return CompilerType::clang_cl; } else if (name.find("clang") != nonstd::string_view::npos) { return CompilerType::clang; } else if (name.find("gcc") != nonstd::string_view::npos @@ -936,7 +936,7 @@ to_cache(Context& ctx, const Args& depend_extra_args, Hash* depend_mode_hash) { - if (ctx.config.is_compiler_group_cl()) { + if (ctx.config.is_compiler_group_msvc()) { args.push_back(fmt::format("-Fo{}", ctx.args_info.output_obj)); } else { args.push_back("-o"); @@ -2122,7 +2122,7 @@ do_cache_compilation(Context& ctx, const char* const* argv) TRY(set_up_uncached_err()); - if (!ctx.config.run_second_cpp() && ctx.config.is_compiler_group_cl()) { + if (!ctx.config.run_second_cpp() && ctx.config.is_compiler_group_msvc()) { LOG_RAW("Second preprocessor cannot be disabled"); ctx.config.set_run_second_cpp(true); }