Skip to content

Commit efac089

Browse files
committed
- Add Clang 8 and GCC 9 to CI
- Switch clang-tidy to Clang 9 - Fix compiler and clang-tidy warnings produced by the previous points
1 parent 12ce925 commit efac089

41 files changed

Lines changed: 191 additions & 125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ references:
4545
deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main
4646
deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-7 main
4747
deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-7 main
48+
deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-8 main
49+
deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-8 main
4850
EOF
4951
sudo chmod o-w /etc/apt/sources.list.d/clang.list
5052
@@ -57,8 +59,8 @@ references:
5759
# They aren't set automatically unfortunately
5860
sudo ln -s /usr/bin/$CC /usr/bin/clang
5961
sudo ln -s /usr/bin/$CXX /usr/bin/clang++
60-
sudo ln -s /usr/bin/clang-tidy-7 /usr/bin/clang-tidy
61-
sudo ln -s /usr/bin/run-clang-tidy-7.py /usr/bin/run-clang-tidy.py
62+
sudo ln -s /usr/bin/clang-tidy-8 /usr/bin/clang-tidy
63+
sudo ln -s /usr/bin/run-clang-tidy-8.py /usr/bin/run-clang-tidy.py
6264
6365
# Need a c++14 compliant STL for clang
6466
sudo apt-get install -y g++-5
@@ -299,6 +301,30 @@ jobs:
299301
GTEST_ARGS: ""
300302
CMAKE_FLAGS: ""
301303
RUN_TESTS: true
304+
gcc_9_debug:
305+
<<: *job_definition
306+
environment:
307+
CC: gcc-9
308+
CXX: g++-9
309+
BUILD_TOOLSET: gcc
310+
APT_COMPILER_PACKAGE: "g++-9"
311+
CXXFLAGS: ""
312+
BUILD_TYPE: "Debug"
313+
GTEST_ARGS: ""
314+
CMAKE_FLAGS: ""
315+
RUN_TESTS: true
316+
gcc_9_release:
317+
<<: *job_definition
318+
environment:
319+
CC: gcc-9
320+
CXX: g++-9
321+
BUILD_TOOLSET: gcc
322+
APT_COMPILER_PACKAGE: "g++-9"
323+
CXXFLAGS: ""
324+
BUILD_TYPE: "Release"
325+
GTEST_ARGS: ""
326+
CMAKE_FLAGS: ""
327+
RUN_TESTS: true
302328
clang_4_debug:
303329
<<: *job_definition
304330
environment:
@@ -395,13 +421,37 @@ jobs:
395421
GTEST_ARGS: ""
396422
CMAKE_FLAGS: ""
397423
RUN_TESTS: true
424+
clang_8_debug:
425+
<<: *job_definition
426+
environment:
427+
CC: clang-8
428+
CXX: clang++-8
429+
BUILD_TOOLSET: clang
430+
APT_COMPILER_PACKAGE: clang-8
431+
CXXFLAGS: ""
432+
BUILD_TYPE: "Debug"
433+
GTEST_ARGS: ""
434+
CMAKE_FLAGS: ""
435+
RUN_TESTS: true
436+
clang_8_release:
437+
<<: *job_definition
438+
environment:
439+
CC: clang-8
440+
CXX: clang++-8
441+
BUILD_TOOLSET: clang
442+
APT_COMPILER_PACKAGE: clang-8
443+
CXXFLAGS: ""
444+
BUILD_TYPE: "Release"
445+
GTEST_ARGS: ""
446+
CMAKE_FLAGS: ""
447+
RUN_TESTS: true
398448
clang_werror:
399449
<<: *job_definition
400450
environment:
401-
CC: clang-7
402-
CXX: clang++-7
451+
CC: clang-8
452+
CXX: clang++-8
403453
BUILD_TOOLSET: clang
404-
APT_COMPILER_PACKAGE: clang-7
454+
APT_COMPILER_PACKAGE: clang-8
405455
CXXFLAGS: ""
406456
BUILD_TYPE: "Release"
407457
GTEST_ARGS: ""
@@ -410,10 +460,10 @@ jobs:
410460
gcc_werror:
411461
<<: *job_definition
412462
environment:
413-
CC: gcc-8
414-
CXX: g++-8
463+
CC: gcc-9
464+
CXX: g++-9
415465
BUILD_TOOLSET: gcc
416-
APT_COMPILER_PACKAGE: "g++-8"
466+
APT_COMPILER_PACKAGE: "g++-9"
417467
CXXFLAGS: ""
418468
BUILD_TYPE: "Release"
419469
GTEST_ARGS: ""
@@ -422,10 +472,10 @@ jobs:
422472
no_compatibility:
423473
<<: *job_definition
424474
environment:
425-
CC: clang-7
426-
CXX: clang++-7
475+
CC: clang-8
476+
CXX: clang++-8
427477
BUILD_TOOLSET: clang
428-
APT_COMPILER_PACKAGE: clang-7
478+
APT_COMPILER_PACKAGE: clang-8
429479
CXXFLAGS: "-DCRYFS_NO_COMPATIBILITY"
430480
BUILD_TYPE: "Debug"
431481
GTEST_ARGS: ""
@@ -434,10 +484,10 @@ jobs:
434484
address_sanitizer:
435485
<<: *job_definition
436486
environment:
437-
CC: clang-7
438-
CXX: clang++-7
487+
CC: clang-8
488+
CXX: clang++-8
439489
BUILD_TOOLSET: clang
440-
APT_COMPILER_PACKAGE: clang-7
490+
APT_COMPILER_PACKAGE: clang-8
441491
CXXFLAGS: "-O2 -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope"
442492
BUILD_TYPE: "Debug"
443493
ASAN_OPTIONS: "detect_leaks=1 check_initialization_order=1 detect_stack_use_after_return=1 detect_invalid_pointer_pairs=1 atexit=1"
@@ -448,10 +498,10 @@ jobs:
448498
ub_sanitizer:
449499
<<: *job_definition
450500
environment:
451-
CC: clang-7
452-
CXX: clang++-7
501+
CC: clang-8
502+
CXX: clang++-8
453503
BUILD_TOOLSET: clang
454-
APT_COMPILER_PACKAGE: clang-7
504+
APT_COMPILER_PACKAGE: clang-8
455505
CXXFLAGS: "-O2 -fno-sanitize-recover=undefined,nullability,implicit-conversion,unsigned-integer-overflow -fno-omit-frame-pointer -fno-common"
456506
BUILD_TYPE: "Debug"
457507
GTEST_ARGS: ""
@@ -460,10 +510,10 @@ jobs:
460510
thread_sanitizer:
461511
<<: *job_definition
462512
environment:
463-
CC: clang-7
464-
CXX: clang++-7
513+
CC: clang-8
514+
CXX: clang++-8
465515
BUILD_TOOLSET: clang
466-
APT_COMPILER_PACKAGE: clang-7
516+
APT_COMPILER_PACKAGE: clang-8
467517
OMP_NUM_THREADS: "1"
468518
CXXFLAGS: "-O2 -fsanitize=thread -fno-omit-frame-pointer"
469519
BUILD_TYPE: "Debug"
@@ -496,10 +546,10 @@ jobs:
496546
- store_artifacts:
497547
path: /tmp/clang-tidy-fixes
498548
environment:
499-
CC: clang-7
500-
CXX: clang++-7
549+
CC: clang-8
550+
CXX: clang++-8
501551
BUILD_TOOLSET: clang
502-
APT_COMPILER_PACKAGE: "clang-7 clang-tidy-7"
552+
APT_COMPILER_PACKAGE: "clang-8 clang-tidy-8"
503553

