diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp | 99 |
1 files changed, 44 insertions, 55 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index 9d5366bb161e..fd54bcbf7c35 100644 --- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -585,7 +585,7 @@ namespace { CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty, CastKind Kind, Expr *E) { TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation()); - return CStyleCastExpr::Create(*Ctx, Ty, VK_RValue, Kind, E, nullptr, + return CStyleCastExpr::Create(*Ctx, Ty, VK_PRValue, Kind, E, nullptr, FPOptionsOverride(), TInfo, SourceLocation(), SourceLocation()); } @@ -2107,12 +2107,12 @@ RewriteModernObjC::SynthesizeCallToFunctionDecl(FunctionDecl *FD, QualType pToFunc = Context->getPointerType(msgSendType); ImplicitCastExpr *ICE = ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay, - DRE, nullptr, VK_RValue, FPOptionsOverride()); + DRE, nullptr, VK_PRValue, FPOptionsOverride()); const auto *FT = msgSendType->castAs<FunctionType>(); CallExpr *Exp = CallExpr::Create(*Context, ICE, Args, FT->getCallResultType(*Context), - VK_RValue, EndLoc, FPOptionsOverride()); + VK_PRValue, EndLoc, FPOptionsOverride()); return Exp; } @@ -2591,7 +2591,7 @@ Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation()); Expr *Unop = UnaryOperator::Create( const_cast<ASTContext &>(*Context), DRE, UO_AddrOf, - Context->getPointerType(DRE->getType()), VK_RValue, OK_Ordinary, + Context->getPointerType(DRE->getType()), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); // cast to NSConstantString * CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(), @@ -2694,7 +2694,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) { auto *FT = msgSendType->castAs<FunctionType>(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), - VK_RValue, EndLoc, FPOptionsOverride()); + VK_PRValue, EndLoc, FPOptionsOverride()); ReplaceStmt(Exp, CE); return CE; } @@ -2720,7 +2720,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) { std::string NSArrayFName("__NSContainer_literal"); FunctionDecl *NSArrayFD = SynthBlockInitFunctionDecl(NSArrayFName); DeclRefExpr *NSArrayDRE = new (Context) DeclRefExpr( - *Context, NSArrayFD, false, NSArrayFType, VK_RValue, SourceLocation()); + *Context, NSArrayFD, false, NSArrayFType, VK_PRValue, SourceLocation()); SmallVector<Expr*, 16> InitExprs; unsigned NumElements = Exp->getNumElements(); @@ -2815,7 +2815,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) { const FunctionType *FT = msgSendType->castAs<FunctionType>(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), - VK_RValue, EndLoc, FPOptionsOverride()); + VK_PRValue, EndLoc, FPOptionsOverride()); ReplaceStmt(Exp, CE); return CE; } @@ -2841,7 +2841,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral std::string NSDictFName("__NSContainer_literal"); FunctionDecl *NSDictFD = SynthBlockInitFunctionDecl(NSDictFName); DeclRefExpr *NSDictDRE = new (Context) DeclRefExpr( - *Context, NSDictFD, false, NSDictFType, VK_RValue, SourceLocation()); + *Context, NSDictFD, false, NSDictFType, VK_PRValue, SourceLocation()); SmallVector<Expr*, 16> KeyExprs; SmallVector<Expr*, 16> ValueExprs; @@ -2967,7 +2967,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral const FunctionType *FT = msgSendType->castAs<FunctionType>(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), - VK_RValue, EndLoc, FPOptionsOverride()); + VK_PRValue, EndLoc, FPOptionsOverride()); ReplaceStmt(Exp, CE); return CE; } @@ -3177,7 +3177,7 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), ID, FuncType, nullptr, SC_Extern, false, false); DeclRefExpr *DRE = new (Context) - DeclRefExpr(*Context, FD, false, castType, VK_RValue, SourceLocation()); + DeclRefExpr(*Context, FD, false, castType, VK_PRValue, SourceLocation()); CallExpr *STCE = CallExpr::Create(*Context, DRE, MsgExprs, castType, VK_LValue, SourceLocation(), FPOptionsOverride()); @@ -3242,16 +3242,11 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SmallVector<Expr*, 4> InitExprs; // set the receiver to self, the first argument to all methods. - InitExprs.push_back( - NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CK_BitCast, - new (Context) DeclRefExpr(*Context, - CurMethodDef->getSelfDecl(), - false, - Context->getObjCIdType(), - VK_RValue, - SourceLocation())) - ); // set the 'receiver'. + InitExprs.push_back(NoTypeInfoCStyleCastExpr( + Context, Context->getObjCIdType(), CK_BitCast, + new (Context) DeclRefExpr(*Context, CurMethodDef->getSelfDecl(), false, + Context->getObjCIdType(), VK_PRValue, + SourceLocation()))); // set the 'receiver'. // (id)class_getSuperclass((Class)objc_getClass("CurrentClass")) SmallVector<Expr*, 8> ClsExprs; @@ -3291,7 +3286,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // SuperRep = UnaryOperator::Create( const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf, - Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary, + Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); SuperRep = NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(superType), @@ -3309,7 +3304,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // struct __rw_objc_super * SuperRep = UnaryOperator::Create( const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf, - Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary, + Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); } MsgExprs.push_back(SuperRep); @@ -3339,15 +3334,11 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface(); SmallVector<Expr*, 4> InitExprs; - InitExprs.push_back( - NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CK_BitCast, - new (Context) DeclRefExpr(*Context, - CurMethodDef->getSelfDecl(), - false, - Context->getObjCIdType(), - VK_RValue, SourceLocation())) - ); // set the 'receiver'. + InitExprs.push_back(NoTypeInfoCStyleCastExpr( + Context, Context->getObjCIdType(), CK_BitCast, + new (Context) DeclRefExpr(*Context, CurMethodDef->getSelfDecl(), false, + Context->getObjCIdType(), VK_PRValue, + SourceLocation()))); // set the 'receiver'. // (id)class_getSuperclass((Class)objc_getClass("CurrentClass")) SmallVector<Expr*, 8> ClsExprs; @@ -3387,7 +3378,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // SuperRep = UnaryOperator::Create( const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf, - Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary, + Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); SuperRep = NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(superType), @@ -3399,9 +3390,8 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SourceLocation()); TypeSourceInfo *superTInfo = Context->getTrivialTypeSourceInfo(superType); - SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo, - superType, VK_RValue, ILE, - false); + SuperRep = new (Context) CompoundLiteralExpr( + SourceLocation(), superTInfo, superType, VK_PRValue, ILE, false); } MsgExprs.push_back(SuperRep); break; @@ -3543,7 +3533,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp, const FunctionType *FT = msgSendType->castAs<FunctionType>(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), - VK_RValue, EndLoc, FPOptionsOverride()); + VK_PRValue, EndLoc, FPOptionsOverride()); Stmt *ReplacingStmt = CE; if (MsgSendStretFlavor) { // We have the method which returns a struct/union. Must also generate @@ -3684,8 +3674,7 @@ bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type, Result += " {\n"; for (const auto *EC : ED->enumerators()) { Result += "\t"; Result += EC->getName(); Result += " = "; - llvm::APSInt Val = EC->getInitVal(); - Result += Val.toString(10); + Result += toString(EC->getInitVal(), 10); Result += ",\n"; } Result += "\t} "; @@ -4580,11 +4569,9 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp Expr *RHSExp = CEXPR->getRHS(); Stmt *RHSStmt = SynthesizeBlockCall(Exp, RHSExp); Expr *CONDExp = CEXPR->getCond(); - ConditionalOperator *CondExpr = - new (Context) ConditionalOperator(CONDExp, - SourceLocation(), cast<Expr>(LHSStmt), - SourceLocation(), cast<Expr>(RHSStmt), - Exp->getType(), VK_RValue, OK_Ordinary); + ConditionalOperator *CondExpr = new (Context) ConditionalOperator( + CONDExp, SourceLocation(), cast<Expr>(LHSStmt), SourceLocation(), + cast<Expr>(RHSStmt), Exp->getType(), VK_PRValue, OK_Ordinary); return CondExpr; } else if (const ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(BlockExp)) { CPT = IRE->getType()->getAs<BlockPointerType>(); @@ -4654,7 +4641,7 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp BlkExprs.push_back(*I); } CallExpr *CE = - CallExpr::Create(*Context, PE, BlkExprs, Exp->getType(), VK_RValue, + CallExpr::Create(*Context, PE, BlkExprs, Exp->getType(), VK_PRValue, SourceLocation(), FPOptionsOverride()); return CE; } @@ -5283,7 +5270,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, FD = SynthBlockInitFunctionDecl(Tag); DeclRefExpr *DRE = new (Context) - DeclRefExpr(*Context, FD, false, FType, VK_RValue, SourceLocation()); + DeclRefExpr(*Context, FD, false, FType, VK_PRValue, SourceLocation()); SmallVector<Expr*, 4> InitExprs; @@ -5305,7 +5292,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, const_cast<ASTContext &>(*Context), new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy, VK_LValue, SourceLocation()), - UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), VK_RValue, + UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); InitExprs.push_back(DescRefExpr); @@ -5323,9 +5310,10 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, if (HasLocalVariableExternalStorage(*I)) { QualType QT = (*I)->getType(); QT = Context->getPointerType(QT); - Exp = UnaryOperator::Create( - const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, QT, VK_RValue, - OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); + Exp = UnaryOperator::Create(const_cast<ASTContext &>(*Context), Exp, + UO_AddrOf, QT, VK_PRValue, OK_Ordinary, + SourceLocation(), false, + FPOptionsOverride()); } } else if (isTopLevelBlockPointerType((*I)->getType())) { FD = SynthBlockInitFunctionDecl((*I)->getName()); @@ -5340,9 +5328,10 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, if (HasLocalVariableExternalStorage(*I)) { QualType QT = (*I)->getType(); QT = Context->getPointerType(QT); - Exp = UnaryOperator::Create( - const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, QT, VK_RValue, - OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); + Exp = UnaryOperator::Create(const_cast<ASTContext &>(*Context), Exp, + UO_AddrOf, QT, VK_PRValue, OK_Ordinary, + SourceLocation(), false, + FPOptionsOverride()); } } @@ -5382,7 +5371,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, if (!isNestedCapturedVar) Exp = UnaryOperator::Create( const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, - Context->getPointerType(Exp->getType()), VK_RValue, OK_Ordinary, + Context->getPointerType(Exp->getType()), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_BitCast, Exp); InitExprs.push_back(Exp); @@ -5409,7 +5398,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, NewRep = UnaryOperator::Create( const_cast<ASTContext &>(*Context), NewRep, UO_AddrOf, - Context->getPointerType(NewRep->getType()), VK_RValue, OK_Ordinary, + Context->getPointerType(NewRep->getType()), VK_PRValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_BitCast, NewRep); @@ -7497,7 +7486,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { VK_LValue, SourceLocation()); BinaryOperator *addExpr = BinaryOperator::Create( *Context, castExpr, DRE, BO_Add, - Context->getPointerType(Context->CharTy), VK_RValue, OK_Ordinary, + Context->getPointerType(Context->CharTy), VK_PRValue, OK_Ordinary, SourceLocation(), FPOptionsOverride()); // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), |