CGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 16 Oct 2019 10:38:40 +0000 (10:38 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 16 Oct 2019 10:38:40 +0000 (10:38 +0000)
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.

llvm-svn: 374988

clang/lib/CodeGen/CGExprConstant.cpp

index 03ef4ab..96e8c9c 100644 (file)
@@ -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