clang-tidy

This commit is contained in:
Markus F.X.J. Oberhumer
2023-07-31 14:49:48 +02:00
parent 41e9f7985f
commit 70287d3c49
20 changed files with 176 additions and 51 deletions
+4 -8
View File
@@ -306,14 +306,10 @@ TEST_CASE("MemBuffer global overloads") {
mb.clear();
mb4.clear();
CHECK(memcmp(mb, "\x00", 1) == 0);
// NOLINTNEXTLINE(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb, "\x00\x00", 2));
// NOLINTNEXTLINE(bugprone-unused-return-value)
CHECK_THROWS(memcmp("\x00\x00", mb, 2));
// NOLINTNEXTLINE(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb, mb4, 2));
// NOLINTNEXTLINE(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb4, mb, 2));
CHECK_THROWS(memcmp(mb, "\x00\x00", 2)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp("\x00\x00", mb, 2)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb, mb4, 2)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb4, mb, 2)); // NOLINT(bugprone-unused-return-value)
CHECK_NOTHROW(memset(mb, 255, 1));
CHECK_THROWS(memset(mb, 254, 2));
CHECK(mb[0] == 255);
+2 -2
View File
@@ -141,7 +141,7 @@ void upx_stable_sort(void *array, size_t n, size_t element_size,
// this works
#define OwningPointer(T) T *
#elif 1
#elif !(DEBUG)
// this also works
template <class T>
@@ -150,7 +150,7 @@ using OwningPointer = T *;
#else
// also works: a simple class with just a number of no-ops
// also works: a trivial class with just a number of no-ops
template <class T>
struct OwningPointer final {
static_assert(std::is_class_v<T>); // UPX convention
+2 -2
View File
@@ -113,8 +113,8 @@ forceinline ~CSelf() noexcept {}
#endif
noinline void invalidate() {
assertInvariants();
// poison the pointer
ptr = (pointer) (upx_uintptr_t) 16; // point to non-null invalid address
// poison the pointer: point to non-null invalid address
ptr = (pointer) (void *) (upx_uintptr_t) 16; // NOLINT(performance-no-int-to-ptr)
// ptr = (pointer) (void *) &ptr; // point to self
base = ptr;
size_in_bytes = 0;
+2 -2
View File
@@ -77,8 +77,8 @@ public:
#endif
noinline void invalidate() {
assertInvariants();
// poison the pointer
ptr = (pointer) (upx_uintptr_t) 16; // point to non-null invalid address
// poison the pointer: point to non-null invalid address
ptr = (pointer) (void *) (upx_uintptr_t) 16; // NOLINT(performance-no-int-to-ptr)
// ptr = (pointer) (void *) &ptr; // point to self
assertInvariants();
}