r234176 - [Objective-C patch] Patch to fix a crash in IRGen because

Fariborz Jahanian fjahanian at apple.com
Mon Apr 6 09:56:39 PDT 2015


Author: fjahanian
Date: Mon Apr  6 11:56:39 2015
New Revision: 234176

URL: http://llvm.org/viewvc/llvm-project?rev=234176&view=rev
Log:
[Objective-C patch] Patch to fix a crash in IRGen because 
of incorrect AST when a compound literal of Objective-C
property access is used to initialize a vertor of floats.
rdar://20407999

Added:
    cfe/trunk/test/CodeGenObjC/compound-literal-property-access.m
Modified:
    cfe/trunk/lib/Sema/SemaExprMember.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=234176&r1=234175&r2=234176&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Mon Apr  6 11:56:39 2015
@@ -1519,7 +1519,15 @@ static ExprResult LookupMemberExpr(Sema
   if (BaseType->isExtVectorType()) {
     // FIXME: this expr should store IsArrow.
     IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
-    ExprValueKind VK = (IsArrow ? VK_LValue : BaseExpr.get()->getValueKind());
+    ExprValueKind VK;
+    if (IsArrow)
+      VK = VK_LValue;
+    else {
+      if (PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(BaseExpr.get()))
+        VK = POE->getSyntacticForm()->getValueKind();
+      else
+        VK = BaseExpr.get()->getValueKind();
+    }
     QualType ret = CheckExtVectorComponent(S, BaseType, VK, OpLoc,
                                            Member, MemberLoc);
     if (ret.isNull())

Added: cfe/trunk/test/CodeGenObjC/compound-literal-property-access.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/compound-literal-property-access.m?rev=234176&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/compound-literal-property-access.m (added)
+++ cfe/trunk/test/CodeGenObjC/compound-literal-property-access.m Mon Apr  6 11:56:39 2015
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s
+// rdar://20407999
+
+typedef __attribute__((__ext_vector_type__(2))) float vector_float2;
+
+ at interface GPAgent2D
+ at property (nonatomic, assign) vector_float2 position;
+ at end
+
+ at interface GPGoal @end
+
+ at implementation GPGoal
+-(void)getForce {
+    GPAgent2D* targetAgent;
+    (vector_float2){targetAgent.position.x, targetAgent.position.y};
+}
+ at end
+
+// CHECK: [[CL:%.*]] = alloca <2 x float>, align 8
+// CHECK: store <2 x float> [[VECINIT:%.*]], <2 x float>* [[CL]]
+// CHECK: [[FOURTEEN:%.*]] = load <2 x float>, <2 x float>* [[CL]]





More information about the cfe-commits mailing list