GOOGLE_FALLTHROUGH_INTENDED in third_party/protobuf has issues |
||
Issue description
third_party/protobuf/src/google/protobuf/stubs/port.h contains:
#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
#endif
This has at least two issues:
1.) It checks for !defined(GOOGLE_PROTOBUF_OS_APPLE) which means it's ignored in chrome/mac builds, causing warnings like this in chrome/mac builds with -Wimplicit-fallthrough enabled:
In file included from ../../third_party/protobuf/src/google/protobuf/map_field_lite.h:35:
../../third_party/protobuf/src/google/protobuf/map_entry_lite.h:207:9: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
case kValueTag:
^
../../third_party/protobuf/src/google/protobuf/map_entry_lite.h:550:3: note: in instantiation of member function 'google::protobuf::internal::MapEntryImpl<google::protobuf::internal::MapEntryLite<std::__1::basic_string<char>, float, google::protobuf::internal::WireFormatLite::TYPE_STRING, google::protobuf::internal::WireFormatLite::TYPE_FLOAT, 0>, google::protobuf::MessageLite, std::__1::basic_string<char>, float, google::protobuf::internal::WireFormatLite::TYPE_STRING, google::protobuf::internal::WireFormatLite::TYPE_FLOAT, 0>::MergePartialFromCodedStream' requested here
MapEntryLite() {}
^
../../third_party/protobuf/src/google/protobuf/generated_message_util.h:129:19: note: in instantiation of member function 'google::protobuf::internal::MapEntryLite<std::__1::basic_string<char>, float, google::protobuf::internal::WireFormatLite::TYPE_STRING, google::protobuf::internal::WireFormatLite::TYPE_FLOAT, 0>::MapEntryLite' requested here
new (&union_) T();
^
I don't know why GOOGLE_PROTOBUF_OS_APPLE is there. If it's only for a very old Xcode, maybe it could check for the version somehow, or at least there could be some define to override things.
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 base). Since this macro is _used_ in a public protobuf header (map_entry_lite.h) it's not fully clear to me what to do about this though -- maybe have a "fallthrough.h" header and a "fallthrough_undef.h" header and make sure their public headers include the undef header when they no longer need the macro? This is less important than 1, but still important.
cc third_party/protobuf owners. How hard is it to get patches into upstream protobuf? What's the process for that? How hard is it to roll protobuf after getting a patch upstream?
,
Feb 7 2018
Upstream patch: https://github.com/google/protobuf/pull/4288
,
Feb 8 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6c9efa619c6fd55fadce49b74768406358ba8068 commit 6c9efa619c6fd55fadce49b74768406358ba8068 Author: Nico Weber <thakis@chromium.org> Date: Thu Feb 08 21:02:07 2018 protobuf: cherry-pick upstream commit b8e47830d Bug: 809157 Change-Id: Id68ab68d988b32e7f7e5ef1fbbe50818bc160943 Reviewed-on: https://chromium-review.googlesource.com/909448 Reviewed-by: Adam Michalik <xyzzyz@chromium.org> Commit-Queue: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/master@{#535510} [modify] https://crrev.com/6c9efa619c6fd55fadce49b74768406358ba8068/third_party/protobuf/README.chromium [add] https://crrev.com/6c9efa619c6fd55fadce49b74768406358ba8068/third_party/protobuf/patches/0018-fallthrough.patch [modify] https://crrev.com/6c9efa619c6fd55fadce49b74768406358ba8068/third_party/protobuf/src/google/protobuf/map_entry_lite.h [modify] https://crrev.com/6c9efa619c6fd55fadce49b74768406358ba8068/third_party/protobuf/src/google/protobuf/stubs/port.h
,
Feb 8 2018
|
||
►
Sign in to add a comment |
||
Comment 1 by xyzzyz@chromium.org
, Feb 5 2018