Commit 7bfc3bf3 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

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.
parent b93dd677
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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<FunctionType>();
  auto *FT = msgSendType->castAs<FunctionType>();
  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<ObjCContainerDecl>(D->getDeclContext());
          auto *CDecl = cast<ObjCContainerDecl>(D->getDeclContext());
          // ivar in class extensions requires special treatment.
          if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
            CDecl = CatDecl->getClassInterface();