Update CI to clang-tidy 9 and fix warnings

This commit is contained in:
Sebastian Messmer 2020-07-22 10:32:43 -07:00
parent cd9aa14202
commit 5290947a98
11 changed files with 29 additions and 14 deletions

View File

@ -89,8 +89,7 @@ references:
# They aren't set automatically unfortunately # They aren't set automatically unfortunately
sudo ln -s /usr/bin/$CC /usr/bin/clang sudo ln -s /usr/bin/$CC /usr/bin/clang
sudo ln -s /usr/bin/$CXX /usr/bin/clang++ sudo ln -s /usr/bin/$CXX /usr/bin/clang++
sudo ln -s /usr/bin/clang-tidy-8 /usr/bin/clang-tidy sudo ln -s /usr/bin/clang-tidy-9 /usr/bin/clang-tidy
sudo ln -s /usr/bin/run-clang-tidy-8.py /usr/bin/run-clang-tidy.py
fi fi
# Setup build cache # Setup build cache
@ -652,10 +651,10 @@ jobs:
- store_artifacts: - store_artifacts:
path: /tmp/clang-tidy-fixes path: /tmp/clang-tidy-fixes
environment: environment:
CC: clang-8 CC: clang-9
CXX: clang++-8 CXX: clang++-9
BUILD_TOOLSET: clang BUILD_TOOLSET: clang
APT_COMPILER_PACKAGE: "clang-8 clang-tidy-8" APT_COMPILER_PACKAGE: "clang-9 clang-tidy-9"
workflows: workflows:
version: 2 version: 2

View File

@ -2,6 +2,7 @@
# TODO Enable (some of) the explicitly disabled checks. Possibly needs helper types from gsl library or similar to enable full cppcoreguidelines. # TODO Enable (some of) the explicitly disabled checks. Possibly needs helper types from gsl library or similar to enable full cppcoreguidelines.
# TODO Enable more checks (google-*, hicpp-*, llvm-*, modernize-*, mpi-*, performance-*, readability-*) # TODO Enable more checks (google-*, hicpp-*, llvm-*, modernize-*, mpi-*, performance-*, readability-*)
# TODO Maybe just enable * and disable a list instead? # TODO Maybe just enable * and disable a list instead?
# TODO Check if there's new checks in clang-tidy-9 and potentially enable them
Checks: | Checks: |
clang-diagnostic-*, clang-diagnostic-*,
clang-analyzer-*, clang-analyzer-*,

View File

@ -19,4 +19,4 @@ cat compile_commands.json|jq "map(select(.file | test(\"^$(realpath ${0%/*})/(sr
rm compile_commands.json rm compile_commands.json
mv compile_commands2.json compile_commands.json mv compile_commands2.json compile_commands.json
run-clang-tidy.py -j${NUMCORES} -quiet -header-filter "$(realpath ${0%/*})/(src|test)/.*" $@ run-clang-tidy-9.py -j${NUMCORES} -quiet -header-filter "$(realpath ${0%/*})/(src|test)/.*" $@

View File

@ -26,6 +26,10 @@ namespace cpputils {
SCryptParameters(SCryptParameters &&rhs) = default; SCryptParameters(SCryptParameters &&rhs) = default;
SCryptParameters &operator=(const SCryptParameters &rhs) { SCryptParameters &operator=(const SCryptParameters &rhs) {
if (this == &rhs) {
return *this;
}
_salt = rhs._salt.copy(); _salt = rhs._salt.copy();
_N = rhs._N; _N = rhs._N;
_r = rhs._r; _r = rhs._r;

View File

@ -47,7 +47,12 @@ namespace cpputils {
} }
//TODO Try allowing copy-assignment when Left/Right types are std::is_convertible //TODO Try allowing copy-assignment when Left/Right types are std::is_convertible
// NOLINTNEXTLINE(cert-oop54-cpp)
either<Left, Right> &operator=(const either<Left, Right> &rhs) noexcept(noexcept(std::declval<either<Left, Right>>()._construct_left(rhs._left)) && noexcept(std::declval<either<Left, Right>>()._construct_right(rhs._right))) { either<Left, Right> &operator=(const either<Left, Right> &rhs) noexcept(noexcept(std::declval<either<Left, Right>>()._construct_left(rhs._left)) && noexcept(std::declval<either<Left, Right>>()._construct_right(rhs._right))) {
if (this == &rhs) {
return *this;
}
_destruct(); _destruct();
_side = rhs._side; _side = rhs._side;
if (_side == Side::left) { if (_side == Side::left) {
@ -59,6 +64,10 @@ namespace cpputils {
} }
either<Left, Right> &operator=(either<Left, Right> &&rhs) noexcept(noexcept(std::declval<either<Left, Right>>()._construct_left(std::move(rhs._left))) && noexcept(std::declval<either<Left, Right>>()._construct_right(std::move(rhs._right)))) { either<Left, Right> &operator=(either<Left, Right> &&rhs) noexcept(noexcept(std::declval<either<Left, Right>>()._construct_left(std::move(rhs._left))) && noexcept(std::declval<either<Left, Right>>()._construct_right(std::move(rhs._right)))) {
if (this == &rhs) {
return *this;
}
_destruct(); _destruct();
_side = rhs._side; _side = rhs._side;
if (_side == Side::left) { if (_side == Side::left) {

View File

@ -70,8 +70,8 @@ public:
return *this; return *this;
} }
constexpr IdValueType& operator=(const IdValueType& rhs) noexcept(noexcept(*std::declval<UnderlyingType*>() = rhs.value_)) { constexpr IdValueType& operator=(const IdValueType& rhs) noexcept(noexcept(*std::declval<UnderlyingType*>() = rhs.value_)) {
value_ = rhs.value_; // NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature,misc-unconventional-assign-operator)
return *this; return operator=(IdValueType(rhs));
} }
protected: protected:

View File

@ -37,6 +37,7 @@ namespace cryfs_cli {
if (warnings == none) { if (warnings == none) {
return none; return none;
} }
// NOLINTNEXTLINE(bugprone-branch-clone)
BOOST_FOREACH(const ptree::value_type &v, *warnings) { BOOST_FOREACH(const ptree::value_type &v, *warnings) {
if(v.first == version) { if(v.first == version) {
return v.second.get_value<std::string>(); return v.second.get_value<std::string>();

View File

@ -98,11 +98,11 @@ public:
return _base->AppendChildrenTo(result); return _base->AppendChildrenTo(result);
} }
const blockstore::BlockId &blockId() const { const blockstore::BlockId &blockId() const override {
return _base->blockId(); return _base->blockId();
} }
fspp::num_bytes_t lstat_size() const { fspp::num_bytes_t lstat_size() const override {
return _base->lstat_size(); return _base->lstat_size();
} }

View File

@ -36,11 +36,11 @@ public:
return _base->flush(); return _base->flush();
} }
const blockstore::BlockId &blockId() const { const blockstore::BlockId &blockId() const override {
return _base->blockId(); return _base->blockId();
} }
fspp::num_bytes_t lstat_size() const { fspp::num_bytes_t lstat_size() const override {
return _base->lstat_size(); return _base->lstat_size();
} }

View File

@ -20,11 +20,11 @@ public:
return _base->target(); return _base->target();
} }
const blockstore::BlockId &blockId() const { const blockstore::BlockId &blockId() const override {
return _base->blockId(); return _base->blockId();
} }
fspp::num_bytes_t lstat_size() const { fspp::num_bytes_t lstat_size() const override {
return _base->lstat_size(); return _base->lstat_size();
} }

View File

@ -9,6 +9,7 @@ public:
CopyableMovableValueType(const CopyableMovableValueType &rhs): CopyableMovableValueType(rhs._value) { CopyableMovableValueType(const CopyableMovableValueType &rhs): CopyableMovableValueType(rhs._value) {
++numCopyConstructorCalled; ++numCopyConstructorCalled;
} }
// NOLINTNEXTLINE(cert-oop54-cpp)
CopyableMovableValueType &operator=(const CopyableMovableValueType &rhs) { CopyableMovableValueType &operator=(const CopyableMovableValueType &rhs) {
_value = rhs._value; _value = rhs._value;
++numCopyConstructorCalled; ++numCopyConstructorCalled;