From 7bfc3bf39b6d279657b480963e72b6c08191b2f2 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 12 Mar 2020 16:49:35 +0000 Subject: [PATCH] Replace getAs/dyn_cast with castAs/cast to fix null dereference static analyzer warnings. Both these casts are immediately deferenced and the cast will assert for us that they are of the correct type. --- clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index f3a2780..fff4a45 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -2688,7 +2688,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) { // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast); - const FunctionType *FT = msgSendType->getAs(); + auto *FT = msgSendType->castAs(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc); ReplaceStmt(Exp, CE); @@ -7501,8 +7501,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { // decltype(((Foo_IMPL*)0)->bar) * - ObjCContainerDecl *CDecl = - dyn_cast(D->getDeclContext()); + auto *CDecl = cast(D->getDeclContext()); // ivar in class extensions requires special treatment. if (ObjCCategoryDecl *CatDecl = dyn_cast(CDecl)) CDecl = CatDecl->getClassInterface(); -- 2.7.4