From ff755cda9c624dd807360bf09717e808dff1665a Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 31 Jul 2012 00:33:55 +0000 Subject: Don't crash *or* insert a bogus autorelease when emitting a this-adjustment thunk in ARC++. llvm-svn: 161014 --- clang/lib/CodeGen/CGCall.cpp | 3 ++- clang/lib/CodeGen/CGVTables.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 37a9a5eaff0..9deec19bf80 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1405,7 +1405,8 @@ static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, 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(CGF.CurCodeDecl); + const ObjCMethodDecl *method = + dyn_cast_or_null(CGF.CurCodeDecl); if (!method) return 0; const VarDecl *self = method->getSelfDecl(); if (!self->getType().isConstQualified()) return 0; diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 3c0dd5d56b5..cdaa26a2bad 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -387,6 +387,9 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, if (!ResultType->isVoidType() && Slot.isNull()) CGM.getCXXABI().EmitReturnFromThunk(*this, RV, ResultType); + // Disable the final ARC autorelease. + AutoreleaseResult = false; + FinishFunction(); // Set the right linkage. -- cgit v1.2.3