mirror of https://github.com/microsoft/clang.git
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
This commit is contained in:
parent
fd527a4e1a
commit
8df014e2b1
|
@ -11968,7 +11968,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
|
||||||
Selector Sel = ME->getSelector();
|
Selector Sel = ME->getSelector();
|
||||||
|
|
||||||
// self = [<foo> init...]
|
// 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;
|
diagnostic = diag::warn_condition_is_idiomatic_assignment;
|
||||||
|
|
||||||
// <foo> = [<bar> nextObject]
|
// <foo> = [<bar> nextObject]
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
}
|
}
|
||||||
- (id) init;
|
- (id) init;
|
||||||
- (id) initWithInt: (int) i;
|
- (id) initWithInt: (int) i;
|
||||||
|
- (id) myInit __attribute__((objc_method_family(init)));
|
||||||
- (void) iterate: (id) coll;
|
- (void) iterate: (id) coll;
|
||||||
- (id) nextObject;
|
- (id) nextObject;
|
||||||
@property unsigned uid;
|
@property unsigned uid;
|
||||||
|
@ -34,6 +35,12 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) myInit {
|
||||||
|
if (self = [self myInit]) {
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) iterate: (id) coll {
|
- (void) iterate: (id) coll {
|
||||||
id cur;
|
id cur;
|
||||||
while (cur = [coll nextObject]) {
|
while (cur = [coll nextObject]) {
|
||||||
|
|
Loading…
Reference in New Issue