From cc8a1504283731f05f937464b631f170d748b7b0 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 14 Jan 2020 13:41:07 +0000 Subject: [PATCH] Merge isa<> and getAs<> calls to fix "pointer is null" static analyzer warnings. NFCI. --- clang/lib/Sema/SemaExprObjC.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 687348c9..29f2820 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -1642,15 +1642,14 @@ bool Sema::CheckMessageArgumentTypes( << Sel << isClassMessage << SourceRange(SelectorLocs.front(), SelectorLocs.back()); // Find the class to which we are sending this message. - if (ReceiverType->isObjCObjectPointerType()) { - if (ObjCInterfaceDecl *ThisClass = - ReceiverType->getAs()->getInterfaceDecl()) { + if (auto *ObjPT = ReceiverType->getAs()) { + if (ObjCInterfaceDecl *ThisClass = ObjPT->getInterfaceDecl()) { Diag(ThisClass->getLocation(), diag::note_receiver_class_declared); if (!RecRange.isInvalid()) if (ThisClass->lookupClassMethod(Sel)) - Diag(RecRange.getBegin(),diag::note_receiver_expr_here) - << FixItHint::CreateReplacement(RecRange, - ThisClass->getNameAsString()); + Diag(RecRange.getBegin(), diag::note_receiver_expr_here) + << FixItHint::CreateReplacement(RecRange, + ThisClass->getNameAsString()); } } } -- 2.7.4