Improve idiomatic-parentheses by checking method family instead of relying on the selector name.

llvm-svn: 186524
This commit is contained in:
Jean-Daniel Dupas 2013-07-17 18:17:14 +00:00
parent 3e7db845f7
commit 3965574929
2 changed files with 8 additions and 1 deletions

View File

@ -11968,7 +11968,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
Selector Sel = ME->getSelector();
// self = [<foo> init...]
if (isSelfExpr(Op->getLHS()) && Sel.getNameForSlot(0).startswith("init"))
if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() == OMF_init)
diagnostic = diag::warn_condition_is_idiomatic_assignment;
// <foo> = [<bar> nextObject]

View File

@ -9,6 +9,7 @@
}
- (id) init;
- (id) initWithInt: (int) i;
- (id) myInit __attribute__((objc_method_family(init)));
- (void) iterate: (id) coll;
- (id) nextObject;
@property unsigned uid;
@ -34,6 +35,12 @@
return self;
}
- (id) myInit {
if (self = [self myInit]) {
}
return self;
}
- (void) iterate: (id) coll {
id cur;
while (cur = [coll nextObject]) {