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

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 15 17:15:51 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG81e33602f78d: [Sema] Use the value category of the base expression when creating an (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138058/new/

https://reviews.llvm.org/D138058

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


Index: clang/test/SemaObjC/property-not-lvalue.m
===================================================================
--- clang/test/SemaObjC/property-not-lvalue.m
+++ 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;
+ at property simd_float2 f2;
 @end
 
 void foo(void) { 
@@ -32,3 +35,8 @@
 }
 - (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}}
+}
Index: clang/lib/Sema/SemaExprMember.cpp
===================================================================
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -1621,16 +1621,7 @@
   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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138058.475643.patch
Type: text/x-patch
Size: 1520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221116/099e2b4d/attachment.bin>


More information about the cfe-commits mailing list