From: Joel Rosdahl Date: Mon, 15 Jan 2024 17:51:01 +0000 (+0100) Subject: chore: Fix some clang-tidy warnings X-Git-Tag: v4.10~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2904e2d7affe0c3042ad97e239f983c686d9d01a;p=thirdparty%2Fccache.git chore: Fix some clang-tidy warnings --- diff --git a/src/.clang-tidy b/src/.clang-tidy index 5832cc35e..3cbfef3a9 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -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, diff --git a/src/Util.cpp b/src/Util.cpp index 1e171c76c..6493df20b 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -18,7 +18,6 @@ #include "Util.hpp" -#include "Config.hpp" #include "Context.hpp" #include diff --git a/src/ccache.cpp b/src/ccache.cpp index 3e6e0338f..66420e241 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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); diff --git a/src/compopt.cpp b/src/compopt.cpp index 01ad88e8f..8bac5169c 100644 --- a/src/compopt.cpp +++ b/src/compopt.cpp @@ -21,27 +21,27 @@ #include // 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 { diff --git a/src/core/ResultRetriever.cpp b/src/core/ResultRetriever.cpp index 8f4a5567b..999d08bf9 100644 --- a/src/core/ResultRetriever.cpp +++ b/src/core/ResultRetriever.cpp @@ -18,7 +18,6 @@ #include "ResultRetriever.hpp" -#include "Context.hpp" #include "Depfile.hpp" #include diff --git a/src/util/TemporaryFile.cpp b/src/util/TemporaryFile.cpp index cc1785fa4..744b46a3c 100644 --- a/src/util/TemporaryFile.cpp +++ b/src/util/TemporaryFile.cpp @@ -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]: - Fd fd(bsd_mkstemps(&path_template[0], static_cast(suffix.length()))); + Fd fd(bsd_mkstemps(path_template.data(), static_cast(suffix.length()))); #else - Fd fd(mkstemps(&path_template[0], static_cast(suffix.length()))); + Fd fd(mkstemps(path_template.data(), static_cast(suffix.length()))); #endif if (!fd) { return tl::unexpected(FMT("failed to create temporary file for {}: {}", diff --git a/src/util/file.cpp b/src/util/file.cpp index 4c2c2aff1..11d5baccc 100644 --- a/src/util/file.cpp +++ b/src/util/file.cpp @@ -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. // @@ -35,12 +35,9 @@ #endif #ifdef HAVE_UTIMENSAT -# include -# include #elif defined(HAVE_UTIMES) # include #else -# include # ifdef HAVE_UTIME_H # include # elif defined(HAVE_SYS_UTIME_H) diff --git a/unittest/.clang-tidy b/unittest/.clang-tidy index 1b93b055a..0ae52b0db 100644 --- a/unittest/.clang-tidy +++ b/unittest/.clang-tidy @@ -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,