1// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
2@class NSString;
3
4@interface NSException
5
6+ (void)raise:(NSString *)name format:(NSString *)format;
7+ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
8
9@end
10
11@interface NotException
12
13+ (void)raise:(NSString *)name format:(NSString *)format;
14
15@end
16
17@implementation Foo
18- (void)f {
19    NSString *foo = @"foo";
20    @throw foo;
21    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
22}
23
24- (void)f2 {
25    [NSException raise:@"TestException" format:@"Test"];
26    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
27    [NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
28    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
29    [NotException raise:@"NotException" format:@"Test"];
30}
31@end
32
33