From: Jean-Daniel Dupas Date: Wed, 17 Jul 2013 18:17:14 +0000 (+0000) Subject: Improve idiomatic-parentheses by checking method family instead of relying on the... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8df014e2b173f9c0595f87480d59caaf8979fca3;p=clang Improve idiomatic-parentheses by checking method family instead of relying on the selector name. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186524 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 517afdac1a..0106232bbb 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -11968,7 +11968,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) { Selector Sel = ME->getSelector(); // self = [ 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; // = [ nextObject] diff --git a/test/SemaObjC/idiomatic-parentheses.m b/test/SemaObjC/idiomatic-parentheses.m index 801db5944f..c6281f0987 100644 --- a/test/SemaObjC/idiomatic-parentheses.m +++ b/test/SemaObjC/idiomatic-parentheses.m @@ -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]) {