瀏覽代碼

Merge topic 'ci-clang-analyzer'

da14f4e19e gitlab-ci: add job to build with clang-analyzer
adc38da49f ci: add clang-analyzer to Fedora base image
b6c4d93dcd clang-analyzer: Suppress warnings in intentional use-after-move cases
c1b575f4d1 clang-analyzer: rename from scan-build in comments
dbfb50cd72 cmFileAPICodemodel: Assert input in DirectoryObject::DumpInstaller
410bf8ed4f cmStandardLevelResolver: Fix size assertion in constructor
82584b99e3 jsoncpp: Revert "Code style: add missed explicit 'this->'"

Acked-by: Kitware Robot <[email protected]>
Acked-by: Ben Boeckel <[email protected]>
Merge-request: !6189
Brad King 4 年之前
父節點
當前提交
ccaaca4e7d

+ 9 - 0
.gitlab-ci.yml

@@ -129,6 +129,15 @@ lint:fedora34-sphinx:
         CMAKE_CI_JOB_CONTINUOUS: "true"
         CMAKE_CI_JOB_HELP: "true"
 
+lint:fedora34-clang-analyzer:
+    extends:
+        - .fedora34_clang_analyzer
+        - .cmake_build_linux
+        - .linux_builder_tags_qt
+        - .run_automatically
+    variables:
+        CMAKE_CI_JOB_NIGHTLY: "true"
+
 # Linux builds
 
 build:centos6-x86_64:

+ 1 - 0
.gitlab/ci/configure_fedora34_clang_analyzer.cmake

@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora34_common.cmake")

+ 1 - 0
.gitlab/ci/docker/fedora34/install_deps.sh

@@ -25,6 +25,7 @@ dnf install --setopt=install_weak_deps=False -y \
 
 # Install lint tools.
 dnf install --setopt=install_weak_deps=False -y \
+    clang-analyzer \
     codespell
 
 # Tools needed for the test suite.

+ 2 - 0
.gitlab/ci/env_fedora34_clang_analyzer.sh

@@ -0,0 +1,2 @@
+export CC=/usr/libexec/ccc-analyzer
+export CXX=/usr/libexec/c++-analyzer

+ 10 - 1
.gitlab/os-linux.yml

@@ -69,7 +69,7 @@
 ### Fedora
 
 .fedora34:
-    image: "kitware/cmake:ci-fedora34-x86_64-2021-05-21"
+    image: "kitware/cmake:ci-fedora34-x86_64-2021-06-03"
 
     variables:
         GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes"
@@ -85,6 +85,15 @@
         CTEST_NO_WARNINGS_ALLOWED: 1
         CMake_SKIP_INSTALL: 1
 
+.fedora34_clang_analyzer:
+    extends: .fedora34
+
+    variables:
+        CMAKE_CONFIGURATION: fedora34_clang_analyzer
+        CMAKE_BUILD_TYPE: Debug
+        CTEST_NO_WARNINGS_ALLOWED: 1
+        CMake_SKIP_INSTALL: 1
+
 .fedora34_sphinx:
     extends: .fedora34
 

+ 12 - 19
CTestCustom.cmake.in

@@ -83,28 +83,21 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
   "compilation completed with warnings" # PGI
   "[0-9]+ Warning\\(s\\) detected" # SunPro
 
-  # scanbuild exceptions
-  "char_traits.h:.*: warning: Null pointer argument in call to string length function"
-  "stl_construct.h:.*: warning: Forming reference to null pointer"
-  ".*stl_uninitialized.h:75:19: warning: Forming reference to null pointer.*"
-  ".*stl_vector.h:.*: warning: Returning null reference.*"
-  "warning: Value stored to 'yymsg' is never read"
-  "warning: Value stored to 'yytoken' is never read"
-  "index_encoder.c.241.2. warning: Value stored to .out_start. is never read"
-  "index.c.*warning: Access to field.*results in a dereference of a null pointer.*loaded from variable.*"
-  "cmCommandArgumentLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
-  "cmDependsJavaLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
-  "cmExprLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
-  "cmListFileLexer.c:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
-  "cmFortranLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
-  "testProcess.*warning: Dereference of null pointer .loaded from variable .invalidAddress.."
+  # clang-analyzer exceptions
+  "cmListFileLexer.c:[0-9]+:[0-9]+: warning: Array subscript is undefined"
+  "jsoncpp/src/.*:[0-9]+:[0-9]+: warning: Value stored to .* is never read"
+  "liblzma/common/index_encoder.c:[0-9]+:[0-9]+: warning: Value stored to '[^']+' during its initialization is never read"
+  "liblzma/liblzma/common/index.c:[0-9]+:[0-9]+: warning: Access to field '[^']+' results in a dereference of a null pointer"
   "liblzma/simple/x86.c:[0-9]+:[0-9]+: warning: The result of the '<<' expression is undefined"
-  "liblzma/common/index_encoder.c:[0-9]+:[0-9]+: warning: Value stored to .* during its initialization is never read"
-  "libuv/src/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
-  "libuv/src/.*:[0-9]+:[0-9]+: warning: The left operand of '==' is a garbage value"
+  "librhash/librhash/.*:[0-9]+:[0-9]+: warning: The left operand of '[^']+' is a garbage value"
   "libuv/src/.*:[0-9]+:[0-9]+: warning: 1st function call argument is an uninitialized value"
+  "libuv/src/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
+  "libuv/src/.*:[0-9]+:[0-9]+: warning: The left operand of '[^']+' is a garbage value"
+  "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Access to field '[^']+' results in a dereference of a null pointer"
   "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
