[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

llvm-svn: 224479
This commit is contained in:
Fariborz Jahanian 2014-12-18 00:30:54 +00:00
parent 2b8ff7e461
commit 323ddf97ba
4 changed files with 20 additions and 2 deletions

View File

@ -413,6 +413,7 @@ def UnusedVariable : DiagGroup<"unused-variable",
[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">;

View File

@ -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>;

View File

@ -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 )]

View File

@ -34,3 +34,20 @@
return 0;
}
@end
// rdar://19137815
#pragma clang diagnostic ignored "-Wunused-getter-return-value"
@interface NSObject @end
@interface I : NSObject
@property (copy) id window;
@end
@implementation I
- (void) Meth {
[self window];
self.window;
}
@end