[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 12:46:14 PST 2022
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.
This fixes a bug where an lvalue `ExtVectorElementExpr` was created when the base expression was an ObjC property dot operator.
This reverts 220d08d942ab0df3211388e602ed34fa6139ca61.
Repository:
rG LLVM Github Monorepo
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.475557.patch
Type: text/x-patch
Size: 1520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221115/a6219e68/attachment.bin>
More information about the cfe-commits
mailing list