aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Nico Weber <thakis@chromium.org>2018-02-07 08:55:36 -0500
committerGravatar Nico Weber <thakis@chromium.org>2018-02-07 08:55:36 -0500
commitc66dd6c2760f0edeaa2529f25668f025a9f5dd0c (patch)
treeda4bac9b22ff1eab2f1a4c7b330e7f6feef69234
parent82e02316072f38f994395b1620cda2aff927dd0f (diff)
Remove use of GOOGLE_FALLTHROUGH_INTENDED from protobuf.
Chrome is running into two issues with the use of this macro in open-source protobuf (https://crbug.com/809157): 1. GOOGLE_FALLTHROUGH_INTENDED is defined to nothing on __APPLE__ platforms, which blocks us from enabling -Wimplicit-fallthrough on Mac and iOS. (We use a hermetic self-built modern clang, so whatever Xcode bug that exclusion might be for doesn't apply to us.) 2. It's in a public header file, and it's included in a public header file. When clang suggests adding [[clang::fallthrough]], it checks if it knows of a macro expanding to that and if so, suggests inserting that. Since lots of chrome code includes protobuf headers, it often suggests inserting GOOGLE_FALLTHROUGH_INTENDED (from protobuf) instead of the correct FALLTHROUGH (from chrome's base). Since the fallthrough doens't do anyting useful, just remove it. Long ago, this might have had perf impact, but d64a2d9941c36a7bc added a parsing fast path that calls this switch as slow fallback, so it should be off the hot path nowadays. No intended behavior change. This is the public version of internal change 184824132.
-rw-r--r--src/google/protobuf/map_entry_lite.h3
-rw-r--r--src/google/protobuf/stubs/port.h14
2 files changed, 1 insertions, 16 deletions
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h
index 1646ce43..dc6ec917 100644
--- a/src/google/protobuf/map_entry_lite.h
+++ b/src/google/protobuf/map_entry_lite.h
@@ -201,8 +201,7 @@ class MapEntryImpl : public Base {
return false;
}
set_has_key();
- if (!input->ExpectTag(kValueTag)) break;
- GOOGLE_FALLTHROUGH_INTENDED;
+ break;
case kValueTag:
if (!ValueTypeHandler::Read(input, mutable_value())) {
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index 30bd7b1d..27849298 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -237,20 +237,6 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);
#define GOOGLE_SAFE_CONCURRENT_WRITES_END()
#endif
-#if defined(__clang__) && defined(__has_cpp_attribute) \
- && !defined(GOOGLE_PROTOBUF_OS_APPLE)
-# if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN) || \
- __has_cpp_attribute(clang::fallthrough)
-# define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]]
-# endif
-#elif defined(__GNUC__) && __GNUC__ > 6
-# define GOOGLE_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
-#endif
-
-#ifndef GOOGLE_FALLTHROUGH_INTENDED
-# define GOOGLE_FALLTHROUGH_INTENDED
-#endif
-
#define GOOGLE_GUARDED_BY(x)
#define GOOGLE_ATTRIBUTE_COLD