r374988 - CGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 16 03:38:41 PDT 2019
Author: rksimon
Date: Wed Oct 16 03:38:40 2019
New Revision: 374988
URL: http://llvm.org/viewvc/llvm-project?rev=374988&view=rev
Log:
CGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI.
The static analyzer is warning about a potential null dereference, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=374988&r1=374987&r2=374988&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Oct 16 03:38:40 2019
@@ -1269,8 +1269,8 @@ public:
return nullptr;
// FIXME: We should not have to call getBaseElementType here.
- const RecordType *RT =
- CGM.getContext().getBaseElementType(Ty)->getAs<RecordType>();
+ const auto *RT =
+ CGM.getContext().getBaseElementType(Ty)->castAs<RecordType>();
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
// If the class doesn't have a trivial destructor, we can't emit it as a
More information about the cfe-commits
mailing list