Skip to content

Commit 942bbce

Browse files
author
Fariborz Jahanian
committed
objc rewriter. Fix declaration of objc_msgSend_stret/objc_msgSendSuper_stret.
Fix an assert crash when casting a CF type to 'id'. // rdar://10250911 llvm-svn: 141369
1 parent bc15899 commit 942bbce

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

clang/lib/Rewrite/RewriteObjC.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,9 @@ void RewriteObjC::Initialize(ASTContext &context) {
610610
Preamble += "(struct objc_object *, struct objc_selector *, ...);\n";
611611
Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper";
612612
Preamble += "(struct objc_super *, struct objc_selector *, ...);\n";
613-
Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSend_stret";
613+
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSend_stret";
614614
Preamble += "(struct objc_object *, struct objc_selector *, ...);\n";
615-
Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper_stret";
615+
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSendSuper_stret";
616616
Preamble += "(struct objc_super *, struct objc_selector *, ...);\n";
617617
Preamble += "__OBJC_RW_DLLIMPORT double objc_msgSend_fpret";
618618
Preamble += "(struct objc_object *, struct objc_selector *, ...);\n";
@@ -2566,7 +2566,7 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
25662566
SC_None, false);
25672567
}
25682568

2569-
// SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...);
2569+
// SynthMsgSendStretFunctionDecl - void objc_msgSend_stret(id self, SEL op, ...);
25702570
void RewriteObjC::SynthMsgSendStretFunctionDecl() {
25712571
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSend_stret");
25722572
SmallVector<QualType, 16> ArgTys;
@@ -2576,7 +2576,7 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() {
25762576
argT = Context->getObjCSelType();
25772577
assert(!argT.isNull() && "Can't find 'SEL' type");
25782578
ArgTys.push_back(argT);
2579-
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
2579+
QualType msgSendType = getSimpleFunctionType(Context->VoidTy,
25802580
&ArgTys[0], ArgTys.size(),
25812581
true /*isVariadic*/);
25822582
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
@@ -2588,7 +2588,7 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() {
25882588
}
25892589

25902590
// SynthMsgSendSuperStretFunctionDecl -
2591-
// id objc_msgSendSuper_stret(struct objc_super *, SEL op, ...);
2591+
// void objc_msgSendSuper_stret(struct objc_super *, SEL op, ...);
25922592
void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
25932593
IdentifierInfo *msgSendIdent =
25942594
&Context->Idents.get("objc_msgSendSuper_stret");
@@ -2602,7 +2602,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
26022602
argT = Context->getObjCSelType();
26032603
assert(!argT.isNull() && "Can't find 'SEL' type");
26042604
ArgTys.push_back(argT);
2605-
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
2605+
QualType msgSendType = getSimpleFunctionType(Context->VoidTy,
26062606
&ArgTys[0], ArgTys.size(),
26072607
true /*isVariadic*/);
26082608
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
@@ -3032,8 +3032,13 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
30323032
Expr *recExpr = Exp->getInstanceReceiver();
30333033
while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr))
30343034
recExpr = CE->getSubExpr();
3035+
CastKind CK = recExpr->getType()->isObjCObjectPointerType()
3036+
? CK_BitCast : recExpr->getType()->isBlockPointerType()
3037+
? CK_BlockPointerToObjCPointerCast
3038+
: CK_CPointerToObjCPointerCast;
3039+
30353040
recExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
3036-
CK_BitCast, recExpr);
3041+
CK, recExpr);
30373042
MsgExprs.push_back(recExpr);
30383043
break;
30393044
}

0 commit comments

Comments
 (0)