[clang] 81e3360 - [Sema] Use the value category of the base expression when creating an
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 15 17:15:46 PST 2022
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;
+ at 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}}
+}
More information about the cfe-commits
mailing list