瀏覽代碼

[protobuf/objc] Introduce a protobuf-specific deprecation annotation ⚠️

Instead of using DEPRECATED_ATTRIBUTE from AvailabilityMacros.h, we should introduce a Google-specific Objective-C protobuf deprecation annotation. This helps address IWYU issues with using DEPRECATED_ATTRIBUTE and also enables allows clients to redefine the macro to treat protobuf warnings differently than other types of warnings (e.g., treating protobuf deprecation warnings as errors or ignoring them).
Stephane Moore 6 年之前
父節點
當前提交
b323b13679
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 7 0
      objectivec/GPBBootstrap.h
  2. 1 1
      src/google/protobuf/compiler/objectivec/objectivec_helpers.h

+ 7 - 0
objectivec/GPBBootstrap.h

@@ -91,6 +91,13 @@
 #endif
 #endif
 
+/**
+ * Attribute used for Objective-C proto interface deprecations.
+ **/
+#ifndef GPB_DEPRECATED
+#define GPB_DEPRECATED __attribute__((deprecated))
+#endif
+
 // If property name starts with init we need to annotate it to get past ARC.
 // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
 //

+ 1 - 1
src/google/protobuf/compiler/objectivec/objectivec_helpers.h

@@ -167,7 +167,7 @@ string GetOptionalDeprecatedAttribute(
     isDeprecated = file->options().deprecated();
   }
   if (isDeprecated) {
-    string result = "DEPRECATED_ATTRIBUTE";
+    string result = "GPB_DEPRECATED";
     if (preSpace) {
       result.insert(0, " ");
     }