504554
workflows:
505555
version: 2
@@ -522,6 +572,10 @@ workflows:
522572
<<: *enable_for_tags
523573
- gcc_8_release:
524574
<<: *enable_for_tags
575+
- gcc_9_debug:
576+
<<: *enable_for_tags
577+
- gcc_9_release:
578+
<<: *enable_for_tags
525579
- clang_4_debug:
526580
<<: *enable_for_tags
527581
- clang_4_release:
@@ -538,6 +592,10 @@ workflows:
538592
<<: *enable_for_tags
539593
- clang_7_release:
540594
<<: *enable_for_tags
595+
- clang_8_debug:
596+
<<: *enable_for_tags
597+
- clang_8_release:
598+
<<: *enable_for_tags
541599
- clang_werror:
542600
<<: *enable_for_tags
543601
- gcc_werror:

.clang-tidy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ Checks: |
2525
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
2626
-cppcoreguidelines-pro-type-vararg,
2727
-cppcoreguidelines-avoid-goto,
28+
-cppcoreguidelines-avoid-magic-numbers,
29+
-cppcoreguidelines-macro-usage,
30+
-cppcoreguidelines-non-private-member-variables-in-classes,
2831
-clang-analyzer-optin.cplusplus.VirtualCall,
32+
-clang-analyzer-cplusplus.NewDeleteLeaks,
2933
-misc-macro-parentheses,
34+
-misc-non-private-member-variables-in-classes,
3035
-misc-unused-raii
3136
WarningsAsErrors: '*'
3237
HeaderFilterRegex: '/src/|/test/'

src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ namespace blobstore {
215215
if (endIndex > beginIndex) {
216216
onBacktrackFromSubtree(newNode.get());
217217
}
218-
return std::move(newNode);
218+
return newNode;
219219
}
220220

221221
uint32_t LeafTraverser::_maxLeavesForTreeDepth(uint8_t depth) const {

src/blockstore/implementations/caching/cache/QueueMap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class QueueMap final {
4848
_removeFromQueue(found->second);
4949
auto value = found->second.release();
5050
_entries.erase(found);
51-
return std::move(value);
51+
return value;
5252
}
5353

5454
boost::optional<Value> pop() {
@@ -83,7 +83,7 @@ class QueueMap final {
8383
}
8484
void init(const Key *key_, Value value_) {
8585
key = key_;
86-
new(__value) Value(std::move(value_));
86+
new(__value.data()) Value(std::move(value_));
8787
}
8888
Value release() {
8989
Value value = std::move(*_value());
@@ -98,9 +98,9 @@ class QueueMap final {
9898
const Key *key;
9999
private:
100100
Value *_value() {
101-
return reinterpret_cast<Value*>(__value);
101+
return reinterpret_cast<Value*>(__value.data());
102102
}
103-
alignas(Value) char __value[sizeof(Value)];
103+
alignas(Value) std::array<char, sizeof(Value)> __value;
104104
DISALLOW_COPY_AND_ASSIGN(Entry);
105105
};
106106

src/cpp-utils/crypto/RandomPadding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ namespace cpputils {
2929
};
3030
Data result(size);
3131
std::memcpy(result.data(), data.dataOffset(sizeof(size)), size);
32-
return std::move(result);
32+
return result;
3333
}
3434
}

src/cpp-utils/crypto/symmetric/CFB_Cipher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ boost::optional<Data> CFB_Cipher<BlockCipher, KeySize>::decrypt(const CryptoPP::
7171
// TODO Shouldn't we pass in ciphertextSize instead of plaintext.size() here as last argument (and also in the if above)?
7272
decryption.ProcessData(static_cast<CryptoPP::byte*>(plaintext.data()), ciphertextData, plaintext.size());
7373
}
74-
return std::move(plaintext);
74+
return plaintext;
7575
}
7676

7777
}

src/cpp-utils/crypto/symmetric/GCM_Cipher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ boost::optional<Data> GCM_Cipher<BlockCipher, KeySize>::decrypt(const CryptoPP::
8181
CryptoPP::AuthenticatedDecryptionFilter::DEFAULT_FLAGS, TAG_SIZE
8282
)
8383
);
84-
return std::move(plaintext);
84+
return plaintext;
8585
} catch (const CryptoPP::HashVerificationFilter::HashVerificationFailed &e) {
8686
return boost::none;
8787
}

src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace cpputils {
9292
Data result(plaintextSize(ciphertextSize));
9393
_xor(static_cast<CryptoPP::byte *>(result.data()), ciphertext + sizeof(uint64_t), plaintextSize(ciphertextSize), encKey.value ^ iv);
9494

95-
return std::move(result);
95+
return result;
9696
}
9797

