From: Christopher Dykes Date: Mon, 22 May 2017 22:33:12 +0000 (-0700) Subject: Enable -Wimplicit-fallthrough X-Git-Tag: v2017.05.29.00~17 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=523ca7d714075a3299dd42925e1f13376e2a4647;p=folly.git Enable -Wimplicit-fallthrough Summary: Because just having a linter enforce it isn't good enough to catch everything. Reviewed By: yfeldblum Differential Revision: D5101828 fbshipit-source-id: a1bc482b37139a1eddeb93bc298596af950aa87d --- diff --git a/folly/FBString.h b/folly/FBString.h index 5db1e61e..09ab0565 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -40,6 +40,7 @@ #else // !_LIBSTDCXX_FBSTRING +#include #include // libc++ doesn't provide this header, nor does msvc @@ -493,7 +494,9 @@ public: if (RefCounted::refs(ml_.data_) > 1) { return ml_.size_; } - default: {} + break; + default: + break; } return ml_.capacity(); } @@ -747,10 +750,13 @@ inline void fbstring_core::initSmall( switch ((byteSize + wordWidth - 1) / wordWidth) { // Number of words. case 3: ml_.capacity_ = reinterpret_cast(data)[2]; + FOLLY_FALLTHROUGH; case 2: ml_.size_ = reinterpret_cast(data)[1]; + FOLLY_FALLTHROUGH; case 1: ml_.data_ = *reinterpret_cast(const_cast(data)); + FOLLY_FALLTHROUGH; case 0: break; } diff --git a/folly/String-inl.h b/folly/String-inl.h index dbfefa01..8baf8f85 100644 --- a/folly/String-inl.h +++ b/folly/String-inl.h @@ -19,6 +19,8 @@ #include #include +#include + #ifndef FOLLY_STRING_H_ #error This file may only be included from String.h #endif @@ -228,6 +230,7 @@ void uriUnescape(StringPiece str, String& out, UriEscapeMode mode) { break; } // else fallthrough + FOLLY_FALLTHROUGH; default: ++p; break; diff --git a/folly/test/ConvBenchmark.cpp b/folly/test/ConvBenchmark.cpp index 337b9926..f73f3f06 100644 --- a/folly/test/ConvBenchmark.cpp +++ b/folly/test/ConvBenchmark.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -277,10 +278,12 @@ static int64_t handwrittenAtoi(const char* start, const char* end) { switch (*start) { case '-': positive = false; + FOLLY_FALLTHROUGH; case '+': ++start; + FOLLY_FALLTHROUGH; default: - ; + break; } while (start < end && *start >= '0' && *start <= '9') {