diff options
author | Douglas Heriot <douglas@douglasheriot.com> | 2015-08-22 02:05:40 +1000 |
---|---|---|
committer | Douglas Heriot <douglas@douglasheriot.com> | 2015-08-22 02:05:40 +1000 |
commit | 5021c4d88506ac19be4302be02c3cd1702f97d03 (patch) | |
tree | 901d4932207a1a2988aff54bdc66f652dde6b07c /src/google/protobuf/repeated_field.h | |
parent | 0cb84ee31fc2ac6e6f07c76a5dc20a20272d7516 (diff) |
Define GOOGLE_ATTRIBUTE_NOINLINE for MSVC. Workaround for VS2015 Release build compiler bug.
See issue #240 - MSVC in VS2015 seems to inline a function it shouldn't. My original workaround was to disable inlining for the whole file, but I found a way to do it on just this specific function using __declspec(noinline).
Unfortunately __declspec has to go at the start of the function declaration, while __attribute in GCC can go either before or after. I had to move lots of GOOGLE_ATTRIBUTE_NOLINE to make it compile. I have not yet tested this change with GCC.
Will there be other side effects of defining this, given it wasn't previously?
I also noticed a few functions marked with both the 'inline' keyword, and GOOGLE_ATTRIBUTE_NOINLINE - huh? Is there an explanation for this, or is it an oversight?
Diffstat (limited to 'src/google/protobuf/repeated_field.h')
-rw-r--r-- | src/google/protobuf/repeated_field.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 14f46298..9c84ed98 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -458,22 +458,21 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { void AddAllocatedInternal(typename TypeHandler::Type* value, google::protobuf::internal::false_type); - template <typename TypeHandler> + template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE void AddAllocatedSlowWithCopy(typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena) - GOOGLE_ATTRIBUTE_NOINLINE; - template <typename TypeHandler> - void AddAllocatedSlowWithoutCopy(typename TypeHandler::Type* value) - GOOGLE_ATTRIBUTE_NOINLINE; +; + template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE + void AddAllocatedSlowWithoutCopy(typename TypeHandler::Type* value); template <typename TypeHandler> typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::true_type); template <typename TypeHandler> typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::false_type); - template<typename TypeHandler> - inline void SwapFallback(RepeatedPtrFieldBase* other) GOOGLE_ATTRIBUTE_NOINLINE; + template<typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE + inline void SwapFallback(RepeatedPtrFieldBase* other); inline Arena* GetArenaNoVirtual() const { return arena_; @@ -545,13 +544,13 @@ class GenericTypeHandler { // constructors and destructors. Note that the GOOGLE_ATTRIBUTE_NOINLINE macro // requires the 'inline' storage class here, which is somewhat confusing, but // the compiler does the right thing. + GOOGLE_ATTRIBUTE_NOINLINE static inline GenericType* NewFromPrototype(const GenericType* prototype, - ::google::protobuf::Arena* arena = NULL) - GOOGLE_ATTRIBUTE_NOINLINE { + ::google::protobuf::Arena* arena = NULL) { return New(arena); } - static inline void Delete(GenericType* value, Arena* arena) - GOOGLE_ATTRIBUTE_NOINLINE { + GOOGLE_ATTRIBUTE_NOINLINE + static inline void Delete(GenericType* value, Arena* arena) { if (arena == NULL) { delete value; } @@ -564,8 +563,9 @@ class GenericTypeHandler { } static inline void Clear(GenericType* value) { value->Clear(); } - static inline void Merge(const GenericType& from, GenericType* to) - GOOGLE_ATTRIBUTE_NOINLINE { + + GOOGLE_ATTRIBUTE_NOINLINE + static inline void Merge(const GenericType& from, GenericType* to) { to->MergeFrom(from); } static inline int SpaceUsed(const GenericType& value) { |