From 938ba4103934db7459a920ca0cd96f0fd3953695 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 10 Dec 2015 15:49:53 -0500 Subject: 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. --- objectivec/GPBDictionary.m | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'objectivec/GPBDictionary.m') 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]; -- cgit v1.2.3