diff --git a/CMakeLists.txt b/CMakeLists.txt index 7013108..a77b353 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,8 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) "MinSizeRel" "RelWithDebInfo") endif() -add_compile_options(-fdata-sections -ffunction-sections -fstrict-enums) +add_compile_options(-fdata-sections -ffunction-sections -Wswitch-enum + -Werror=switch-enum) # This is encouraged according to # https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 9d112fb..e30f240 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -382,8 +382,9 @@ uint8_t *Node::partialKey() { return ((Node48 *)this)->partialKey(); case Type_Node256: return ((Node256 *)this)->partialKey(); + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } struct NodeAllocators { @@ -478,8 +479,9 @@ Node *&getChildExists(Node *self, uint8_t index) { assert(self256->bitSet.test(index)); return self256->children[index].child; } + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } // Precondition - an entry for index must exist in the node @@ -510,8 +512,9 @@ Node *getChild(Node *self, uint8_t index) { auto *self256 = static_cast(self); return self256->children[index].child; } + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } template int getChildGeqSimd(NodeT *self, int child) { @@ -590,8 +593,9 @@ int getChildGeq(Node *self, int child) { auto *self48 = static_cast(self); return self48->bitSet.firstSetGeq(child); } + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } void setChildrenParents(Node3 *n) { @@ -652,6 +656,8 @@ Node *&getOrCreateChild(Node *&self, uint8_t index, return result; } } break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } switch (self->type) { @@ -783,8 +789,9 @@ Node *&getOrCreateChild(Node *&self, uint8_t index, self256->bitSet.set(index); return self256->children[index].child; } + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } Node *nextPhysical(Node *node) { @@ -917,6 +924,8 @@ void freeAndMakeCapacityAtLeast(Node *&self, int capacity, } self = newSelf; } break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } } @@ -1063,6 +1072,8 @@ void maybeDownsize(Node *self, NodeAllocators *allocators, allocators->node256.release(self256); } break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } } @@ -1111,6 +1122,8 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, case Type_Node256: allocators->node256.release((Node256 *)self); break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } switch (parent->type) { @@ -1158,6 +1171,8 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl, parent256->bitSet.reset(parentsIndex); parent256->children[parentsIndex].child = nullptr; } break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } --parent->numChildren; @@ -1508,6 +1523,8 @@ int64_t maxBetweenExclusive(Node *n, int begin, int end) { begin, end); break; } + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } #if DEBUG_VERBOSE && !defined(NDEBUG) fprintf(stderr, "At `%s', max version in (%02x, %02x) is %" PRId64 "\n", @@ -1711,7 +1728,7 @@ struct CheckRangeLeftSide { } break; } - case DownLeftSpine: + case DownLeftSpine: { if (n->entryPresent) { ok = n->entry.rangeVersion <= readVersion; return true; @@ -1719,7 +1736,9 @@ struct CheckRangeLeftSide { int c = getChildGeq(n, 0); assert(c >= 0); n = getChildExists(n, c); - break; + } break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } return false; } @@ -1837,7 +1856,7 @@ struct CheckRangeRightSide { } } } break; - case DownLeftSpine: + case DownLeftSpine: { if (n->entryPresent) { ok = n->entry.rangeVersion <= readVersion; return true; @@ -1845,7 +1864,9 @@ struct CheckRangeRightSide { int c = getChildGeq(n, 0); assert(c >= 0); n = getChildExists(n, c); - break; + } break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } return false; } @@ -2380,8 +2401,9 @@ int64_t &maxVersion(Node *n, ConflictSet::Impl *impl) { assert(n256->bitSet.test(index)); return n256->children[index].childMaxVersion; } + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } Node *&getInTree(Node *n, ConflictSet::Impl *impl) { @@ -2651,6 +2673,8 @@ Iterator firstGeq(Node *n, std::string_view key) { case Type_Node256: minNumChildren = kMinChildrenNode256; break; + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } if (node->numChildren + int(node->entryPresent) < minNumChildren) { fprintf(stderr, @@ -2708,8 +2732,9 @@ int64_t getNodeSize(struct Node *n) { return sizeof(Node48); case Type_Node256: return sizeof(Node256); + default: + __builtin_unreachable(); // GCOVR_EXCL_LINE } - __builtin_unreachable(); // GCOVR_EXCL_LINE } int64_t getSearchPathLength(Node *n) {