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 <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !6189
This commit is contained in:
Brad King
2021-06-04 10:57:45 +00:00
committed by Kitware Robot
25 changed files with 2471 additions and 2921 deletions

View File

@@ -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:

View File

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

View File

@@ -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.

View File

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

View File

@@ -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

View File

@@ -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")

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -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.

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff