aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBDictionary.m
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2015-12-10 15:49:53 -0500
committerThomas Van Lenten <thomasvl@google.com>2015-12-10 16:40:10 -0500
commit938ba4103934db7459a920ca0cd96f0fd3953695 (patch)
tree94fc5e48edf2dcd9e298f4b450e016687d2ac099 /objectivec/GPBDictionary.m
parent2f2da0702db0aab16f473a86b28de854e5740295 (diff)
downloadprotobuf-938ba4103934db7459a920ca0cd96f0fd3953695.tar.gz
protobuf-938ba4103934db7459a920ca0cd96f0fd3953695.tar.bz2
protobuf-938ba4103934db7459a920ca0cd96f0fd3953695.zip
Update the min toolchain for iOS/OS X to be Xcode 7
- Let Xcode update the projects, schemes, and info.plists. - Add workaround for shallow analyzer issues in current Xcode versions (deep analyze gets things correct). - Tweak the Swift based tests to avoid warnings from Xcode 7's XCTest using optionals for autoenclosure results. - No longer tag the ObjC iOS travis test as flaky, xctool seems to manage the simulator pretty well.
Diffstat (limited to 'objectivec/GPBDictionary.m')
-rw-r--r--objectivec/GPBDictionary.m25
1 files changed, 25 insertions, 0 deletions
diff --git a/objectivec/GPBDictionary.m b/objectivec/GPBDictionary.m
index 7015b3ee..6baa2a18 100644
--- a/objectivec/GPBDictionary.m
+++ b/objectivec/GPBDictionary.m
@@ -45,6 +45,18 @@
// directly.
// ------------------------------------------------------------------
+// Used to include code only visible to specific versions of the static
+// analyzer. Useful for wrapping code that only exists to silence the analyzer.
+// Determine the values you want to use for BEGIN_APPLE_BUILD_VERSION,
+// END_APPLE_BUILD_VERSION using:
+// xcrun clang -dM -E -x c /dev/null | grep __apple_build_version__
+// Example usage:
+// #if GPB_STATIC_ANALYZER_ONLY(5621, 5623) ... #endif
+#define GPB_STATIC_ANALYZER_ONLY(BEGIN_APPLE_BUILD_VERSION, END_APPLE_BUILD_VERSION) \
+ (defined(__clang_analyzer__) && \
+ (__apple_build_version__ >= BEGIN_APPLE_BUILD_VERSION && \
+ __apple_build_version__ <= END_APPLE_BUILD_VERSION))
+
enum {
kMapKeyFieldNumber = 1,
kMapValueFieldNumber = 2,
@@ -496,6 +508,19 @@ void GPBDictionaryReadEntry(id mapDictionary,
}
if ((keyDataType == GPBDataTypeString) && GPBDataTypeIsObject(valueDataType)) {
+#if GPB_STATIC_ANALYZER_ONLY(6020053, 7000181)
+ // Limited to Xcode 6.4 - 7.2, are known to fail here. The upper end can
+ // be raised as needed for new Xcodes.
+ //
+ // This is only needed on a "shallow" analyze; on a "deep" analyze, the
+ // existing code path gets this correct. In shallow, the analyzer decides
+ // GPBDataTypeIsObject(valueDataType) is both false and true on a single
+ // path through this function, allowing nil to be used for the
+ // setObject:forKey:.
+ if (value.valueString == nil) {
+ value.valueString = [@"" retain];
+ }
+#endif
// mapDictionary is an NSMutableDictionary
[(NSMutableDictionary *)mapDictionary setObject:value.valueString
forKey:key.valueString];