From 504f38da4e2c5ef76e7414f18fdafc71908876e9 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 24 Mar 2015 16:24:50 +0000 Subject: Fix record layout when synthesizing class types. Prior to this patch, we would try to synthesize class types by iterating over a DenseMap of FieldDecls and adding each one to a CXXRecordDecl. Since a DenseMap doesn't provide a deterministic ordering of the elements, this would not add the fields in FieldOffset order, but rather in some random order determined by the memory layout of the DenseMap. This patch fixes the issue by changing DenseMaps to vectors. The ability to lookup a value in the DenseMap was hardly being used, and where it is sufficient to do a vector lookup. Differential Revision: http://reviews.llvm.org/D8512 llvm-svn: 233090 --- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 32 +++++++++------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h') diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 5ebb60e1367..4551d6ef56b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -151,22 +151,16 @@ public: clang::DeclarationName Name, llvm::SmallVectorImpl *results); - static bool - LayoutRecordType (void *baton, - const clang::RecordDecl *record_decl, - uint64_t &size, - uint64_t &alignment, - llvm::DenseMap &field_offsets, - llvm::DenseMap &base_offsets, - llvm::DenseMap &vbase_offsets); - - bool - LayoutRecordType (const clang::RecordDecl *record_decl, - uint64_t &size, - uint64_t &alignment, - llvm::DenseMap &field_offsets, - llvm::DenseMap &base_offsets, - llvm::DenseMap &vbase_offsets); + static bool + LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, + std::vector> &FieldOffsets, + std::vector> &BaseOffsets, + std::vector> &VirtualBaseOffsets); + + bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, + std::vector> &FieldOffsets, + std::vector> &BaseOffsets, + std::vector> &VirtualBaseOffsets); struct LayoutInfo { @@ -180,9 +174,9 @@ public: } uint64_t bit_size; uint64_t alignment; - llvm::DenseMap field_offsets; - llvm::DenseMap base_offsets; - llvm::DenseMap vbase_offsets; + std::vector> field_offsets; + std::vector> base_offsets; + std::vector> vbase_offsets; }; //------------------------------------------------------------------ // PluginInterface protocol -- cgit v1.2.3