[DebugInfo] Don't dereference a dyn_cast<PDBSymbolData> result. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 15 Sep 2019 15:38:26 +0000 (15:38 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 15 Sep 2019 15:38:26 +0000 (15:38 +0000)
The static analyzer is warning about a potential null dereference - but as we're in DataMemberLayoutItem we should be able to guarantee that the Symbol is a PDBSymbolData type, allowing us to use cast<PDBSymbolData> - and if not assert will fire for us.

llvm-svn: 371933

llvm/lib/DebugInfo/PDB/UDTLayout.cpp

index d8bc3dc..a8e1d0a 100644 (file)
@@ -84,7 +84,7 @@ VBPtrLayoutItem::VBPtrLayoutItem(const UDTLayoutBase &Parent,
 }
 
 const PDBSymbolData &DataMemberLayoutItem::getDataMember() {
-  return *dyn_cast<PDBSymbolData>(Symbol);
+  return *cast<PDBSymbolData>(Symbol);
 }
 
 bool DataMemberLayoutItem::hasUDTLayout() const { return UdtLayout != nullptr; }