From f162036fcd065d34a7f0e2c9279bc79bf7db0f14 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 11 Feb 2022 15:05:09 +0000 Subject: [PATCH] [clang] RewriteModernObjC::SynthBlockInitExpr - remove block nullptr check All paths have already dereferenced the block pointer --- .../lib/Frontend/Rewrite/RewriteModernObjC.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index b4487f004715..1eb6b835e2d0 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -5356,16 +5356,15 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, Exp = new (Context) DeclRefExpr(*Context, FD, false, FD->getType(), VK_LValue, SourceLocation()); bool isNestedCapturedVar = false; - if (block) - for (const auto &CI : block->captures()) { - const VarDecl *variable = CI.getVariable(); - if (variable == ND && CI.isNested()) { - assert (CI.isByRef() && - "SynthBlockInitExpr - captured block variable is not byref"); - isNestedCapturedVar = true; - break; - } + for (const auto &CI : block->captures()) { + const VarDecl *variable = CI.getVariable(); + if (variable == ND && CI.isNested()) { + assert(CI.isByRef() && + "SynthBlockInitExpr - captured block variable is not byref"); + isNestedCapturedVar = true; + break; } + } // captured nested byref variable has its address passed. Do not take // its address again. if (!isNestedCapturedVar)