From 502a509e478a5e6625b58d87b484aacd2387c64d Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 21 Oct 2019 19:08:31 +0000 Subject: [PATCH] SemaTemplateDeduction - 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. llvm-svn: 375443 --- clang/lib/Sema/SemaTemplateDeduction.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 16d5afb..64ef819 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -3826,8 +3826,7 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments( if (Args.size() < Function->getMinRequiredArguments() && !PartialOverloading) return TDK_TooFewArguments; else if (TooManyArguments(NumParams, Args.size(), PartialOverloading)) { - const FunctionProtoType *Proto - = Function->getType()->getAs(); + const auto *Proto = Function->getType()->castAs(); if (Proto->isTemplateVariadic()) /* Do nothing */; else if (!Proto->isVariadic()) @@ -3965,11 +3964,8 @@ QualType Sema::adjustCCAndNoReturn(QualType ArgFunctionType, if (ArgFunctionType.isNull()) return ArgFunctionType; - const FunctionProtoType *FunctionTypeP = - FunctionType->castAs(); - const FunctionProtoType *ArgFunctionTypeP = - ArgFunctionType->getAs(); - + const auto *FunctionTypeP = FunctionType->castAs(); + const auto *ArgFunctionTypeP = ArgFunctionType->castAs(); FunctionProtoType::ExtProtoInfo EPI = ArgFunctionTypeP->getExtProtoInfo(); bool Rebuild = false; -- 2.7.4