r186524 - Improve idiomatic-parentheses by checking method family instead of relying on the selector name.
Jean-Daniel Dupas
devlists at shadowlab.org
Wed Jul 17 11:17:14 PDT 2013
Author: jddupas
Date: Wed Jul 17 13:17:14 2013
New Revision: 186524
URL: http://llvm.org/viewvc/llvm-project?rev=186524&view=rev
Log:
Improve idiomatic-parentheses by checking method family instead of relying on the selector name.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/idiomatic-parentheses.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=186524&r1=186523&r2=186524&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jul 17 13:17:14 2013
@@ -11968,7 +11968,7 @@ void Sema::DiagnoseAssignmentAsCondition
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]
Modified: cfe/trunk/test/SemaObjC/idiomatic-parentheses.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/idiomatic-parentheses.m?rev=186524&r1=186523&r2=186524&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/idiomatic-parentheses.m (original)
+++ cfe/trunk/test/SemaObjC/idiomatic-parentheses.m Wed Jul 17 13:17:14 2013
@@ -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;
@@ -33,6 +34,12 @@
}
return self;
}
+
+- (id) myInit {
+ if (self = [self myInit]) {
+ }
+ return self;
+}
- (void) iterate: (id) coll {
id cur;
More information about the cfe-commits
mailing list