[cfe-commits] r129397 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGenObjC/property-agrr-getter.m
John McCall
rjmccall at apple.com
Tue Apr 12 15:02:02 PDT 2011
Author: rjmccall
Date: Tue Apr 12 17:02:02 2011
New Revision: 129397
URL: http://llvm.org/viewvc/llvm-project?rev=129397&view=rev
Log:
We can't emit an aggregate cast as its sub-expression in general just
because the result is ignored. The particular example here is with
property l-values, but there could be all sorts of lovely casts that this
isn't safe for. Sink the check into the one case that seems to actually
be capable of honoring this.
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/test/CodeGenObjC/property-agrr-getter.m
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=129397&r1=129396&r2=129397&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Tue Apr 12 17:02:02 2011
@@ -249,11 +249,6 @@
}
void AggExprEmitter::VisitCastExpr(CastExpr *E) {
- if (Dest.isIgnored() && E->getCastKind() != CK_Dynamic) {
- Visit(E->getSubExpr());
- return;
- }
-
switch (E->getCastKind()) {
case CK_Dynamic: {
assert(isa<CXXDynamicCastExpr>(E) && "CK_Dynamic without a dynamic_cast?");
@@ -270,6 +265,8 @@
}
case CK_ToUnion: {
+ if (Dest.isIgnored()) break;
+
// GCC union extension
QualType Ty = E->getSubExpr()->getType();
QualType PtrTy = CGF.getContext().getPointerType(Ty);
Modified: cfe/trunk/test/CodeGenObjC/property-agrr-getter.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property-agrr-getter.m?rev=129397&r1=129396&r2=129397&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/property-agrr-getter.m (original)
+++ cfe/trunk/test/CodeGenObjC/property-agrr-getter.m Tue Apr 12 17:02:02 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -emit-llvm-only %s
typedef struct {
unsigned f0;
@@ -36,3 +36,9 @@
AnObject* obj;
return (obj.size).width;
}
+
+// rdar://problem/9272392
+void test3(AnObject *obj) {
+ obj.size;
+ (void) obj.size;
+}
More information about the cfe-commits
mailing list