diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2015-04-09 18:36:50 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2015-04-09 18:36:50 +0000 |
commit | f8e68e230b7351d39ded3edbdadb374ed4bfb5ae (patch) | |
tree | 062cd17b8ab4e0091a5befc36eb108f1e4901e45 /clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp | |
parent | 49286e9f4a3bf3b78ff45003d36722a4b4d9d039 (diff) | |
download | bcm5719-llvm-f8e68e230b7351d39ded3edbdadb374ed4bfb5ae.tar.gz bcm5719-llvm-f8e68e230b7351d39ded3edbdadb374ed4bfb5ae.zip |
[Objective-C modern translation]. Patch to fix type of
objc_msgSend's first argument to "Class" because
objc_getClass is passed. rdar://20477025
llvm-svn: 234520
Diffstat (limited to 'clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp')
-rw-r--r-- | clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp | 194 |
1 files changed, 97 insertions, 97 deletions
diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index 12c57cdced7..92ca1acfde1 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -886,15 +886,15 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) { FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get(D->getNameAsString()), - IvarT, nullptr,
- /*BitWidth=*/nullptr, /*Mutable=*/true,
- ICIS_NoInit);
- MemberExpr *ME = new (Context)
- MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
- FD->getType(), VK_LValue, OK_Ordinary);
- IvarT = Context->getDecltypeType(ME, ME->getType());
- }
- }
+ IvarT, nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/true, + ICIS_NoInit); + MemberExpr *ME = new (Context) + MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(), + FD->getType(), VK_LValue, OK_Ordinary); + IvarT = Context->getDecltypeType(ME, ME->getType()); + } + } convertObjCTypeToCStyleType(IvarT); QualType castT = Context->getPointerType(IvarT); std::string TypeString(castT.getAsString(Context->getPrintingPolicy())); @@ -2689,7 +2689,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) { MsgExprs.push_back(subExpr); SmallVector<QualType, 4> ArgTypes; - ArgTypes.push_back(Context->getObjCIdType()); + ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); for (const auto PI : BoxingMethod->parameters()) ArgTypes.push_back(PI->getType()); @@ -2764,15 +2764,15 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) { FieldDecl *ARRFD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get("arr"), - Context->getPointerType(Context->VoidPtrTy),
- nullptr, /*BitWidth=*/nullptr,
- /*Mutable=*/true, ICIS_NoInit);
- MemberExpr *ArrayLiteralME = new (Context)
- MemberExpr(NSArrayCallExpr, false, SourceLocation(), ARRFD,
- SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);
- QualType ConstIdT = Context->getObjCIdType().withConst();
- CStyleCastExpr * ArrayLiteralObjects =
- NoTypeInfoCStyleCastExpr(Context,
+ Context->getPointerType(Context->VoidPtrTy), + nullptr, /*BitWidth=*/nullptr, + /*Mutable=*/true, ICIS_NoInit); + MemberExpr *ArrayLiteralME = new (Context) + MemberExpr(NSArrayCallExpr, false, SourceLocation(), ARRFD, + SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary); + QualType ConstIdT = Context->getObjCIdType().withConst(); + CStyleCastExpr * ArrayLiteralObjects = + NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(ConstIdT), CK_BitCast, ArrayLiteralME); @@ -2816,7 +2816,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) { SmallVector<QualType, 4> ArgTypes; - ArgTypes.push_back(Context->getObjCIdType()); + ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); for (const auto *PI : ArrayMethod->params()) ArgTypes.push_back(PI->getType()); @@ -2899,30 +2899,30 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral FieldDecl *ARRFD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get("arr"), - Context->getPointerType(Context->VoidPtrTy),
- nullptr, /*BitWidth=*/nullptr,
- /*Mutable=*/true, ICIS_NoInit);
- MemberExpr *DictLiteralValueME = new (Context)
- MemberExpr(NSValueCallExpr, false, SourceLocation(), ARRFD,
- SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);
- QualType ConstIdT = Context->getObjCIdType().withConst();
- CStyleCastExpr * DictValueObjects =
- NoTypeInfoCStyleCastExpr(Context,
+ Context->getPointerType(Context->VoidPtrTy), + nullptr, /*BitWidth=*/nullptr, + /*Mutable=*/true, ICIS_NoInit); + MemberExpr *DictLiteralValueME = new (Context) + MemberExpr(NSValueCallExpr, false, SourceLocation(), ARRFD, + SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary); + QualType ConstIdT = Context->getObjCIdType().withConst(); + CStyleCastExpr * DictValueObjects = + NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(ConstIdT), CK_BitCast, DictLiteralValueME); // (const id <NSCopying> [])keys - Expr *NSKeyCallExpr =
- new (Context) CallExpr(*Context, NSDictDRE, KeyExprs,
- NSDictFType, VK_LValue, SourceLocation());
-
- MemberExpr *DictLiteralKeyME = new (Context)
- MemberExpr(NSKeyCallExpr, false, SourceLocation(), ARRFD,
- SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);
-
- CStyleCastExpr * DictKeyObjects =
- NoTypeInfoCStyleCastExpr(Context,
- Context->getPointerType(ConstIdT),
+ Expr *NSKeyCallExpr = + new (Context) CallExpr(*Context, NSDictDRE, KeyExprs, + NSDictFType, VK_LValue, SourceLocation()); + + MemberExpr *DictLiteralKeyME = new (Context) + MemberExpr(NSKeyCallExpr, false, SourceLocation(), ARRFD, + SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary); + + CStyleCastExpr * DictKeyObjects = + NoTypeInfoCStyleCastExpr(Context, + Context->getPointerType(ConstIdT), CK_BitCast, DictLiteralKeyME); @@ -2969,7 +2969,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral SmallVector<QualType, 8> ArgTypes; - ArgTypes.push_back(Context->getObjCIdType()); + ArgTypes.push_back(Context->getObjCClassType()); ArgTypes.push_back(Context->getObjCSelType()); for (const auto *PI : DictMethod->params()) { QualType T = PI->getType(); @@ -3225,15 +3225,15 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla FieldDecl *FieldD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get("s"), - returnType, nullptr,
- /*BitWidth=*/nullptr,
- /*Mutable=*/true, ICIS_NoInit);
- MemberExpr *ME = new (Context)
- MemberExpr(STCE, false, SourceLocation(), FieldD, SourceLocation(),
- FieldD->getType(), VK_LValue, OK_Ordinary);
-
- return ME;
-}
+ returnType, nullptr, + /*BitWidth=*/nullptr, + /*Mutable=*/true, ICIS_NoInit); + MemberExpr *ME = new (Context) + MemberExpr(STCE, false, SourceLocation(), FieldD, SourceLocation(), + FieldD->getType(), VK_LValue, OK_Ordinary); + + return ME; +} Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SourceLocation StartLoc, @@ -4723,16 +4723,16 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get("FuncPtr"), - Context->VoidPtrTy, nullptr,
- /*BitWidth=*/nullptr, /*Mutable=*/true,
- ICIS_NoInit);
- MemberExpr *ME =
- new (Context) MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
- FD->getType(), VK_LValue, OK_Ordinary);
-
- CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,
- CK_BitCast, ME);
- PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast);
+ Context->VoidPtrTy, nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/true, + ICIS_NoInit); + MemberExpr *ME = + new (Context) MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(), + FD->getType(), VK_LValue, OK_Ordinary); + + CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType, + CK_BitCast, ME); + PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast); SmallVector<Expr*, 8> BlkExprs; // Add the implicit argument. @@ -4771,26 +4771,26 @@ Stmt *RewriteModernObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) { FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get("__forwarding"), - Context->VoidPtrTy, nullptr,
- /*BitWidth=*/nullptr, /*Mutable=*/true,
- ICIS_NoInit);
- MemberExpr *ME = new (Context)
- MemberExpr(DeclRefExp, isArrow, SourceLocation(), FD, SourceLocation(),
- FD->getType(), VK_LValue, OK_Ordinary);
-
- StringRef Name = VD->getName();
- FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(),
+ Context->VoidPtrTy, nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/true, + ICIS_NoInit); + MemberExpr *ME = new (Context) + MemberExpr(DeclRefExp, isArrow, SourceLocation(), FD, SourceLocation(), + FD->getType(), VK_LValue, OK_Ordinary); + + StringRef Name = VD->getName(); + FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get(Name), - Context->VoidPtrTy, nullptr,
- /*BitWidth=*/nullptr, /*Mutable=*/true,
- ICIS_NoInit);
- ME =
- new (Context) MemberExpr(ME, true, SourceLocation(), FD, SourceLocation(),
- DeclRefExp->getType(), VK_LValue, OK_Ordinary);
-
- // Need parens to enforce precedence.
- ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(),
- DeclRefExp->getExprLoc(),
+ Context->VoidPtrTy, nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/true, + ICIS_NoInit); + ME = + new (Context) MemberExpr(ME, true, SourceLocation(), FD, SourceLocation(), + DeclRefExp->getType(), VK_LValue, OK_Ordinary); + + // Need parens to enforce precedence. + ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(), + DeclRefExp->getExprLoc(), ME); ReplaceStmt(DeclRefExp, PE); return PE; @@ -7682,15 +7682,15 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get(D->getNameAsString()), - IvarT, nullptr,
- /*BitWidth=*/nullptr,
- /*Mutable=*/true, ICIS_NoInit);
- MemberExpr *ME = new (Context)
- MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
- FD->getType(), VK_LValue, OK_Ordinary);
- IvarT = Context->getDecltypeType(ME, ME->getType());
- }
- }
+ IvarT, nullptr, + /*BitWidth=*/nullptr, + /*Mutable=*/true, ICIS_NoInit); + MemberExpr *ME = new (Context) + MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(), + FD->getType(), VK_LValue, OK_Ordinary); + IvarT = Context->getDecltypeType(ME, ME->getType()); + } + } convertObjCTypeToCStyleType(IvarT); QualType castT = Context->getPointerType(IvarT); @@ -7711,15 +7711,15 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(), &Context->Idents.get(D->getNameAsString()), - D->getType(), nullptr,
- /*BitWidth=*/D->getBitWidth(),
- /*Mutable=*/true, ICIS_NoInit);
- MemberExpr *ME = new (Context)
- MemberExpr(PE, /*isArrow*/ false, SourceLocation(), FD,
- SourceLocation(), FD->getType(), VK_LValue, OK_Ordinary);
- Replacement = ME;
-
- }
+ D->getType(), nullptr, + /*BitWidth=*/D->getBitWidth(), + /*Mutable=*/true, ICIS_NoInit); + MemberExpr *ME = new (Context) + MemberExpr(PE, /*isArrow*/ false, SourceLocation(), FD, + SourceLocation(), FD->getType(), VK_LValue, OK_Ordinary); + Replacement = ME; + + } else Replacement = PE; } |