From: Simon Pilgrim Date: Thu, 3 Oct 2019 16:58:01 +0000 (+0000) Subject: DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null dereference... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f294fc0727d7d1db043d33162c78d94333572761;p=clang DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373626 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 10537efebf..77a3a4c679 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -959,11 +959,11 @@ const FunctionType *Decl::getFunctionType(bool BlocksToo) const { return nullptr; if (Ty->isFunctionPointerType()) - Ty = Ty->getAs()->getPointeeType(); + Ty = Ty->castAs()->getPointeeType(); else if (Ty->isFunctionReferenceType()) - Ty = Ty->getAs()->getPointeeType(); + Ty = Ty->castAs()->getPointeeType(); else if (BlocksToo && Ty->isBlockPointerType()) - Ty = Ty->getAs()->getPointeeType(); + Ty = Ty->castAs()->getPointeeType(); return Ty->getAs(); } diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 3602f1189e..a085941e68 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -2566,7 +2566,7 @@ bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const { return false; return (getNumParams() == 0 && - getType()->getAs()->isVariadic()) || + getType()->castAs()->isVariadic()) || (getNumParams() == 1) || (getNumParams() > 1 && (getParamDecl(1)->hasDefaultArg() || diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index c03ae22fb5..ccfc292e4c 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -519,15 +519,15 @@ SourceRange TemplateTypeParmDecl::getSourceRange() const { } unsigned TemplateTypeParmDecl::getDepth() const { - return getTypeForDecl()->getAs()->getDepth(); + return getTypeForDecl()->castAs()->getDepth(); } unsigned TemplateTypeParmDecl::getIndex() const { - return getTypeForDecl()->getAs()->getIndex(); + return getTypeForDecl()->castAs()->getIndex(); } bool TemplateTypeParmDecl::isParameterPack() const { - return getTypeForDecl()->getAs()->isParameterPack(); + return getTypeForDecl()->castAs()->isParameterPack(); } //===----------------------------------------------------------------------===//