[clang] ded237b - Fix "pointer is null" static analyzer warning. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 11 08:03:45 PST 2020
Author: Simon Pilgrim
Date: 2020-01-11T16:02:22Z
New Revision: ded237b58d56299f90ef44853ef79b039248b85e
URL: https://github.com/llvm/llvm-project/commit/ded237b58d56299f90ef44853ef79b039248b85e
DIFF: https://github.com/llvm/llvm-project/commit/ded237b58d56299f90ef44853ef79b039248b85e.diff
LOG: Fix "pointer is null" static analyzer warning. NFCI.
Use castAs<> instead of getAs<> since the pointer is dereferenced immediately below and castAs will perform the null assertion for us.
Added:
Modified:
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 468db9cfc7f8..507e4a6cd436 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13936,8 +13936,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
LSI->ReturnType.isNull() ? Context.VoidTy : LSI->ReturnType;
// Update the return type to the deduced type.
- const FunctionProtoType *Proto =
- FD->getType()->getAs<FunctionProtoType>();
+ const auto *Proto = FD->getType()->castAs<FunctionProtoType>();
FD->setType(Context.getFunctionType(RetType, Proto->getParamTypes(),
Proto->getExtProtoInfo()));
}
More information about the cfe-commits
mailing list