]> granicus.if.org Git - clang/commitdiff
Sema: handle typo correction with ARC'ed objc properties
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 7 Feb 2016 02:30:55 +0000 (02:30 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 7 Feb 2016 02:30:55 +0000 (02:30 +0000)
We would previously assert in findCapturingExpr when performing a typo
correction resulting in an assignment of an ObjC property with a strong lifetype
specifier due to the expression not being rooted in the file (invalid SLoc)
during the retain cycle check on the typo-corrected expression.  Handle the
expression type appropriately during the TreeTransform to ensure that we have a
source location associated with the expression.

Fixes PR26486.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260016 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaObjC/typo-correction-arc.m [new file with mode: 0644]

index 32aa5a69d07aca4cdb0723dc1205dacfa5e7ca31..3083a1f50dff3a2688b60188db83db7207d188ea 100644 (file)
@@ -6586,6 +6586,10 @@ public:
 
   ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
 
+  ExprResult TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
+    return Owned(E);
+  }
+
   ExprResult Transform(Expr *E) {
     ExprResult Res;
     while (true) {
diff --git a/test/SemaObjC/typo-correction-arc.m b/test/SemaObjC/typo-correction-arc.m
new file mode 100644 (file)
index 0000000..9131ca8
--- /dev/null
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only -Wno-objc-root-class %s -verify
+
+typedef unsigned long NSUInteger;
+
+@interface NSArray
+- (instancetype)initWithObjects:(const id[])objects count:(NSUInteger)count;
+@end
+
+@interface I
+@property NSArray *array;
+@end
+
+@interface J
+- (void)setArray:(id)array;
+@end
+
+@implementation J {
+  I *i;
+}
+- (void)setArray:(id)array {  // expected-note{{'array' declared here}}
+  i.array = aray;             // expected-error{{use of undeclared identifier 'aray'; did you mean 'array'}}
+}
+@end
+