Skip to content

Commit 7bfc3bf

Browse files
committed
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.
1 parent b93dd67 commit 7bfc3bf

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) {
26882688
// Don't forget the parens to enforce the proper binding.
26892689
ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
26902690

2691-
const FunctionType *FT = msgSendType->getAs<FunctionType>();
2691+
auto *FT = msgSendType->castAs<FunctionType>();
26922692
CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
26932693
VK_RValue, EndLoc);
26942694
ReplaceStmt(Exp, CE);
@@ -7501,8 +7501,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
75017501
RD = RD->getDefinition();
75027502
if (RD && !RD->getDeclName().getAsIdentifierInfo()) {
75037503
// decltype(((Foo_IMPL*)0)->bar) *
7504-
ObjCContainerDecl *CDecl =
7505-
dyn_cast<ObjCContainerDecl>(D->getDeclContext());
7504+
auto *CDecl = cast<ObjCContainerDecl>(D->getDeclContext());
75067505
// ivar in class extensions requires special treatment.
75077506
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
75087507
CDecl = CatDecl->getClassInterface();

0 commit comments

Comments
 (0)