Sfoglia il codice sorgente

Merge topic 'clang-tidy-config'

d0c3e47d clang-tidy: add option CMake_RUN_CLANG_TIDY
894ff96c auto_ptr: silence clang-tidy warnings

Acked-by: Kitware Robot <[email protected]>
Merge-request: !790
Brad King 8 anni fa
parent
commit
053c0f1e44
5 ha cambiato i file con 58 aggiunte e 5 eliminazioni
  1. 30 0
      .clang-tidy
  2. 14 0
      CMakeLists.txt
  3. 5 5
      Source/cm_auto_ptr.hxx
  4. 6 0
      Utilities/.clang-tidy
  5. 3 0
      Utilities/CMakeLists.txt

+ 30 - 0
.clang-tidy

@@ -0,0 +1,30 @@
+---
+Checks: "-*,\
+misc-*,\
+-misc-incorrect-roundings,\
+-misc-macro-parentheses,\
+-misc-misplaced-widening-cast,\
+-misc-static-assert,\
+modernize-make-shared,\
+modernize-make-unique,\
+modernize-redundant-void-arg,\
+modernize-use-bool-literals,\
+modernize-use-nullptr,\
+modernize-use-override,\
+performance-*,\
+-performance-inefficient-string-concatenation,\
+readability-*,\
+-readability-function-size,\
+-readability-identifier-naming,\
+-readability-implicit-bool-cast,\
+-readability-inconsistent-declaration-parameter-name,\
+-readability-named-parameter,\
+-readability-redundant-declaration,\
+-readability-redundant-member-init,\
+-readability-simplify-boolean-expr,\
+"
+HeaderFilterRegex: 'Source/cm[^/]*\.(h|hxx|cxx)$'
+CheckOptions:
+  - key:    modernize-use-nullptr.NullMacros
+    value:  'CM_NULLPTR'
+...

+ 14 - 0
CMakeLists.txt

@@ -226,6 +226,20 @@ option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
 mark_as_advanced(CMAKE_USE_FOLDERS)
 
 
+option(CMake_RUN_CLANG_TIDY "Run clang-tidy with the compiler." OFF)
+if(CMake_RUN_CLANG_TIDY)
+  if(CMake_SOURCE_DIR STREQUAL CMake_BINARY_DIR)
+    message(FATAL_ERROR "CMake_RUN_CLANG_TIDY requires an out-of-source build!")
+  endif()
+  find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
+  if(NOT CLANG_TIDY_COMMAND)
+    message(FATAL_ERROR "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
+  endif()
+  set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
+endif()
+configure_file(.clang-tidy .clang-tidy COPYONLY)
+
+
 option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF)
 if(CMake_RUN_IWYU)
   find_program(IWYU_COMMAND NAMES include-what-you-use iwyu)

+ 5 - 5
Source/cm_auto_ptr.hxx

@@ -100,10 +100,10 @@ public:
   /** Assign from an auto_ptr holding a compatible object.  This
       transfers ownership to the left-hand-side of the assignment.  */
   template <class Y>
-  auto_ptr& operator=(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw()
+  auto_ptr& operator=(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw() // NOLINT
   {
     this->reset(cm_AUTO_PTR_CAST(a).release());
-    return *this;
+    return *this; // NOLINT
   }
 
   /**
@@ -127,10 +127,10 @@ public:
 
   /** Assign from another auto_ptr holding an object of the same type.
       This transfers ownership to the newly constructed auto_ptr.  */
-  auto_ptr& operator=(auto_ptr cm_AUTO_PTR_CONST& a) throw()
+  auto_ptr& operator=(auto_ptr cm_AUTO_PTR_CONST& a) throw() // NOLINT
   {
     this->reset(cm_AUTO_PTR_CAST(a).release());
-    return *this;
+    return *this; // NOLINT
   }
 
   /** Destruct and delete the object held.  */
@@ -192,7 +192,7 @@ public:
   auto_ptr& operator=(detail::auto_ptr_ref<X> r) throw()
   {
     this->reset(r.p_);
-    return *this;
+    return *this; // NOLINT
   }
 
   /** Convert to an auto_ptr_ref.  This is used when a function

+ 6 - 0
Utilities/.clang-tidy

@@ -0,0 +1,6 @@
+---
+# We want to disable all checks for 3rd party code.  However, clang-tidy will
+# assume we did not configure it correctly.  Just add one check that will never
+# be found.
+Checks: '-*,llvm-twine-local'
+...

+ 3 - 0
Utilities/CMakeLists.txt

@@ -29,3 +29,6 @@ endif()
 if(WIX_CUSTOM_ACTION_ENABLED)
   add_subdirectory(Release/WiX)
 endif()
+
+# Make sure generated files use the same clang-tidy checks (none).
+configure_file(.clang-tidy .clang-tidy COPYONLY)