r180175 - Add test case for -Wdeprecated-objc-pointer-introspection, and
Ted Kremenek
kremenek at apple.com
Tue Apr 23 23:52:20 PDT 2013
Author: kremenek
Date: Wed Apr 24 01:52:20 2013
New Revision: 180175
URL: http://llvm.org/viewvc/llvm-project?rev=180175&view=rev
Log:
Add test case for -Wdeprecated-objc-pointer-introspection, and
tweak warning to suggest that it is just a bad thing to do.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaObjC/deprecated-objc-introspection.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=180175&r1=180174&r2=180175&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 24 01:52:20 2013
@@ -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">,
Modified: cfe/trunk/test/SemaObjC/deprecated-objc-introspection.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/deprecated-objc-introspection.m?rev=180175&r1=180174&r2=180175&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/deprecated-objc-introspection.m (original)
+++ cfe/trunk/test/SemaObjC/deprecated-objc-introspection.m Wed Apr 24 01:52:20 2013
@@ -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
+}
\ No newline at end of file
More information about the cfe-commits
mailing list