9898
static constexpr const char *NAME = "FakeAuthenticatedCipher";
@@ -101,7 +101,7 @@ namespace cpputils {
101101
static uint64_t _checksum(const CryptoPP::byte *data, FakeKey encKey, std::size_t size) {
102102
uint64_t checksum = 34343435 * encKey.value; // some init value
103103

104-
for (unsigned int i = 0; i < size; ++i) {
104+
for (size_t i = 0; i < size; ++i) {
105105
checksum ^= (static_cast<uint64_t>(data[i]) << (56 - 8 * (i%8)));
106106
}
107107

src/cpp-utils/data/FixedSizeData.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FixedSizeData final {
3737
FixedSizeData(): _data() {}
3838
template<size_t _SIZE> friend class FixedSizeData;
3939

40-
unsigned char _data[BINARY_LENGTH];
40+
std::array<unsigned char, BINARY_LENGTH> _data;
4141
};
4242

4343
template<size_t SIZE> bool operator==(const FixedSizeData<SIZE> &lhs, const FixedSizeData<SIZE> &rhs);
@@ -51,7 +51,7 @@ template<size_t SIZE> constexpr size_t FixedSizeData<SIZE>::STRING_LENGTH;
5151
template<size_t SIZE>
5252
FixedSizeData<SIZE> FixedSizeData<SIZE>::Null() {
5353
FixedSizeData<SIZE> result;
54-
std::memset(result._data, 0, BINARY_LENGTH);
54+
std::memset(result._data.data(), 0, BINARY_LENGTH);
5555
return result;
5656
}
5757

@@ -62,7 +62,7 @@ FixedSizeData<SIZE> FixedSizeData<SIZE>::FromString(const std::string &data) {
6262
{
6363
CryptoPP::StringSource _1(data, true,
6464
new CryptoPP::HexDecoder(
65-
new CryptoPP::ArraySink(result._data, BINARY_LENGTH)
65+
new CryptoPP::ArraySink(result._data.data(), BINARY_LENGTH)
6666
)
6767
);
6868
}
@@ -72,7 +72,7 @@ FixedSizeData<SIZE> FixedSizeData<SIZE>::FromString(const std::string &data) {
7272
template<size_t SIZE>
7373
std::string FixedSizeData<SIZE>::ToString() const {
7474
std::string result;
75-
CryptoPP::ArraySource(_data, BINARY_LENGTH, true,
75+
CryptoPP::ArraySource(_data.data(), BINARY_LENGTH, true,
7676
new CryptoPP::HexEncoder(
7777
new CryptoPP::StringSink(result)
7878
)
@@ -83,7 +83,7 @@ std::string FixedSizeData<SIZE>::ToString() const {
8383

8484
template<size_t SIZE>
8585
const unsigned char *FixedSizeData<SIZE>::data() const {
86-
return _data;
86+
return _data.data();
8787
}
8888

8989
template<size_t SIZE>
@@ -93,29 +93,29 @@ unsigned char *FixedSizeData<SIZE>::data() {
9393

9494
template<size_t SIZE>
9595
void FixedSizeData<SIZE>::ToBinary(void *target) const {
96-
std::memcpy(target, _data, BINARY_LENGTH);
96+
std::memcpy(target, _data.data(), BINARY_LENGTH);
9797
}
9898

9999
template<size_t SIZE>
100100
FixedSizeData<SIZE> FixedSizeData<SIZE>::FromBinary(const void *source) {
101101
FixedSizeData<SIZE> result;
102-
std::memcpy(result._data, source, BINARY_LENGTH);
102+
std::memcpy(result._data.data(), source, BINARY_LENGTH);
103103
return result;
104104
}
105105

106106
template<size_t SIZE> template<size_t size>
107107
FixedSizeData<size> FixedSizeData<SIZE>::take() const {
108108
static_assert(size <= SIZE, "Out of bounds");
109109
FixedSizeData<size> result;
110-
std::memcpy(result._data, _data, size);
110+
std::memcpy(result._data.data(), _data.data(), size);
111111
return result;
112112
}
113113

114114
template<size_t SIZE> template<size_t size>
115115
FixedSizeData<SIZE-size> FixedSizeData<SIZE>::drop() const {
116116
static_assert(size <= SIZE, "Out of bounds");
117117
FixedSizeData<SIZE-size> result;
118-
std::memcpy(result._data, _data+size, SIZE-size);
118+
std::memcpy(result._data.data(), _data.data()+size, SIZE-size);
119119
return result;
120120
}
121121

src/cpp-utils/io/IOStreamConsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ unsigned int IOStreamConsole::ask(const string &question, const vector<string> &
6767
throw std::invalid_argument("options should have at least one entry");
6868
}
6969
_output << question << "\n";
70-
for (unsigned int i = 0; i < options.size(); ++i) {
70+
for (size_t i = 0; i < options.size(); ++i) {
7171
_output << " [" << (i+1) << "] " << options[i] << "\n";
7272
}
7373
int choice = _askForChoice("Your choice [1-" + std::to_string(options.size()) + "]: ", _parseUIntWithMinMax(1, options.size()));

0 commit comments

Comments
 (0)