r179254 - Drop ObjCIndirectCopyRestoreExprs during template instantiation.
John McCall
rjmccall at apple.com
Wed Apr 10 19:14:26 PDT 2013
Author: rjmccall
Date: Wed Apr 10 21:14:26 2013
New Revision: 179254
URL: http://llvm.org/viewvc/llvm-project?rev=179254&view=rev
Log:
Drop ObjCIndirectCopyRestoreExprs during template instantiation.
It's a kind of implicit conversion, which we generally drop, but
more importantly it's got very specific placement requirements.
rdar://13617051
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CodeGenObjCXX/arc.mm
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=179254&r1=179253&r2=179254&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Apr 10 21:14:26 2013
@@ -8608,16 +8608,11 @@ TreeTransform<Derived>::TransformObjCEnc
template<typename Derived>
ExprResult TreeTransform<Derived>::
TransformObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
- ExprResult result = getDerived().TransformExpr(E->getSubExpr());
- if (result.isInvalid()) return ExprError();
- Expr *subExpr = result.take();
-
- if (!getDerived().AlwaysRebuild() &&
- subExpr == E->getSubExpr())
- return SemaRef.Owned(E);
-
- return SemaRef.Owned(new(SemaRef.Context)
- ObjCIndirectCopyRestoreExpr(subExpr, E->getType(), E->shouldCopy()));
+ // This is a kind of implicit conversion, and it needs to get dropped
+ // and recomputed for the same general reasons that ImplicitCastExprs
+ // do, as well a more specific one: this expression is only valid when
+ // it appears *immediately* as an argument expression.
+ return getDerived().TransformExpr(E->getSubExpr());
}
template<typename Derived>
Modified: cfe/trunk/test/CodeGenObjCXX/arc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc.mm?rev=179254&r1=179253&r2=179254&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/arc.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc.mm Wed Apr 10 21:14:26 2013
@@ -275,3 +275,25 @@ id Test39::bar() { return 0; }
// CHECK: define i8* @_ZThn8_N6Test393barEv(
// CHECK: call i8* @_ZN6Test393barEv(
// CHECK-NEXT: ret i8*
+
+// rdar://13617051
+// Just a basic sanity-check that IR-gen still works after instantiating
+// a non-dependent message send that requires writeback.
+ at interface Test40
++ (void) foo:(id *)errorPtr;
+ at end
+template <class T> void test40_helper() {
+ id x;
+ [Test40 foo: &x];
+};
+template void test40_helper<int>();
+// CHECK: define weak_odr void @_Z13test40_helperIiEvv()
+// CHECK: [[X:%.*]] = alloca i8*
+// CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
+// CHECK-NEXT: store i8* null, i8** [[X]]
+// CHECK: [[T0:%.*]] = load i8** [[X]]
+// CHECK-NEXT: store i8* [[T0]], i8** [[TEMP]]
+// CHECK: @objc_msgSend
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[TEMP]]
+// CHECK-NEXT: call i8* @objc_retain(i8* [[T0]])
+
More information about the cfe-commits
mailing list