Skip to content

Commit 502a509

Browse files
committed
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
1 parent 87cb734 commit 502a509

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,8 +3826,7 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
38263826
if (Args.size() < Function->getMinRequiredArguments() && !PartialOverloading)
38273827
return TDK_TooFewArguments;
38283828
else if (TooManyArguments(NumParams, Args.size(), PartialOverloading)) {
3829-
const FunctionProtoType *Proto
3830-
= Function->getType()->getAs<FunctionProtoType>();
3829+
const auto *Proto = Function->getType()->castAs<FunctionProtoType>();
38313830
if (Proto->isTemplateVariadic())
38323831
/* Do nothing */;
38333832
else if (!Proto->isVariadic())
@@ -3965,11 +3964,8 @@ QualType Sema::adjustCCAndNoReturn(QualType ArgFunctionType,
39653964
if (ArgFunctionType.isNull())
39663965
return ArgFunctionType;
39673966

3968-
const FunctionProtoType *FunctionTypeP =
3969-
FunctionType->castAs<FunctionProtoType>();
3970-
const FunctionProtoType *ArgFunctionTypeP =
3971-
ArgFunctionType->getAs<FunctionProtoType>();
3972-
3967+
const auto *FunctionTypeP = FunctionType->castAs<FunctionProtoType>();
3968+
const auto *ArgFunctionTypeP = ArgFunctionType->castAs<FunctionProtoType>();
39733969
FunctionProtoType::ExtProtoInfo EPI = ArgFunctionTypeP->getExtProtoInfo();
39743970
bool Rebuild = false;
39753971

0 commit comments

Comments
 (0)