[IRGen] Handle 'super' method sends in ObjC partial application forwarders.

The Objective-C partial application forwarder that one gets when
using, e.g., "super.foo" as a function value was doing a normal
objc_msgSend. Fix the miscompile by threading all of the information
about the Objective-C message send through the forwarder.

Fixes rdar://problem/28140758.
This commit is contained in:
Doug Gregor
2016-09-14 14:17:06 -07:00
parent 644dfc1b81
commit ab70291b82
4 changed files with 65 additions and 37 deletions

View File

@@ -786,7 +786,7 @@ llvm::Value *irgen::emitObjCAllocObjectCall(IRGenFunction &IGF,
}
static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
SILDeclRef method,
ObjCMethod method,
CanSILFunctionType origMethodType,
CanSILFunctionType resultType,
const HeapLayout &layout,
@@ -884,10 +884,12 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
}
// Prepare the call to the underlying method.
CallEmission emission
= prepareObjCMethodRootCall(subIGF, method, origMethodType, origMethodType,
= prepareObjCMethodRootCall(subIGF, method.getMethod(),
origMethodType, origMethodType,
ArrayRef<Substitution>{},
ObjCMessageKind::Normal);
method.getMessageKind());
Explosion args;
@@ -895,7 +897,8 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
if (formalIndirectResult)
args.add(formalIndirectResult);
addObjCMethodCallImplicitArguments(subIGF, args, method, self, SILType());
addObjCMethodCallImplicitArguments(subIGF, args, method.getMethod(), self,
method.getSearchType());
args.add(params.claimAll());
emission.setArgs(args);
@@ -930,7 +933,7 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
}
void irgen::emitObjCPartialApplication(IRGenFunction &IGF,
SILDeclRef method,
ObjCMethod method,
CanSILFunctionType origMethodType,
CanSILFunctionType resultType,
llvm::Value *self,