Enable -Wimplicit-fallthrough
authorChristopher Dykes <cdykes@fb.com>
Mon, 22 May 2017 22:33:12 +0000 (15:33 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 22 May 2017 22:36:21 +0000 (15:36 -0700)
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
folly/String-inl.h
folly/test/ConvBenchmark.cpp

index 5db1e61e19329bc2fc86c82d90d2bb0ff18036e4..09ab0565220e3a22ddf163faab07c725141f9603 100644 (file)
@@ -40,6 +40,7 @@
 
 #else // !_LIBSTDCXX_FBSTRING
 
+#include <folly/CppAttributes.h>
 #include <folly/Portability.h>
 
 // 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<Char>::initSmall(
     switch ((byteSize + wordWidth - 1) / wordWidth) { // Number of words.
       case 3:
         ml_.capacity_ = reinterpret_cast<const size_t*>(data)[2];
+        FOLLY_FALLTHROUGH;
       case 2:
         ml_.size_ = reinterpret_cast<const size_t*>(data)[1];
+        FOLLY_FALLTHROUGH;
       case 1:
         ml_.data_ = *reinterpret_cast<Char**>(const_cast<Char*>(data));
+        FOLLY_FALLTHROUGH;
       case 0:
         break;
     }
index dbfefa010fb6f97ac530ce280b74f086996b7ec0..8baf8f85690c6fe5970f1903c9735a81b153e0ba 100644 (file)
@@ -19,6 +19,8 @@
 #include <stdexcept>
 #include <iterator>
 
+#include <folly/CppAttributes.h>
+
 #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;
index 337b99262f83c4421566859d68e44915332bf650..f73f3f06f6c3ecb4960ca4ef06b668f2b5613b4e 100644 (file)
@@ -19,6 +19,7 @@
 #include <boost/lexical_cast.hpp>
 
 #include <folly/Benchmark.h>
+#include <folly/CppAttributes.h>
 #include <folly/Foreach.h>
 
 #include <array>
@@ -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') {