From 523ca7d714075a3299dd42925e1f13376e2a4647 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Mon, 22 May 2017 15:33:12 -0700 Subject: [PATCH] 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 --- folly/FBString.h | 8 +++++++- folly/String-inl.h | 3 +++ folly/test/ConvBenchmark.cpp | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) 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') { -- 2.34.1