diff clang/lib/Frontend/Rewrite/RewriteObjC.cpp @ 223:5f17cb93ff66 llvm-original

LLVM13 (2021/7/18)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:43:00 +0900
parents 79ff65ed7e25
children c4bab56944e8
line wrap: on
line diff
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp	Sun Jul 18 22:10:01 2021 +0900
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp	Sun Jul 18 22:43:00 2021 +0900
@@ -491,7 +491,7 @@
     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());
     }
@@ -2024,13 +2024,13 @@
   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;
 }
 
@@ -2518,7 +2518,7 @@
       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(),
@@ -2617,7 +2617,7 @@
 
   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 @@
     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 @@
       //
       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 @@
       // 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 @@
     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 @@
       //
       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 @@
                                    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 @@
 
   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 @@
                                                    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 @@
       *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 @@
     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>();
@@ -3823,7 +3809,7 @@
     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 @@
   // 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 @@
       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 @@
         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 @@
         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);
@@ -4520,7 +4508,7 @@
       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 @@
                             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);