ahatanak created this revision. ahatanak added reviewers: rjmccall, aprantl, vsk, dblaikie. ahatanak added a project: clang. Herald added a subscriber: kristof.beyls. ahatanak requested review of this revision.
This is needed to prevent clang from crashing when we make the changes proposed in https://reviews.llvm.org/D98799. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D104883 Files: clang/lib/CodeGen/CGObjC.cpp Index: clang/lib/CodeGen/CGObjC.cpp =================================================================== --- clang/lib/CodeGen/CGObjC.cpp +++ clang/lib/CodeGen/CGObjC.cpp @@ -3694,12 +3694,18 @@ FunctionTy, nullptr, SC_Static, false, false); FunctionArgList args; - ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, - ImplicitParamDecl::Other); - args.push_back(&DstDecl); - ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy, - ImplicitParamDecl::Other); - args.push_back(&SrcDecl); + ParmVarDecl *Params[2]; + ParmVarDecl *DstDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy, + C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[0] = DstDecl); + ParmVarDecl *SrcDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy, + C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[1] = SrcDecl); + FD->setParams(Params); const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); @@ -3715,12 +3721,12 @@ StartFunction(FD, ReturnTy, Fn, FI, args); - DeclRefExpr DstExpr(C, &DstDecl, false, DestTy, VK_PRValue, SourceLocation()); + DeclRefExpr DstExpr(C, DstDecl, false, DestTy, VK_PRValue, SourceLocation()); UnaryOperator *DST = UnaryOperator::Create( C, &DstExpr, UO_Deref, DestTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); - DeclRefExpr SrcExpr(C, &SrcDecl, false, SrcTy, VK_PRValue, SourceLocation()); + DeclRefExpr SrcExpr(C, SrcDecl, false, SrcTy, VK_PRValue, SourceLocation()); UnaryOperator *SRC = UnaryOperator::Create( C, &SrcExpr, UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); @@ -3778,12 +3784,18 @@ FunctionTy, nullptr, SC_Static, false, false); FunctionArgList args; - ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, - ImplicitParamDecl::Other); - args.push_back(&DstDecl); - ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy, - ImplicitParamDecl::Other); - args.push_back(&SrcDecl); + ParmVarDecl *Params[2]; + ParmVarDecl *DstDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy, + C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[0] = DstDecl); + ParmVarDecl *SrcDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy, + C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[1] = SrcDecl); + FD->setParams(Params); const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); @@ -3798,7 +3810,7 @@ StartFunction(FD, ReturnTy, Fn, FI, args); - DeclRefExpr SrcExpr(getContext(), &SrcDecl, false, SrcTy, VK_PRValue, + DeclRefExpr SrcExpr(getContext(), SrcDecl, false, SrcTy, VK_PRValue, SourceLocation()); UnaryOperator *SRC = UnaryOperator::Create( @@ -3825,7 +3837,7 @@ CXXConstExpr->getConstructionKind(), SourceRange()); - DeclRefExpr DstExpr(getContext(), &DstDecl, false, DestTy, VK_PRValue, + DeclRefExpr DstExpr(getContext(), DstDecl, false, DestTy, VK_PRValue, SourceLocation()); RValue DV = EmitAnyExpr(&DstExpr);
Index: clang/lib/CodeGen/CGObjC.cpp =================================================================== --- clang/lib/CodeGen/CGObjC.cpp +++ clang/lib/CodeGen/CGObjC.cpp @@ -3694,12 +3694,18 @@ FunctionTy, nullptr, SC_Static, false, false); FunctionArgList args; - ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, - ImplicitParamDecl::Other); - args.push_back(&DstDecl); - ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy, - ImplicitParamDecl::Other); - args.push_back(&SrcDecl); + ParmVarDecl *Params[2]; + ParmVarDecl *DstDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy, + C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[0] = DstDecl); + ParmVarDecl *SrcDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy, + C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[1] = SrcDecl); + FD->setParams(Params); const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); @@ -3715,12 +3721,12 @@ StartFunction(FD, ReturnTy, Fn, FI, args); - DeclRefExpr DstExpr(C, &DstDecl, false, DestTy, VK_PRValue, SourceLocation()); + DeclRefExpr DstExpr(C, DstDecl, false, DestTy, VK_PRValue, SourceLocation()); UnaryOperator *DST = UnaryOperator::Create( C, &DstExpr, UO_Deref, DestTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); - DeclRefExpr SrcExpr(C, &SrcDecl, false, SrcTy, VK_PRValue, SourceLocation()); + DeclRefExpr SrcExpr(C, SrcDecl, false, SrcTy, VK_PRValue, SourceLocation()); UnaryOperator *SRC = UnaryOperator::Create( C, &SrcExpr, UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); @@ -3778,12 +3784,18 @@ FunctionTy, nullptr, SC_Static, false, false); FunctionArgList args; - ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, - ImplicitParamDecl::Other); - args.push_back(&DstDecl); - ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy, - ImplicitParamDecl::Other); - args.push_back(&SrcDecl); + ParmVarDecl *Params[2]; + ParmVarDecl *DstDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, DestTy, + C.getTrivialTypeSourceInfo(DestTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[0] = DstDecl); + ParmVarDecl *SrcDecl = ParmVarDecl::Create( + C, FD, SourceLocation(), SourceLocation(), nullptr, SrcTy, + C.getTrivialTypeSourceInfo(SrcTy, SourceLocation()), SC_None, + /*DefArg=*/nullptr); + args.push_back(Params[1] = SrcDecl); + FD->setParams(Params); const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); @@ -3798,7 +3810,7 @@ StartFunction(FD, ReturnTy, Fn, FI, args); - DeclRefExpr SrcExpr(getContext(), &SrcDecl, false, SrcTy, VK_PRValue, + DeclRefExpr SrcExpr(getContext(), SrcDecl, false, SrcTy, VK_PRValue, SourceLocation()); UnaryOperator *SRC = UnaryOperator::Create( @@ -3825,7 +3837,7 @@ CXXConstExpr->getConstructionKind(), SourceRange()); - DeclRefExpr DstExpr(getContext(), &DstDecl, false, DestTy, VK_PRValue, + DeclRefExpr DstExpr(getContext(), DstDecl, false, DestTy, VK_PRValue, SourceLocation()); RValue DV = EmitAnyExpr(&DstExpr);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits