New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 809157 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug

Blocking:
issue 177475



Sign in to add a comment

GOOGLE_FALLTHROUGH_INTENDED in third_party/protobuf has issues

Project Member Reported by thakis@chromium.org, Feb 5 2018

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?
 
My experience is that getting patches upstream is very easy. The procedure I followed was to go through public protobuf github[1], as this seems to be currently source of truth for protobuf. Just follow the regular github workflow; fork, edit, pull request. 

Rolling the whole protobuf tends to get harder the longer it passes since the previous roll. We have a procedure for cherry-picks, see README.chromium and third_party/protobuf/patches/.

[1] - https://github.com/google/protobuf/
Owner: thakis@chromium.org
Status: Fixed (was: Untriaged)

Sign in to add a comment