[llvm-branch-commits] [cfe-branch] r294059 - Merging r294008:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 3 14:23:11 PST 2017


Author: hans
Date: Fri Feb  3 16:23:11 2017
New Revision: 294059

URL: http://llvm.org/viewvc/llvm-project?rev=294059&view=rev
Log:
Merging r294008:
------------------------------------------------------------------------
r294008 | arphaman | 2017-02-03 06:22:33 -0800 (Fri, 03 Feb 2017) | 14 lines

[Sema][ObjC++] Typo correction should handle ivars and properties

After r260016 and r260017 disabled typo correction for ivars and properties
clang didn't report errors about unresolved identifier in the base of ivar and
property ref expressions. This meant that clang invoked CodeGen on invalid AST
which then caused a crash.

This commit re-enables typo correction for ivars and properites, and fixes the
PR25113 & PR26486 (that were originally fixed in r260017 and r260016) in a
different manner by transforming the Objective-C ivar reference expression with
'IsFreeIvar' preserved.

rdar://30310772

------------------------------------------------------------------------

Modified:
    cfe/branches/release_40/   (props changed)
    cfe/branches/release_40/lib/Sema/SemaExprCXX.cpp
    cfe/branches/release_40/lib/Sema/TreeTransform.h
    cfe/branches/release_40/test/SemaObjCXX/typo-correction.mm

Propchange: cfe/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  3 16:23:11 2017
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291963-291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293043,293134,293360,293369,293596,293678,293787
+/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291963-291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293043,293134,293360,293369,293596,293678,293787,294008
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_40/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Sema/SemaExprCXX.cpp?rev=294059&r1=294058&r2=294059&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/release_40/lib/Sema/SemaExprCXX.cpp Fri Feb  3 16:23:11 2017
@@ -7190,14 +7190,6 @@ public:
 
   ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
 
-  ExprResult TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
-    return Owned(E);
-  }
-
-  ExprResult TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
-    return Owned(E);
-  }
-
   ExprResult Transform(Expr *E) {
     ExprResult Res;
     while (true) {

Modified: cfe/branches/release_40/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Sema/TreeTransform.h?rev=294059&r1=294058&r2=294059&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/release_40/lib/Sema/TreeTransform.h Fri Feb  3 16:23:11 2017
@@ -2932,16 +2932,17 @@ public:
   ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar,
                                           SourceLocation IvarLoc,
                                           bool IsArrow, bool IsFreeIvar) {
-    // FIXME: We lose track of the IsFreeIvar bit.
     CXXScopeSpec SS;
     DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
-    return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
-                                              /*FIXME:*/IvarLoc, IsArrow,
-                                              SS, SourceLocation(),
-                                              /*FirstQualifierInScope=*/nullptr,
-                                              NameInfo,
-                                              /*TemplateArgs=*/nullptr,
-                                              /*S=*/nullptr);
+    ExprResult Result = getSema().BuildMemberReferenceExpr(
+        BaseArg, BaseArg->getType(),
+        /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
+        /*FirstQualifierInScope=*/nullptr, NameInfo,
+        /*TemplateArgs=*/nullptr,
+        /*S=*/nullptr);
+    if (IsFreeIvar && Result.isUsable())
+      cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
+    return Result;
   }
 
   /// \brief Build a new Objective-C property reference expression.

Modified: cfe/branches/release_40/test/SemaObjCXX/typo-correction.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/test/SemaObjCXX/typo-correction.mm?rev=294059&r1=294058&r2=294059&view=diff
==============================================================================
--- cfe/branches/release_40/test/SemaObjCXX/typo-correction.mm (original)
+++ cfe/branches/release_40/test/SemaObjCXX/typo-correction.mm Fri Feb  3 16:23:11 2017
@@ -21,3 +21,18 @@ public:
   self.m_prop2 = new ClassB(m_prop1); // expected-error {{use of undeclared identifier 'm_prop1'; did you mean '_m_prop1'?}}
 }
 @end
+
+// rdar://30310772
+
+ at interface InvalidNameInIvarAndPropertyBase
+{
+ at public
+  float  _a;
+}
+ at property float _b;
+ at end
+
+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'}}
+}




More information about the llvm-branch-commits mailing list