diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 134 |
1 files changed, 61 insertions, 73 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index 543b3b09a9cc..bf5176a2b6fb 100644 --- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -491,7 +491,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()); } @@ -499,8 +499,8 @@ namespace { StringLiteral *getStringLiteral(StringRef Str) { QualType StrType = Context->getConstantArrayType( Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr, - ArrayType::Normal, 0); - return StringLiteral::Create(*Context, Str, StringLiteral::Ascii, + ArraySizeModifier::Normal, 0); + return StringLiteral::Create(*Context, Str, StringLiteralKind::Ordinary, /*Pascal=*/false, StrType, SourceLocation()); } }; @@ -569,7 +569,7 @@ static bool IsHeaderFile(const std::string &Filename) { return false; } - std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end()); + std::string Ext = Filename.substr(DotPos + 1); // C header: .h // C++ header: .hh or .H; return Ext == "h" || Ext == "hh" || Ext == "H"; @@ -2024,13 +2024,13 @@ RewriteObjC::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; } @@ -2357,7 +2357,7 @@ void RewriteObjC::SynthMsgSendFunctionDecl() { void RewriteObjC::SynthMsgSendSuperFunctionDecl() { IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper"); SmallVector<QualType, 16> ArgTys; - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, + RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, SourceLocation(), SourceLocation(), &Context->Idents.get("objc_super")); QualType argT = Context->getPointerType(Context->getTagDeclType(RD)); @@ -2400,7 +2400,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper_stret"); SmallVector<QualType, 16> ArgTys; - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, + RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, SourceLocation(), SourceLocation(), &Context->Idents.get("objc_super")); QualType argT = Context->getPointerType(Context->getTagDeclType(RD)); @@ -2518,7 +2518,7 @@ Stmt *RewriteObjC::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(), @@ -2531,7 +2531,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { // struct objc_super { struct objc_object *receiver; struct objc_class *super; }; QualType RewriteObjC::getSuperStructType() { if (!SuperStructDecl) { - SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl, + SuperStructDecl = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, SourceLocation(), SourceLocation(), &Context->Idents.get("objc_super")); QualType FieldTypes[2]; @@ -2559,9 +2559,9 @@ QualType RewriteObjC::getSuperStructType() { QualType RewriteObjC::getConstantStringStructType() { if (!ConstantStringDecl) { - ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get("__NSConstantStringImpl")); + ConstantStringDecl = RecordDecl::Create( + *Context, TagTypeKind::Struct, TUDecl, SourceLocation(), + SourceLocation(), &Context->Idents.get("__NSConstantStringImpl")); QualType FieldTypes[4]; // struct objc_object *receiver; @@ -2617,7 +2617,7 @@ CallExpr *RewriteObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavo const auto *FT = msgSendType->castAs<FunctionType>(); CallExpr *STCE = - CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, + CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_PRValue, SourceLocation(), FPOptionsOverride()); return STCE; } @@ -2670,16 +2670,11 @@ Stmt *RewriteObjC::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; @@ -2721,7 +2716,7 @@ Stmt *RewriteObjC::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), @@ -2739,7 +2734,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // struct 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); @@ -2766,15 +2761,11 @@ Stmt *RewriteObjC::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; @@ -2817,7 +2808,7 @@ Stmt *RewriteObjC::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), @@ -2829,9 +2820,8 @@ Stmt *RewriteObjC::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; @@ -2973,7 +2963,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, const auto *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 @@ -3003,14 +2993,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Context->IntTy, SourceLocation()); BinaryOperator *lessThanExpr = BinaryOperator::Create( - *Context, sizeofExpr, limit, BO_LE, Context->IntTy, VK_RValue, + *Context, sizeofExpr, limit, BO_LE, Context->IntTy, VK_PRValue, OK_Ordinary, SourceLocation(), FPOptionsOverride()); // (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...)) - ConditionalOperator *CondExpr = - new (Context) ConditionalOperator(lessThanExpr, - SourceLocation(), CE, - SourceLocation(), STCE, - returnType, VK_RValue, OK_Ordinary); + ConditionalOperator *CondExpr = new (Context) ConditionalOperator( + lessThanExpr, SourceLocation(), CE, SourceLocation(), STCE, returnType, + VK_PRValue, OK_Ordinary); ReplacingStmt = new (Context) ParenExpr(SourceLocation(), SourceLocation(), CondExpr); } @@ -3056,7 +3044,7 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { *Context, VD, false, getProtocolType(), VK_LValue, SourceLocation()); Expr *DerefExpr = 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()); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, DerefExpr->getType(), CK_BitCast, @@ -3749,11 +3737,9 @@ Stmt *RewriteObjC::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>(); @@ -3769,7 +3755,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT); // FTP will be null for closures that don't take arguments. - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, + RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, SourceLocation(), SourceLocation(), &Context->Idents.get("__block_impl")); QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD)); @@ -3823,7 +3809,7 @@ Stmt *RewriteObjC::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; } @@ -4422,7 +4408,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, // Simulate a constructor call... 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; @@ -4444,7 +4430,7 @@ Stmt *RewriteObjC::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); @@ -4462,9 +4448,10 @@ Stmt *RewriteObjC::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()); @@ -4479,9 +4466,10 @@ Stmt *RewriteObjC::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()); } } InitExprs.push_back(Exp); @@ -4495,9 +4483,9 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, RewriteByRefString(RecName, Name, ND, true); IdentifierInfo *II = &Context->Idents.get(RecName.c_str() + sizeof("struct")); - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - II); + RecordDecl *RD = + RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, + SourceLocation(), SourceLocation(), II); assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); @@ -4520,7 +4508,7 @@ Stmt *RewriteObjC::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); @@ -4539,7 +4527,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, SourceLocation(), FPOptionsOverride()); 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); @@ -5833,9 +5821,9 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { std::string(clsDeclared->getIdentifier()->getName()); RecName += "_IMPL"; IdentifierInfo *II = &Context->Idents.get(RecName); - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - II); + RecordDecl *RD = + RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, + SourceLocation(), SourceLocation(), II); assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT, @@ -5874,9 +5862,9 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { std::string(clsDeclared->getIdentifier()->getName()); RecName += "_IMPL"; IdentifierInfo *II = &Context->Idents.get(RecName); - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - II); + RecordDecl *RD = + RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, + SourceLocation(), SourceLocation(), II); assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT, |