]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix scanning of headers with Clang-Tidy (#758)
authorAlexander Lanin <alex@lanin.de>
Wed, 6 Jan 2021 20:50:41 +0000 (21:50 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Jan 2021 20:50:41 +0000 (21:50 +0100)
By adding . as an include directory, CMake actually took it literally and files
are included from e.g. src/./AtomicFile.h. However in .clang-tidy headers with
an additional slash (headers from subdirectory third_party) are excluded from
reports.

This commit:

- gets rid of include via .
- fixes some warnings
- disables the rest

src/.clang-tidy
src/CMakeLists.txt
src/Config.hpp
src/NonCopyable.hpp
src/argprocessing.hpp
src/third_party/CMakeLists.txt
unittest/CMakeLists.txt

index 0f3fa75345ab3fea3fc7677c5e8f2b6dce963fbb..f30529dc0d62a5f0803e554b59d9a2813cdbec88 100644 (file)
@@ -13,14 +13,17 @@ Checks:          '-*,
                   -readability-implicit-bool-conversion,
                   -readability-magic-numbers,
                   -readability-else-after-return,
+                  -readability-named-parameter,
                   -readability-qualified-auto,
-                  -readability-magic-numbers,
+                  -readability-redundant-declaration,
                   performance-*,
                   -performance-unnecessary-value-param,
                   modernize-*,
                   -modernize-avoid-c-arrays,
                   -modernize-pass-by-value,
+                  -modernize-return-braced-init-list,
                   -modernize-use-auto,
+                  -modernize-use-default-member-init,
                   -modernize-use-trailing-return-type,
                   cppcoreguidelines-*,
                   -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
@@ -40,6 +43,8 @@ Checks:          '-*,
                   -cppcoreguidelines-pro-type-reinterpret-cast,
                   -cppcoreguidelines-pro-type-union-access,
                   -cppcoreguidelines-narrowing-conversions,
+                  -cppcoreguidelines-non-private-member-variables-in-classes,
+                  -cppcoreguidelines-special-member-functions,
                   bugprone-*,
                   -bugprone-signed-char-misuse,
                   -bugprone-branch-clone,
@@ -47,6 +52,7 @@ Checks:          '-*,
                   cert-*,
                   -cert-err34-c,
                   -cert-dcl50-cpp,
+                  -cert-dcl58-cpp,
                   -cert-err58-cpp,
                   clang-diagnostic-*,
                   clang-analyzer-*,
index 30a2f92c2633353db55929608fcfbb6c1349ce61..beefd81f1fc2a1efc36bc581a53c5ba8278ec6d1 100644 (file)
@@ -77,6 +77,6 @@ target_link_libraries(
   PRIVATE standard_settings standard_warnings ZSTD::ZSTD
           Threads::Threads third_party_lib)
 
-target_include_directories(ccache_lib PRIVATE ${CMAKE_BINARY_DIR} .)
+target_include_directories(ccache_lib PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
 
 add_subdirectory(third_party)
index 95a1b68a8395b034c179abb272b7fd6b99fa8bcf..eb574dc8c45f0f45fc5c73afb0a6611f4b8eb7b2 100644 (file)
@@ -84,7 +84,7 @@ public:
   void set_cache_dir(const std::string& value);
   void set_cpp_extension(const std::string& value);
   void set_compiler(const std::string& value);
-  void set_compiler_type(CompilerType compiler_type);
+  void set_compiler_type(CompilerType value);
   void set_depend_mode(bool value);
   void set_debug(bool value);
   void set_direct_mode(bool value);
index 86004a93426367261660eb8bc1f0ad6847ffe1cb..37fe7e7147d544faba59935d5b71bc8d7a54b565 100644 (file)
 
 class NonCopyable
 {
-protected:
-  NonCopyable() = default;
-
-private:
+public:
   NonCopyable(const NonCopyable&) = delete;
   NonCopyable& operator=(const NonCopyable&) = delete;
+
+protected:
+  NonCopyable() = default;
 };
index c040c44e57fe7762fbf8b29c19674732bae2978e..1da89d3f379136d70cb84c77e921b6de5b600d72 100644 (file)
@@ -27,10 +27,10 @@ class Context;
 
 struct ProcessArgsResult
 {
-  ProcessArgsResult(Statistic error);
-  ProcessArgsResult(const Args& preprocessor_args,
-                    const Args& extra_args_to_hash,
-                    const Args& compiler_args);
+  ProcessArgsResult(Statistic error_);
+  ProcessArgsResult(const Args& preprocessor_args_,
+                    const Args& extra_args_to_hash_,
+                    const Args& compiler_args_);
 
   // nullopt on success, otherwise the statistics counter that should be
   // incremented.
index c361974a4496336a9663d91854f3110459c9e39a..ed0ff9e84801d6c4117b97d79295047f971ebb03 100644 (file)
@@ -40,7 +40,7 @@ endif()
 # Treat third party headers as system files (no warning for those headers).
 target_include_directories(
   third_party_lib
-  PRIVATE ${CMAKE_BINARY_DIR} . SYSTEM)
+  PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} SYSTEM)
 
 target_link_libraries(third_party_lib PRIVATE standard_settings)
 target_link_libraries(third_party_lib INTERFACE blake3)
index 65401041a4c0daf15df645a8592e26d25c558120..48cf058ecb9212659128fe571e34545c20280c9f 100644 (file)
@@ -36,6 +36,6 @@ target_link_libraries(
   unittest
   PRIVATE standard_settings standard_warnings ccache_lib third_party_lib)
 
-target_include_directories(unittest PRIVATE ${CMAKE_BINARY_DIR} . ../src)
+target_include_directories(unittest PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${ccache_SOURCE_DIR}/src)
 
 add_test(NAME unittest COMMAND unittest)