forked from OSchip/llvm-project
Enforce nonnull __attribute__ on Objective-C method calls.
// rdar://9287695 llvm-svn: 129615
This commit is contained in:
parent
46ce91a964
commit
0fe1a9861c
|
@ -324,6 +324,12 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
|
|||
Args[NumArgs-1]->getLocEnd());
|
||||
}
|
||||
}
|
||||
// diagnose nonnull arguments.
|
||||
for (specific_attr_iterator<NonNullAttr>
|
||||
i = Method->specific_attr_begin<NonNullAttr>(),
|
||||
e = Method->specific_attr_end<NonNullAttr>(); i != e; ++i) {
|
||||
CheckNonNullArguments(*i, Args, lbrac);
|
||||
}
|
||||
|
||||
DiagnoseSentinelCalls(Method, lbrac, Args, NumArgs);
|
||||
return IsError;
|
||||
|
|
|
@ -67,3 +67,30 @@ void func6(dispatch_object_t _head) {
|
|||
_dispatch_queue_push_list(_head._do); // no warning
|
||||
}
|
||||
|
||||
// rdar://9287695
|
||||
#define NULL (void*)0
|
||||
|
||||
@interface NSObject
|
||||
- (void)doSomethingWithNonNullPointer:(void *)ptr :(int)iarg : (void*)ptr1 __attribute__((nonnull(1, 3)));
|
||||
+ (void)doSomethingClassyWithNonNullPointer:(void *)ptr __attribute__((nonnull(1)));
|
||||
@end
|
||||
|
||||
extern void DoSomethingNotNull(void *db) __attribute__((nonnull(1)));
|
||||
|
||||
@interface IMP
|
||||
{
|
||||
void * vp;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation IMP
|
||||
- (void) Meth {
|
||||
NSObject *object;
|
||||
[object doSomethingWithNonNullPointer:NULL:1:NULL]; // expected-warning 2 {{null passed to a callee which requires a non-null argument}}
|
||||
[object doSomethingWithNonNullPointer:vp:1:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}}
|
||||
[NSObject doSomethingClassyWithNonNullPointer:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}}
|
||||
DoSomethingNotNull(NULL); // expected-warning {{null passed to a callee which requires a non-null argument}}
|
||||
[object doSomethingWithNonNullPointer:vp:1:vp];
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue