[cfe-commits] r144144 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenObjC/property.m
John McCall
rjmccall at apple.com
Tue Nov 8 14:54:08 PST 2011
Author: rjmccall
Date: Tue Nov 8 16:54:08 2011
New Revision: 144144
URL: http://llvm.org/viewvc/llvm-project?rev=144144&view=rev
Log:
Bind function "r-values" as l-values when emitting them as
opaque values. Silly C type system.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenObjC/property.m
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=144144&r1=144143&r2=144144&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Nov 8 16:54:08 2011
@@ -2137,7 +2137,7 @@
}
LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) {
- assert(e->isGLValue() || e->getType()->isRecordType());
+ assert(OpaqueValueMappingData::shouldBindAsLValue(e));
return getOpaqueLValueMapping(e);
}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=144144&r1=144143&r2=144144&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Nov 8 16:54:08 2011
@@ -970,7 +970,14 @@
OpaqueValueMappingData() : OpaqueValue(0) {}
static bool shouldBindAsLValue(const Expr *expr) {
- return expr->isGLValue() || expr->getType()->isRecordType();
+ // gl-values should be bound as l-values for obvious reasons.
+ // Records should be bound as l-values because IR generation
+ // always keeps them in memory. Expressions of function type
+ // act exactly like l-values but are formally required to be
+ // r-values in C.
+ return expr->isGLValue() ||
+ expr->getType()->isRecordType() ||
+ expr->getType()->isFunctionType();
}
static OpaqueValueMappingData bind(CodeGenFunction &CGF,
Modified: cfe/trunk/test/CodeGenObjC/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property.m?rev=144144&r1=144143&r2=144144&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/property.m (original)
+++ cfe/trunk/test/CodeGenObjC/property.m Tue Nov 8 16:54:08 2011
@@ -112,3 +112,14 @@
@implementation Test5
@synthesize x = _x;
@end
+
+// rdar://problem/10410531
+ at interface Test6
+ at property void (*prop)(void);
+ at end
+
+void test6_func(void);
+void test6(Test6 *a) {
+ a.prop = test6_func;
+}
+
More information about the cfe-commits
mailing list