diff options
| author | Zachary Turner <zturner@google.com> | 2017-06-12 20:46:35 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-06-12 20:46:35 +0000 |
| commit | d334cebac4ca2c51677b415526d1e23476298710 (patch) | |
| tree | 708ad1f8249248adfbcc8bcf1e5af4885ab954c7 /llvm | |
| parent | 76f063090b2822106f0ff1fc951cae8e8821614f (diff) | |
| download | bcm5719-llvm-d334cebac4ca2c51677b415526d1e23476298710.tar.gz bcm5719-llvm-d334cebac4ca2c51677b415526d1e23476298710.zip | |
Fix a null pointer dereference in llvm-pdbutil pretty.
Static data members were causing a problem because I mistakenly
assumed all members would affect a class's layout and so the
Layout member would be non-null.
llvm-svn: 305229
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/DebugInfo/PDB/UDTLayout.cpp | 5 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp | 24 |
2 files changed, 15 insertions, 14 deletions
diff --git a/llvm/lib/DebugInfo/PDB/UDTLayout.cpp b/llvm/lib/DebugInfo/PDB/UDTLayout.cpp index aacefae80c3..da353cb6977 100644 --- a/llvm/lib/DebugInfo/PDB/UDTLayout.cpp +++ b/llvm/lib/DebugInfo/PDB/UDTLayout.cpp @@ -181,13 +181,14 @@ void UDTLayoutBase::initializeChildren(const PDBSymbol &Sym) { if (Data->getDataKind() == PDB_DataKind::Member) Members.push_back(std::move(Data)); else - Other.push_back(std::move(Child)); + Other.push_back(std::move(Data)); } else if (auto VT = unique_dyn_cast<PDBSymbolTypeVTable>(Child)) VTables.push_back(std::move(VT)); else if (auto Func = unique_dyn_cast<PDBSymbolFunc>(Child)) Funcs.push_back(std::move(Func)); - else + else { Other.push_back(std::move(Child)); + } } // We don't want to have any re-allocations in the list of bases, so make diff --git a/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp b/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp index 54e33683f55..66c29fc5d4e 100644 --- a/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp +++ b/llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp @@ -151,21 +151,21 @@ bool PrettyClassLayoutGraphicalDumper::shouldRecurse() const { } void PrettyClassLayoutGraphicalDumper::dump(const PDBSymbolData &Symbol) { - assert(CurrentItem != nullptr); - - DataMemberLayoutItem &Layout = - static_cast<DataMemberLayoutItem &>(*CurrentItem); - VariableDumper VarDumper(Printer); VarDumper.start(Symbol, ClassOffsetZero); - if (Layout.hasUDTLayout() && shouldRecurse()) { - uint32_t ChildOffsetZero = ClassOffsetZero + Layout.getOffsetInParent(); - Printer.Indent(); - PrettyClassLayoutGraphicalDumper TypeDumper(Printer, RecursionLevel + 1, - ChildOffsetZero); - TypeDumper.start(Layout.getUDTLayout()); - Printer.Unindent(); + if (CurrentItem != nullptr) { + DataMemberLayoutItem &Layout = + static_cast<DataMemberLayoutItem &>(*CurrentItem); + + if (Layout.hasUDTLayout() && shouldRecurse()) { + uint32_t ChildOffsetZero = ClassOffsetZero + Layout.getOffsetInParent(); + Printer.Indent(); + PrettyClassLayoutGraphicalDumper TypeDumper(Printer, RecursionLevel + 1, + ChildOffsetZero); + TypeDumper.start(Layout.getUDTLayout()); + Printer.Unindent(); + } } DumpedAnything = true; |

