[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / diagnostics / macros.m
blobb4599748621481a749dd24af5990fd9b63c54f95
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -fblocks -analyzer-output=text -verify %s
3 #include "../Inputs/system-header-simulator-objc.h"
5 @interface NSDictionary : NSObject
6 - (NSUInteger)count;
7 - (id)objectForKey:(id)aKey;
8 - (NSEnumerator *)keyEnumerator;
9 @end
10 @interface NSMutableDictionary : NSDictionary
11 - (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;
12 @end
14 void testBOOLMacro(BOOL b) {
15   if (b == YES) { // expected-note {{Assuming 'b' is equal to YES}}
16                   // expected-note@-1 {{Taking true branch}}
17     char *p = NULL;// expected-note {{'p' initialized to a null pointer value}}
18     *p = 7;  // expected-warning {{Dereference of null pointer (loaded from variable 'p')}}
19              // expected-note@-1 {{Dereference of null pointer (loaded from variable 'p')}}
20   }
23 void testNilMacro(NSMutableDictionary *d, NSObject *o) {
24   if (o == nil) // expected-note {{Assuming 'o' is equal to nil}}
25                 // expected-note@-1 {{Taking true branch}}
26     [d setObject:o forKey:[o description]]; // expected-warning {{Key argument to 'setObject:forKey:' cannot be nil}}
27                                             // expected-note@-1 {{'description' not called because the receiver is nil}}
28                                             // expected-note@-2 {{Key argument to 'setObject:forKey:' cannot be nil}}
30   return;