]> granicus.if.org Git - clang/commitdiff
Improve idiomatic-parentheses by checking method family instead of relying on the...
authorJean-Daniel Dupas <devlists@shadowlab.org>
Wed, 17 Jul 2013 18:17:14 +0000 (18:17 +0000)
committerJean-Daniel Dupas <devlists@shadowlab.org>
Wed, 17 Jul 2013 18:17:14 +0000 (18:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186524 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaObjC/idiomatic-parentheses.m

index 517afdac1af033f12c735a74142741ed4d6f3eb5..0106232bbbc426fbe2b55c366c1fa290c2ad923a 100644 (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]
index 801db5944f10f2982004b11d23a72fba61e7ba73..c6281f0987dec0030217b1cae24c94a38f072813 100644 (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;
   return self;
 }
 
+- (id) myInit {
+  if (self = [self myInit]) {
+  }
+  return self;
+}
+
 - (void) iterate: (id) coll {
   id cur;
   while (cur = [coll nextObject]) {