r224479 - [Objective-C]. Modern property getters have side-effects.
Fariborz Jahanian
fjahanian at apple.com
Wed Dec 17 16:30:54 PST 2014
Author: fjahanian
Date: Wed Dec 17 18:30:54 2014
New Revision: 224479
URL: http://llvm.org/viewvc/llvm-project?rev=224479&view=rev
Log:
[Objective-C]. Modern property getters have side-effects.
So, place warning about property getter should not be used for side-effect
under its own group so warning can be turned off.
rdar://19137815
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/SemaObjC/access-property-getter.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=224479&r1=224478&r2=224479&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Dec 17 18:30:54 2014
@@ -413,6 +413,7 @@ def UnusedVariable : DiagGroup<"unused-v
[UnusedConstVariable]>;
def UnusedLocalTypedef : DiagGroup<"unused-local-typedef">;
def UnusedPropertyIvar : DiagGroup<"unused-property-ivar">;
+def UnusedGetterReturnValue : DiagGroup<"unused-getter-return-value">;
def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">;
def UserDefinedLiterals : DiagGroup<"user-defined-literals">;
def Reorder : DiagGroup<"reorder">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=224479&r1=224478&r2=224479&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 17 18:30:54 2014
@@ -6100,7 +6100,7 @@ def warn_unused_voidptr : Warning<
InGroup<UnusedValue>;
def warn_unused_property_expr : Warning<
"property access result unused - getters should not be used for side effects">,
- InGroup<UnusedValue>;
+ InGroup<UnusedGetterReturnValue>;
def warn_unused_container_subscript_expr : Warning<
"container access result unused - container access should not be used for side effects">,
InGroup<UnusedValue>;
Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=224479&r1=224478&r2=224479&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed Dec 17 18:30:54 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
+// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
Modified: cfe/trunk/test/SemaObjC/access-property-getter.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/access-property-getter.m?rev=224479&r1=224478&r2=224479&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/access-property-getter.m (original)
+++ cfe/trunk/test/SemaObjC/access-property-getter.m Wed Dec 17 18:30:54 2014
@@ -34,3 +34,20 @@
return 0;
}
@end
+
+// rdar://19137815
+#pragma clang diagnostic ignored "-Wunused-getter-return-value"
+
+ at interface NSObject @end
+
+ at interface I : NSObject
+ at property (copy) id window;
+ at end
+
+ at implementation I
+- (void) Meth {
+ [self window];
+ self.window;
+}
+ at end
+
More information about the cfe-commits
mailing list