]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Fix some clang-tidy warnings
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 15 Jan 2024 17:51:01 +0000 (18:51 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 27 Jan 2024 09:50:16 +0000 (10:50 +0100)
src/.clang-tidy
src/Util.cpp
src/ccache.cpp
src/compopt.cpp
src/core/ResultRetriever.cpp
src/util/TemporaryFile.cpp
src/util/file.cpp
unittest/.clang-tidy

index 5832cc35e43492d0da1e1dfe2cd51dbe9939d3a8..3cbfef3a9469c8328eb5ca9212fb0897617565c2 100644 (file)
@@ -61,6 +61,7 @@ Checks: '
   -readability-convert-member-functions-to-static,
   -readability-else-after-return,
   -readability-function-cognitive-complexity,
+  -readability-identifier-length,
   -readability-implicit-bool-conversion,
   -readability-magic-numbers,
   -readability-named-parameter,
index 1e171c76c3fc97c2853c2e7608b7d01202e4ca55..6493df20bc6076ee9bfa6c276e0606023928c792 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "Util.hpp"
 
-#include "Config.hpp"
 #include "Context.hpp"
 
 #include <Config.hpp>
index 3e6e0338f37e2c4c9f72933103b81e8153473fb2..66420e24189625d820520ef63b9031cb3e7aa7b9 100644 (file)
@@ -1425,7 +1425,7 @@ hash_common_info(const Context& ctx,
 #ifdef _WIN32
   const std::string compiler_path = util::add_exe_suffix(args[0]);
 #else
-  const std::string compiler_path = args[0];
+  const std::string& compiler_path = args[0];
 #endif
 
   DirEntry dir_entry(compiler_path, DirEntry::LogOnError::yes);
index 01ad88e8fcae12243f15ceb2018be5d1bae99a46..8bac5169c77509dab6d863090eb10d3adf4167c8 100644 (file)
 #include <util/fmtmacros.hpp>
 
 // The option it too hard to handle at all.
-#define TOO_HARD (1 << 0)
+int TOO_HARD = 1 << 0;
 
 // The option it too hard for the direct mode.
-#define TOO_HARD_DIRECT (1 << 1)
+int TOO_HARD_DIRECT = 1 << 1;
 
 // The option takes a separate argument, e.g. "-D FOO=1".
-#define TAKES_ARG (1 << 2)
+int TAKES_ARG = 1 << 2;
 
 // The option takes a concatenated argument, e.g. "-DFOO=1".
-#define TAKES_CONCAT_ARG (1 << 3)
+int TAKES_CONCAT_ARG = 1 << 3;
 
 // The argument to the option is a path that may be rewritten if base_dir is
 // used.
-#define TAKES_PATH (1 << 4)
+int TAKES_PATH = 1 << 4;
 
 // The option only affects preprocessing; not passed to the compiler if
 // run_second_cpp is false.
-#define AFFECTS_CPP (1 << 5)
+int AFFECTS_CPP = 1 << 5;
 
 // The option only affects compilation; not passed to the preprocessor.
-#define AFFECTS_COMP (1 << 6)
+int AFFECTS_COMP = 1 << 6;
 
 struct CompOpt
 {
index 8f4a5567b482d22f2ccff937b87911db2fd4c7e4..999d08bf9daf5a075b39668a1ac7ea5dc64fdba4 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "ResultRetriever.hpp"
 
-#include "Context.hpp"
 #include "Depfile.hpp"
 
 #include <Context.hpp>
index cc1785fa410cd110fe0fbd98365450ff0367593f..744b46a3c33fa89dbac672d4016471f269c28aba 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -60,9 +60,9 @@ TemporaryFile::create(const fs::path& path_prefix, std::string_view suffix)
 
   // [1]: <https://github.com/Alexpux/mingw-w64/blob/
   // d0d7f784833bbb0b2d279310ddc6afb52fe47a46/mingw-w64-crt/misc/mkstemp.c>
-  Fd fd(bsd_mkstemps(&path_template[0], static_cast<int>(suffix.length())));
+  Fd fd(bsd_mkstemps(path_template.data(), static_cast<int>(suffix.length())));
 #else
-  Fd fd(mkstemps(&path_template[0], static_cast<int>(suffix.length())));
+  Fd fd(mkstemps(path_template.data(), static_cast<int>(suffix.length())));
 #endif
   if (!fd) {
     return tl::unexpected(FMT("failed to create temporary file for {}: {}",
index 4c2c2aff1f9c95e51bce20357ece06962dab7dc9..11d5bacccbb11db377defac56290286d1add3e81 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2023 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2024 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
 #endif
 
 #ifdef HAVE_UTIMENSAT
-#  include <fcntl.h>
-#  include <sys/stat.h>
 #elif defined(HAVE_UTIMES)
 #  include <sys/time.h>
 #else
-#  include <sys/types.h>
 #  ifdef HAVE_UTIME_H
 #    include <utime.h>
 #  elif defined(HAVE_SYS_UTIME_H)
index 1b93b055ab941da309316bfaf98c5907522695ff..0ae52b0dbf7a7bed315c277560a0529c945c5fc6 100644 (file)
@@ -4,6 +4,7 @@ Checks: '
   readability-*,
   -readability-else-after-return,
   -readability-function-cognitive-complexity,
+  -readability-identifier-length,
   -readability-implicit-bool-conversion,
   -readability-magic-numbers,
   -readability-named-parameter,