]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
style: Improve names related to clang-cl
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Feb 2022 19:49:11 +0000 (20:49 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Feb 2022 19:49:11 +0000 (20:49 +0100)
src/Config.cpp
src/Config.hpp
src/argprocessing.cpp
src/ccache.cpp

index 55105a266e327ed5291e7dc7d561d52ddd86c9d9..61e621647ff6bd2ab03c7f3de2ebb397e1c45a2b 100644 (file)
@@ -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);
index d138e6dec47ee0f46fe9bc216349bed282e2f619..6275fa65930245cdcb8b3a092c4b90ab700a9522 100644 (file)
@@ -31,7 +31,7 @@
 #include <string>
 #include <unordered_map>
 
-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<mode_t> 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
index 345a4ddd2410d3c3bee4ee67d897ee2fdf97c9e7..3b09fbe1cf2222a01a1100c01f4cf218e775f215 100644 (file)
@@ -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";
index 3170d3ca15a0f3b8f8407ba29665cfadebfedeb2..a822263d0bbdf3b22486a53f82abd78bbefb2d00 100644 (file)
@@ -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);
   }