[ios, macos] Fixes for static analyzer warnings (#14453)
This commit is contained in:
@@ -291,7 +291,7 @@ private: // Private utilities for converting from mbgl to mgl values
|
||||
}
|
||||
|
||||
// Array
|
||||
static ObjCType toMGLRawStyleValue(const std::vector<MBGLElement> &mbglStopValue) {
|
||||
static NSArray<NSExpression*> *toMGLRawStyleValue(const std::vector<MBGLElement> &mbglStopValue) {
|
||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()];
|
||||
for (const auto &mbglElement: mbglStopValue) {
|
||||
[array addObject:[NSExpression expressionForConstantValue:toMGLRawStyleValue(mbglElement)]];
|
||||
|
||||
@@ -190,7 +190,7 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionI
|
||||
@return An initialized expression equivalent to `object`, suitable for use as
|
||||
the value of a style layer attribute.
|
||||
*/
|
||||
+ (instancetype)expressionWithMGLJSONObject:(id)object NS_SWIFT_NAME(init(mglJSONObject:));
|
||||
+ (instancetype)expressionWithMGLJSONObject:(nullable id)object NS_SWIFT_NAME(init(mglJSONObject:));
|
||||
|
||||
/**
|
||||
An equivalent Foundation object that can be serialized as JSON.
|
||||
|
||||
@@ -823,9 +823,14 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
|
||||
minimum = [NSExpression expressionWithMGLJSONObject:valueExpression];
|
||||
}
|
||||
}
|
||||
NSExpression *stopExpression = [NSExpression expressionForConstantValue:stops];
|
||||
return [NSExpression expressionForFunction:@"mgl_step:from:stops:"
|
||||
arguments:@[inputExpression, minimum, stopExpression]];
|
||||
|
||||
NSAssert(minimum, @"minimum should be non-nil");
|
||||
if (minimum) {
|
||||
NSExpression *stopExpression = [NSExpression expressionForConstantValue:stops];
|
||||
return [NSExpression expressionForFunction:@"mgl_step:from:stops:"
|
||||
arguments:@[inputExpression, minimum, stopExpression]];
|
||||
}
|
||||
|
||||
} else if ([op isEqualToString:@"zoom"]) {
|
||||
return NSExpression.zoomLevelVariableExpression;
|
||||
} else if ([op isEqualToString:@"heatmap-density"]) {
|
||||
@@ -1030,7 +1035,11 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
|
||||
expressionObject = @[@"get", pathComponent];
|
||||
}
|
||||
}
|
||||
return expressionObject;
|
||||
|
||||
NSAssert(expressionObject.count > 0, @"expressionObject should be non-empty");
|
||||
|
||||
// Return a non-null value to quieten static analysis
|
||||
return expressionObject ?: @[];
|
||||
}
|
||||
|
||||
case NSFunctionExpressionType: {
|
||||
|
||||
@@ -13,8 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSObject (MGLExpressionAdditions)
|
||||
|
||||
- (NSNumber *)mgl_number;
|
||||
- (NSNumber *)mgl_numberWithFallbackValues:(id)fallbackValue, ... NS_REQUIRES_NIL_TERMINATION;
|
||||
- (nullable NSNumber *)mgl_number;
|
||||
- (nullable NSNumber *)mgl_numberWithFallbackValues:(id)fallbackValue, ... NS_REQUIRES_NIL_TERMINATION;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (mbgl::style::Filter)mgl_filter;
|
||||
|
||||
+ (instancetype)mgl_predicateWithFilter:(mbgl::style::Filter)filter;
|
||||
+ (nullable instancetype)mgl_predicateWithFilter:(mbgl::style::Filter)filter;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSPredicate (MGLExpressionAdditions)
|
||||
|
||||
- (id)mgl_if:(id)firstValue, ...;
|
||||
- (nullable id)mgl_if:(id)firstValue, ...;
|
||||
|
||||
- (id)mgl_match:(NSExpression *)firstCase, ...;
|
||||
- (nullable id)mgl_match:(NSExpression *)firstCase, ...;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
self.mapView.showsUserLocation = NO;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,12 @@ const CGFloat MBXFrameTimeBarWidth = 4.f;
|
||||
self.scrollLayer.frame = self.bounds;
|
||||
|
||||
CGRect thresholdLineRect = CGRectMake(0, self.frame.size.height - [self renderDurationTargetMilliseconds], self.frame.size.width, 1);
|
||||
self.thresholdLayer.path = CGPathCreateWithRect(thresholdLineRect, nil);
|
||||
|
||||
{
|
||||
CGPathRef path = CGPathCreateWithRect(thresholdLineRect, nil);
|
||||
self.thresholdLayer.path = path;
|
||||
CGPathRelease(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,13 @@
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
[super viewDidDisappear:animated];
|
||||
[self.timer invalidate];
|
||||
self.timer = nil;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
self.timer = [NSTimer scheduledTimerWithTimeInterval:1
|
||||
target:self
|
||||
selector:@selector(onTimerTick)
|
||||
|
||||
@@ -155,13 +155,13 @@ CLLocationCoordinate2D randomWorldCoordinate() {
|
||||
{{ 12.966246, 77.586505 }, 19000 } // Bengaluru
|
||||
};
|
||||
|
||||
NSInteger index = drand48() * (sizeof(landmasses)/sizeof(landmasses[0]));
|
||||
NSInteger index = arc4random_uniform(sizeof(landmasses)/sizeof(landmasses[0]));
|
||||
CLLocationCoordinate2D coordinate = landmasses[index].coordinate;
|
||||
CLLocationDistance radius = landmasses[index].radius;
|
||||
|
||||
// Now create a world coord
|
||||
CLLocationDegrees heading = drand48()*360.0;
|
||||
CLLocationDistance distance = drand48()*radius;
|
||||
CLLocationDegrees heading = (CLLocationDegrees)arc4random_uniform(360);
|
||||
CLLocationDistance distance = (CLLocationDistance)arc4random_uniform(radius);
|
||||
CLLocationCoordinate2D newLocation = coordinateCentered(coordinate, heading, distance);
|
||||
return newLocation;
|
||||
}
|
||||
@@ -1775,8 +1775,8 @@ CLLocationCoordinate2D randomWorldCoordinate() {
|
||||
NSMutableArray *annotations = [[NSMutableArray alloc] initWithCapacity:numAnnotations];
|
||||
for (NSInteger i = 0; i<numAnnotations; i++) {
|
||||
|
||||
CLLocationDegrees heading = drand48()*360.0;
|
||||
CLLocationDistance distance = drand48()*radius;
|
||||
CLLocationDegrees heading = (CLLocationDegrees)arc4random_uniform(360);
|
||||
CLLocationDistance distance = (CLLocationDistance)arc4random_uniform(radius);
|
||||
CLLocationCoordinate2D newLocation = coordinateCentered(coordinate, heading, distance);
|
||||
|
||||
MBXDroppedPinAnnotation *annotation = [[MBXDroppedPinAnnotation alloc] init];
|
||||
@@ -1814,12 +1814,12 @@ CLLocationCoordinate2D randomWorldCoordinate() {
|
||||
[self.mapView addAnnotation:annotation];
|
||||
|
||||
// Add annotations around that coord
|
||||
[self addAnnotations:50 aroundCoordinate:annotation.coordinate radius:100000.0]; // 100km
|
||||
[self addAnnotations:50 aroundCoordinate:annotation.coordinate radius:100000]; // 100km
|
||||
|
||||
MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:annotation.coordinate
|
||||
altitude:10000.0
|
||||
pitch:drand48()*60.0
|
||||
heading:drand48()*360];
|
||||
pitch:(CLLocationDegrees)arc4random_uniform(60)
|
||||
heading:(CLLocationDegrees)arc4random_uniform(360)];
|
||||
[self.mapView flyToCamera:camera
|
||||
withDuration:duration
|
||||
peakAltitude:2000000.0
|
||||
|
||||
@@ -3630,8 +3630,12 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -3899,8 +3903,12 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -3967,8 +3975,12 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
|
||||
@@ -1130,7 +1130,7 @@ MGL_EXPORT
|
||||
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
|
||||
depending on the order of notification delivery.
|
||||
*/
|
||||
- (MGLMapCamera *)cameraThatFitsCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
|
||||
- (nullable MGLMapCamera *)cameraThatFitsCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
|
||||
|
||||
/**
|
||||
Returns the camera that best fits the given coordinate bounds, with the specified camera,
|
||||
@@ -1150,7 +1150,7 @@ MGL_EXPORT
|
||||
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
|
||||
depending on the order of notification delivery.
|
||||
*/
|
||||
- (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
|
||||
- (nullable MGLMapCamera *)camera:(MGLMapCamera *)camera fittingCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets;
|
||||
|
||||
/**
|
||||
Returns the camera that best fits the given shape, with the specified camera,
|
||||
@@ -1169,7 +1169,7 @@ MGL_EXPORT
|
||||
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
|
||||
depending on the order of notification delivery.
|
||||
*/
|
||||
- (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingShape:(MGLShape *)shape edgePadding:(UIEdgeInsets)insets;
|
||||
- (nullable MGLMapCamera *)camera:(MGLMapCamera *)camera fittingShape:(MGLShape *)shape edgePadding:(UIEdgeInsets)insets;
|
||||
|
||||
/**
|
||||
Returns the camera that best fits the given shape, with the specified direction,
|
||||
@@ -1187,7 +1187,7 @@ MGL_EXPORT
|
||||
`UIApplicationWillTerminateNotification`; you may receive a `nil` return value
|
||||
depending on the order of notification delivery.
|
||||
*/
|
||||
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets;
|
||||
- (nullable MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets;
|
||||
|
||||
/**
|
||||
Returns the point in this view’s coordinate system on which to "anchor" in
|
||||
|
||||
@@ -2481,7 +2481,7 @@ public:
|
||||
}];
|
||||
[attributionController addAction:telemetryAction];
|
||||
|
||||
NSString *cancelTitle = NSLocalizedStringWithDefaultValue(@"CANCEL", nil, nil, @"Cancel", @"");
|
||||
NSString *cancelTitle = NSLocalizedStringWithDefaultValue(@"CANCEL", nil, nil, @"Cancel", @"Cancel");
|
||||
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelTitle
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:NULL];
|
||||
|
||||
@@ -4,7 +4,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIView (MGLAdditions)
|
||||
|
||||
- (UIViewController *)mgl_viewControllerForLayoutGuides;
|
||||
- (nullable UIViewController *)mgl_viewControllerForLayoutGuides;
|
||||
|
||||
- (NSLayoutYAxisAnchor *)mgl_safeTopAnchor;
|
||||
|
||||
|
||||
@@ -554,13 +554,18 @@ NSTimeInterval const kMGLSMCalloutViewRepositionDelayForUIScrollView = 1.0/3.0;
|
||||
stretch.toValue = presenting ? @1.0 : @0.0;
|
||||
animation = stretch;
|
||||
}
|
||||
|
||||
|
||||
NSAssert(animation, @"There should be an animation");
|
||||
|
||||
// CAAnimation is KVC compliant, so we can store whether we're presenting for lookup in our delegate methods
|
||||
[animation setValue:@(presenting) forKey:@"presenting"];
|
||||
|
||||
animation.fillMode = kCAFillModeForwards;
|
||||
animation.removedOnCompletion = NO;
|
||||
return animation;
|
||||
|
||||
// Cast as non-null to mute static analysis warning as documented at
|
||||
// https://clang-analyzer.llvm.org/faq.html#decide_nullability
|
||||
return (CAAnimation * _Nonnull)animation;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
|
||||
Reference in New Issue
Block a user