-  "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Value stored to .* is never read"
+  "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Value stored to '[^']+' is never read"
+  "zstd/lib/.*:[0-9]+:[0-9]+: warning: Assigned value is garbage or undefined"
+  "zstd/lib/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
   )
 
 if(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode")

+ 1 - 1
Source/LexerParser/cmCTestResourceGroupsLexer.cxx

@@ -659,7 +659,7 @@ Modify cmCTestResourceGroupsLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include "cmCTestResourceGroupsLexerHelper.h"
 

+ 1 - 1
Source/LexerParser/cmCTestResourceGroupsLexer.in.l

@@ -18,7 +18,7 @@ Modify cmCTestResourceGroupsLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include "cmCTestResourceGroupsLexerHelper.h"
 

+ 1 - 1
Source/LexerParser/cmCommandArgumentLexer.cxx

@@ -664,7 +664,7 @@ Modify cmCommandArgumentLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include "cmCommandArgumentParserHelper.h"
 

+ 1 - 1
Source/LexerParser/cmCommandArgumentLexer.in.l

@@ -18,7 +18,7 @@ Modify cmCommandArgumentLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include "cmCommandArgumentParserHelper.h"
 

+ 1 - 1
Source/LexerParser/cmDependsJavaLexer.cxx

@@ -860,7 +860,7 @@ Modify cmDependsJavaLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include <iostream>
 

+ 1 - 1
Source/LexerParser/cmDependsJavaLexer.in.l

@@ -18,7 +18,7 @@ Modify cmDependsJavaLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include <iostream>
 

+ 1 - 1
Source/LexerParser/cmExprLexer.cxx

@@ -664,7 +664,7 @@ Modify cmExprLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include "cmExprParserHelper.h"
 

+ 1 - 1
Source/LexerParser/cmExprLexer.in.l

@@ -18,7 +18,7 @@ Modify cmExprLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include "cmExprParserHelper.h"
 

+ 1 - 1
Source/LexerParser/cmFortranLexer.cxx

@@ -838,7 +838,7 @@ Modify cmFortranLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #undef YY_NO_UNPUT
 

+ 1 - 1
Source/LexerParser/cmFortranLexer.in.l

@@ -27,7 +27,7 @@ Modify cmFortranLexer.cxx:
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #undef YY_NO_UNPUT
 

+ 1 - 1
Source/LexerParser/cmGccDepfileLexer.cxx

@@ -645,7 +645,7 @@ static const flex_int16_t yy_chk[46] =
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include <cmGccDepfileLexerHelper.h>
 #include <string>

+ 1 - 1
Source/LexerParser/cmGccDepfileLexer.in.l

@@ -4,7 +4,7 @@
 
 /* IWYU pragma: no_forward_declare yyguts_t */
 
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
 
 #include <cmGccDepfileLexerHelper.h>
 #include <string>

+ 1 - 0
Source/cmFileAPICodemodel.cxx

@@ -874,6 +874,7 @@ Json::Value DirectoryObject::DumpInstallers()
 
 Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen)
 {
+  assert(gen);
   Json::Value installer = Json::objectValue;
 
   // Exclude subdirectory installers.  They are implementation details.

+ 1 - 1
Source/cmStandardLevelResolver.cxx

@@ -62,7 +62,7 @@ struct StanardLevelComputer
     , Levels(std::move(levels))
     , LevelsAsStrings(std::move(levelsStr))
   {
-    assert(levels.size() == levelsStr.size());
+    assert(this->Levels.size() == this->LevelsAsStrings.size());
   }
 
   std::string GetCompileOptionDef(cmMakefile* makefile,

+ 2 - 0
Tests/CMakeLib/testOptional.cxx

@@ -301,12 +301,14 @@ static bool testMoveConstruct(std::vector<Event>& expected)
   cm::optional<EventLogger> o3{};
   const cm::optional<EventLogger> o4{ std::move(o3) };
 
+#ifndef __clang_analyzer__ /* cplusplus.Move */
   expected = {
     { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
     { Event::MOVE_CONSTRUCT, &*o2, &*o1, 4 },
     { Event::DESTRUCT, &*o2, nullptr, 4 },
     { Event::DESTRUCT, &*o1, nullptr, 4 },
   };
+#endif
   return true;
 }
 

+ 4 - 0
Tests/CMakeLib/testString.cxx

@@ -326,12 +326,14 @@ static bool testConstructMove()
   std::cout << "testConstructMove()\n";
   cm::String s1 = std::string("abc");
   cm::String s2 = std::move(s1);
+#ifndef __clang_analyzer__ /* cplusplus.Move */
   ASSERT_TRUE(s1.data() == nullptr);
   ASSERT_TRUE(s1.size() == 0);
   ASSERT_TRUE(s2.size() == 3);
   ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
   ASSERT_TRUE(s1.is_stable());
   ASSERT_TRUE(s2.is_stable());
+#endif
   return true;
 }
 
@@ -356,12 +358,14 @@ static bool testAssignMove()
   cm::String s1 = std::string("abc");
   cm::String s2;
   s2 = std::move(s1);
+#ifndef __clang_analyzer__ /* cplusplus.Move */
   ASSERT_TRUE(s1.data() == nullptr);
   ASSERT_TRUE(s1.size() == 0);
   ASSERT_TRUE(s2.size() == 3);
   ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
   ASSERT_TRUE(s1.is_stable());
   ASSERT_TRUE(s2.is_stable());
+#endif
   return true;
 }
 

文件差異過大導致無法顯示
+ 353 - 411
Utilities/cmjsoncpp/src/lib_json/json_reader.cpp


文件差異過大導致無法顯示
+ 578 - 723
Utilities/cmjsoncpp/src/lib_json/json_value.cpp


文件差異過大導致無法顯示
+ 497 - 581
Utilities/cmjsoncpp/src/lib_json/json_writer.cpp


部分文件因文件數量過多而無法顯示