diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-07 17:17:45 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-07 17:17:45 +0000 |
commit | baac1ea9e06985fceff856398655c6dfdab8c85c (patch) | |
tree | 251bf51fc9ed98e29fb40bc5319ac0a680085755 /lib/Rewrite/RewriteObjC.cpp | |
parent | 5e1cdac63c3d9c9b32fa41fa0b2d242a58a20d49 (diff) |
objc rewriter. Fix declaration of objc_msgSend_stret/objc_msgSendSuper_stret.
Fix an assert crash when casting a CF type to 'id'.
// rdar://10250911
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141369 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 0d83e8c975..ab3b69002c 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -610,9 +610,9 @@ void RewriteObjC::Initialize(ASTContext &context) { Preamble += "(struct objc_object *, struct objc_selector *, ...);\n"; Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper"; Preamble += "(struct objc_super *, struct objc_selector *, ...);\n"; - Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSend_stret"; + Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSend_stret"; Preamble += "(struct objc_object *, struct objc_selector *, ...);\n"; - Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper_stret"; + Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSendSuper_stret"; Preamble += "(struct objc_super *, struct objc_selector *, ...);\n"; Preamble += "__OBJC_RW_DLLIMPORT double objc_msgSend_fpret"; Preamble += "(struct objc_object *, struct objc_selector *, ...);\n"; @@ -2566,7 +2566,7 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() { SC_None, false); } -// SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...); +// SynthMsgSendStretFunctionDecl - void objc_msgSend_stret(id self, SEL op, ...); void RewriteObjC::SynthMsgSendStretFunctionDecl() { IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSend_stret"); SmallVector<QualType, 16> ArgTys; @@ -2576,7 +2576,7 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + QualType msgSendType = getSimpleFunctionType(Context->VoidTy, &ArgTys[0], ArgTys.size(), true /*isVariadic*/); MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, @@ -2588,7 +2588,7 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() { } // SynthMsgSendSuperStretFunctionDecl - -// id objc_msgSendSuper_stret(struct objc_super *, SEL op, ...); +// void objc_msgSendSuper_stret(struct objc_super *, SEL op, ...); void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper_stret"); @@ -2602,7 +2602,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { argT = Context->getObjCSelType(); assert(!argT.isNull() && "Can't find 'SEL' type"); ArgTys.push_back(argT); - QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), + QualType msgSendType = getSimpleFunctionType(Context->VoidTy, &ArgTys[0], ArgTys.size(), true /*isVariadic*/); MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, @@ -3032,8 +3032,13 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Expr *recExpr = Exp->getInstanceReceiver(); while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr)) recExpr = CE->getSubExpr(); + CastKind CK = recExpr->getType()->isObjCObjectPointerType() + ? CK_BitCast : recExpr->getType()->isBlockPointerType() + ? CK_BlockPointerToObjCPointerCast + : CK_CPointerToObjCPointerCast; + recExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CK_BitCast, recExpr); + CK, recExpr); MsgExprs.push_back(recExpr); break; } |