Author: Akira Hatanaka
Date: 2022-11-15T17:14:48-08:00
New Revision: 81e33602f78d135c11b0d74d738263fc6cfaae12

URL: 
https://github.com/llvm/llvm-project/commit/81e33602f78d135c11b0d74d738263fc6cfaae12
DIFF: 
https://github.com/llvm/llvm-project/commit/81e33602f78d135c11b0d74d738263fc6cfaae12.diff

LOG: [Sema] Use the value category of the base expression when creating an
ExtVectorElementExpr

This fixes a bug where an lvalue ExtVectorElementExpr was created when
the base expression was an ObjC property dot operator.

This reverts 220d08d942ab0df3211388e602ed34fa6139ca61.

Differential Revision: https://reviews.llvm.org/D138058

Added: 
    

Modified: 
    clang/lib/Sema/SemaExprMember.cpp
    clang/test/SemaObjC/property-not-lvalue.m

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 8eeed1a29dfc7..a3420ac6fdd2d 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1621,16 +1621,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
   if (BaseType->isExtVectorType()) {
     // FIXME: this expr should store IsArrow.
     IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
-    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();
-    }
-
+    ExprValueKind VK = (IsArrow ? VK_LValue : BaseExpr.get()->getValueKind());
     QualType ret = CheckExtVectorComponent(S, BaseType, VK, OpLoc,
                                            Member, MemberLoc);
     if (ret.isNull())

diff  --git a/clang/test/SemaObjC/property-not-lvalue.m 
b/clang/test/SemaObjC/property-not-lvalue.m
index 4f8301b40ef31..029a0723ad2cb 100644
--- a/clang/test/SemaObjC/property-not-lvalue.m
+++ b/clang/test/SemaObjC/property-not-lvalue.m
@@ -7,10 +7,13 @@
                } inner;
 } NSSize;
 
+typedef __attribute__((__ext_vector_type__(2))) float simd_float2;
+
 @interface Foo  {
         NSSize _size;
 }
 @property NSSize size;
+@property simd_float2 f2;
 @end
 
 void foo(void) { 
@@ -32,3 +35,8 @@ - (void)MyView_sharedInit {
 }
 - (NSSize)size {}
 @end
+
+// clang used to crash compiling this code.
+void test(Foo *f) {
+  simd_float2 *v = &f.f2.xy; // expected-error {{cannot take the address of an 
rvalue}}
+}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to