diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2017-09-15 00:08:37 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2017-09-15 00:08:37 +0000 |
commit | 4d9d425d739b556339e6aa7006754bc5e0459b2b (patch) | |
tree | 4d21ee1bcc5408248481339cc069a713ad699190 /test/SemaObjCXX | |
parent | 11269d31847e07edf14db760e5e940f394ce595d (diff) |
[Sema] Correct typos in LHS, RHS before building a binop expression.
Specifically, typo correction should be done before dispatching between
different kinds of binary operations like pseudo-object assignment,
overloaded binary operation, etc.
Without this change we hit an assertion
Assertion failed: (!LHSExpr->hasPlaceholderType(BuiltinType::PseudoObject)), function CheckAssignmentOperands
when in Objective-C we reference a property without `self` and there are
2 equally good typo correction candidates: ivar and a class name. In
this case LHS expression in `BuildBinOp` is
CXXDependentScopeMemberExpr
`-TypoExpr
and instead of handling Obj-C property assignment as pseudo-object
assignment, we call `CreateBuiltinBinOp` which corrects typo to
ObjCPropertyRefExpr '<pseudo-object type>'
but cannot handle pseudo-objects and asserts about it (indirectly,
through `CheckAssignmentOperands`).
rdar://problem/33102722
Reviewers: rsmith, ahatanak, majnemer
Reviewed By: ahatanak
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D37322
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r-- | test/SemaObjCXX/typo-correction.mm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/SemaObjCXX/typo-correction.mm b/test/SemaObjCXX/typo-correction.mm index 5e33bfb8cb..8dcda7921f 100644 --- a/test/SemaObjCXX/typo-correction.mm +++ b/test/SemaObjCXX/typo-correction.mm @@ -36,3 +36,22 @@ void invalidNameInIvarAndPropertyBase() { float a = ((InvalidNameInIvarAndPropertyBase*)node)->_a; // expected-error {{use of undeclared identifier 'node'}} float b = ((InvalidNameInIvarAndPropertyBase*)node)._b; // expected-error {{use of undeclared identifier 'node'}} } + +// rdar://problem/33102722 +// Typo correction for a property when it has as correction candidates +// synthesized ivar and a class name, both at the same edit distance. +@class TypoCandidate; + +@interface PropertyType : NSObject +@property int x; +@end + +@interface InterfaceC : NSObject +@property(assign) PropertyType *typoCandidate; // expected-note {{'_typoCandidate' declared here}} +@end + +@implementation InterfaceC +-(void)method { + typoCandidate.x = 0; // expected-error {{use of undeclared identifier 'typoCandidate'; did you mean '_typoCandidate'?}} +} +@end |