[cfe-commits] r161014 - in /cfe/trunk: lib/CodeGen/CGCall.cpp lib/CodeGen/CGVTables.cpp test/CodeGenObjCXX/arc.mm
John McCall
rjmccall at apple.com
Mon Jul 30 17:33:55 PDT 2012
Author: rjmccall
Date: Mon Jul 30 19:33:55 2012
New Revision: 161014
URL: http://llvm.org/viewvc/llvm-project?rev=161014&view=rev
Log:
Don't crash *or* insert a bogus autorelease when emitting a
this-adjustment thunk in ARC++.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenObjCXX/arc.mm
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=161014&r1=161013&r2=161014&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jul 30 19:33:55 2012
@@ -1405,7 +1405,8 @@
static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF,
llvm::Value *result) {
// This is only applicable to a method with an immutable 'self'.
- const ObjCMethodDecl *method = dyn_cast<ObjCMethodDecl>(CGF.CurCodeDecl);
+ const ObjCMethodDecl *method =
+ dyn_cast_or_null<ObjCMethodDecl>(CGF.CurCodeDecl);
if (!method) return 0;
const VarDecl *self = method->getSelfDecl();
if (!self->getType().isConstQualified()) return 0;
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=161014&r1=161013&r2=161014&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Mon Jul 30 19:33:55 2012
@@ -387,6 +387,9 @@
if (!ResultType->isVoidType() && Slot.isNull())
CGM.getCXXABI().EmitReturnFromThunk(*this, RV, ResultType);
+ // Disable the final ARC autorelease.
+ AutoreleaseResult = false;
+
FinishFunction();
// Set the right linkage.
Modified: cfe/trunk/test/CodeGenObjCXX/arc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc.mm?rev=161014&r1=161013&r2=161014&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/arc.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc.mm Mon Jul 30 19:33:55 2012
@@ -252,3 +252,19 @@
};
// CHECK: define weak_odr void @_ZN6Test38IiE4testEi(
template class Test38<int>;
+
+// rdar://problem/11964832
+class Test39_base1 {
+ virtual void foo();
+};
+class Test39_base2 {
+ virtual id bar();
+};
+class Test39 : Test39_base1, Test39_base2 { // base2 is at non-zero offset
+ virtual id bar();
+};
+id Test39::bar() { return 0; }
+// Note lack of autorelease.
+// CHECK: define i8* @_ZThn8_N6Test393barEv(
+// CHECK: call i8* @_ZN6Test393barEv(
+// CHECK-NEXT: ret i8*
More information about the cfe-commits
mailing list