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 517afda..0106232 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -11968,7 +11968,7 @@
       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]
diff --git a/test/SemaObjC/idiomatic-parentheses.m b/test/SemaObjC/idiomatic-parentheses.m
index 801db59..c6281f0 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]) {