Commit ce517216 authored by Andres Medina's avatar Andres Medina Committed by Commit Bot

[third_party/protobuf] Modify how depreacated fields are allowed.

recently protobuf added a deprecated annotation to C++ code to warn when
depreacated protobuf fields are in use. To allow continue use of
deprecated fields in C++, a compiler exception was added. This turned
out to be pretty widespread. Will disable for now protobuf deprecated
warnings and remove the extra GN config so that the exception doesn't
need to be present.

Bug: 1151621
Change-Id: I9216c94079f90231f2cea81d9f46b6a39b0037fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2553387
Commit-Queue: Andres Medina <medinaandres@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Auto-Submit: Andres Medina <medinaandres@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830021}
parent f151b9c0
...@@ -25,9 +25,7 @@ config("protobuf_warnings") { ...@@ -25,9 +25,7 @@ config("protobuf_warnings") {
cflags = [] cflags = []
if (is_clang) { if (is_clang) {
# protobuf-3 contains a few functions that are unused. # protobuf-3 contains a few functions that are unused.
cflags += [ cflags += [ "-Wno-unused-function" ]
"-Wno-unused-function" ,
]
} }
} }
...@@ -35,9 +33,7 @@ config("protoc_warnings") { ...@@ -35,9 +33,7 @@ config("protoc_warnings") {
cflags = [] cflags = []
if (is_clang) { if (is_clang) {
# Some generates contain a few fields that are not used. # Some generates contain a few fields that are not used.
cflags += [ cflags += [ "-Wno-unused-private-field" ]
"-Wno-unused-private-field" ,
]
} }
} }
...@@ -58,7 +54,7 @@ config("using_proto") { ...@@ -58,7 +54,7 @@ config("using_proto") {
config("allow_deprecated_proto_fields") { config("allow_deprecated_proto_fields") {
if (is_clang) { if (is_clang) {
cflags = [ "-Wno-deprecated-declarations" ] cflags = [ "-DPROTOBUF_ALLOW_DEPRECATED=1" ]
} }
} }
...@@ -93,8 +89,8 @@ protobuf_lite_sources = [ ...@@ -93,8 +89,8 @@ protobuf_lite_sources = [
"src/google/protobuf/io/zero_copy_stream_impl.h", "src/google/protobuf/io/zero_copy_stream_impl.h",
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc", "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"src/google/protobuf/io/zero_copy_stream_impl_lite.h", "src/google/protobuf/io/zero_copy_stream_impl_lite.h",
"src/google/protobuf/map.h",
"src/google/protobuf/map.cc", "src/google/protobuf/map.cc",
"src/google/protobuf/map.h",
"src/google/protobuf/map_entry_lite.h", "src/google/protobuf/map_entry_lite.h",
"src/google/protobuf/map_field_lite.h", "src/google/protobuf/map_field_lite.h",
"src/google/protobuf/map_type_handler.h", "src/google/protobuf/map_type_handler.h",
......
...@@ -75,3 +75,8 @@ Description of the patches: ...@@ -75,3 +75,8 @@ Description of the patches:
- 0021-Fix-protobuf-s-library-.gitinore-file.patch - 0021-Fix-protobuf-s-library-.gitinore-file.patch
Un-ignores python/google/protobuf/descriptor_pb2.py Un-ignores python/google/protobuf/descriptor_pb2.py
- 0022-Allow-deprecated-fields.patch
Allows depreacated fields to be used without extra C++ compiler warnings.
\ No newline at end of file
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 19e71f80c..4283ed099 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -150,6 +150,11 @@
} /* namespace protobuf */ \
} /* namespace google */
+#ifdef PROTOBUF_ALLOW_DEPRECATED
+#define PROTOBUF_DEPRECATED
+#define PROTOBUF_DEPRECATED_ENUM
+#define PROTOBUF_DEPRECATED_MSG(msg)
+#else
#if defined(__GNUC__) || defined(__clang__)
#define PROTOBUF_DEPRECATED __attribute__((deprecated))
#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
@@ -159,6 +164,7 @@
#define PROTOBUF_DEPRECATED_ENUM
#define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#endif
+#endif
#define PROTOBUF_SECTION_VARIABLE(x)
#define PROTOBUF_MUST_USE_RESULT
...@@ -150,6 +150,11 @@ ...@@ -150,6 +150,11 @@
} /* namespace protobuf */ \ } /* namespace protobuf */ \
} /* namespace google */ } /* namespace google */
#ifdef PROTOBUF_ALLOW_DEPRECATED
#define PROTOBUF_DEPRECATED
#define PROTOBUF_DEPRECATED_ENUM
#define PROTOBUF_DEPRECATED_MSG(msg)
#else
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#define PROTOBUF_DEPRECATED __attribute__((deprecated)) #define PROTOBUF_DEPRECATED __attribute__((deprecated))
#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) #define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
...@@ -159,6 +164,7 @@ ...@@ -159,6 +164,7 @@
#define PROTOBUF_DEPRECATED_ENUM #define PROTOBUF_DEPRECATED_ENUM
#define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg)) #define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#endif #endif
#endif
#define PROTOBUF_SECTION_VARIABLE(x) #define PROTOBUF_SECTION_VARIABLE(x)
#define PROTOBUF_MUST_USE_RESULT #define PROTOBUF_MUST_USE_RESULT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment