Add test case for -Wdeprecated-objc-pointer-introspection, and

tweak warning to suggest that it is just a bad thing to do.

llvm-svn: 180175
This commit is contained in:
Ted Kremenek 2013-04-24 06:52:20 +00:00
parent 616986f859
commit bedcd85645
2 changed files with 9 additions and 1 deletions

View File

@ -644,7 +644,7 @@ def warn_objc_isa_assign : Warning<
"object_setClass()">, InGroup<DeprecatedObjCIsaUsage>;
def warn_objc_pointer_masking : Warning<
"bitmasking for introspection of Objective-C object pointers is strongly "
"discouraged in favor of using runtime APIs">,
"discouraged">,
InGroup<DiagGroup<"deprecated-objc-pointer-introspection">>;
def warn_objc_property_default_assign_on_object : Warning<
"default property attribute 'assign' not appropriate for non-GC object">,

View File

@ -87,3 +87,11 @@ static void func() {
}
@end
// Test for introspection of Objective-C pointers via bitmasking.
void testBitmasking(NSObject *p) {
(void) (((NSUInteger) p) & 0x1); // expected-warning {{bitmasking for introspection of Objective-C object pointers is strongly discouraged}}
(void) (0x1 & ((NSUInteger) p)); // expected-warning {{bitmasking for introspection of Objective-C object pointers is strongly discouraged}}
(void) (((NSUInteger) p) ^ 0x1); // no-warning
(void) (0x1 ^ ((NSUInteger) p)); // no-warning
}