From: Simon Pilgrim Date: Thu, 9 Jan 2020 12:33:37 +0000 (+0000) Subject: Fix "pointer is null" static analyzer warning. NFCI. X-Git-Tag: llvmorg-11-init~575 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d462185e8daa49889c31c8f5568749e379a5ddf9;p=platform%2Fupstream%2Fllvm.git Fix "pointer is null" static analyzer warning. NFCI. Use cast<> instead of dyn_cast<> since we know that the pointer should be valid (and is dereferenced immediately below). --- diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index a8fc77f..98e05f0 100755 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -655,11 +655,10 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, LateAttrs->push_back(LateInstantiatedAttribute(TmplAttr, Saved, New)); } else { // Allow 'this' within late-parsed attributes. - NamedDecl *ND = dyn_cast(New); - CXXRecordDecl *ThisContext = - dyn_cast_or_null(ND->getDeclContext()); + auto *ND = cast(New); + auto *ThisContext = dyn_cast_or_null(ND->getDeclContext()); CXXThisScopeRAII ThisScope(*this, ThisContext, Qualifiers(), - ND && ND->isCXXInstanceMember()); + ND->isCXXInstanceMember()); Attr *NewAttr = sema::instantiateTemplateAttribute(TmplAttr, Context, *this, TemplateArgs);