[llvm] r371933 - [DebugInfo] Don't dereference a dyn_cast<PDBSymbolData> result. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 15 08:38:26 PDT 2019


Author: rksimon
Date: Sun Sep 15 08:38:26 2019
New Revision: 371933

URL: http://llvm.org/viewvc/llvm-project?rev=371933&view=rev
Log:
[DebugInfo] Don't dereference a dyn_cast<PDBSymbolData> result. NFCI.

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.

Modified:
    llvm/trunk/lib/DebugInfo/PDB/UDTLayout.cpp

Modified: llvm/trunk/lib/DebugInfo/PDB/UDTLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/UDTLayout.cpp?rev=371933&r1=371932&r2=371933&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/UDTLayout.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/UDTLayout.cpp Sun Sep 15 08:38:26 2019
@@ -84,7 +84,7 @@ VBPtrLayoutItem::VBPtrLayoutItem(const U
 }
 
 const PDBSymbolData &DataMemberLayoutItem::getDataMember() {
-  return *dyn_cast<PDBSymbolData>(Symbol);
+  return *cast<PDBSymbolData>(Symbol);
 }
 
 bool DataMemberLayoutItem::hasUDTLayout() const { return UdtLayout != nullptr; }




More information about the llvm-commits mailing list