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
This commit is contained in:
Zachary Turner
2015-03-24 16:24:50 +00:00
parent 186d2cbd1d
commit 504f38da4e
12 changed files with 141 additions and 187 deletions

View File

@@ -11,6 +11,7 @@
#define liblldb_ClangASTSource_h_
#include <set>
#include <vector>
#include "clang/Basic/IdentifierTable.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
@@ -20,6 +21,12 @@
#include "llvm/ADT/SmallSet.h"
namespace clang
{
class CharUnits;
class FieldDecl;
}
namespace lldb_private {
//----------------------------------------------------------------------
@@ -122,7 +129,10 @@ public:
FindExternalLexicalDecls (const clang::DeclContext *DC,
bool (*isKindWeWant)(clang::Decl::Kind),
llvm::SmallVectorImpl<clang::Decl*> &Decls);
typedef std::vector<std::pair<const clang::FieldDecl *, uint64_t>> FieldOffsetList;
typedef std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> BaseOffsetList;
//------------------------------------------------------------------
/// Specify the layout of the contents of a RecordDecl.
///
@@ -155,15 +165,11 @@ public:
///
/// @return
/// True <=> the layout is valid.
//-----------------------------------------------------------------
bool
layoutRecordType(const clang::RecordDecl *Record,
uint64_t &Size,
uint64_t &Alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets);
//-----------------------------------------------------------------
bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
FieldOffsetList &FieldOffsets, BaseOffsetList &BaseOffsets,
BaseOffsetList &VirtualBaseOffsets);
//------------------------------------------------------------------
/// Complete a TagDecl.
///
@@ -277,14 +283,10 @@ public:
{
return m_original.CompleteType(Class);
}
bool
layoutRecordType(const clang::RecordDecl *Record,
uint64_t &Size,
uint64_t &Alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets)
bool
layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
FieldOffsetList &FieldOffsets, BaseOffsetList &BaseOffsets, BaseOffsetList &VirtualBaseOffsets)
{
return m_original.layoutRecordType(Record,
Size,

View File

@@ -34,13 +34,11 @@ public:
typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *);
typedef void (*FindExternalVisibleDeclsByNameCallback)(void *baton, const clang::DeclContext *DC, clang::DeclarationName Name, llvm::SmallVectorImpl <clang::NamedDecl *> *results);
typedef bool (*LayoutRecordTypeCallback)(void *baton,
const clang::RecordDecl *Record,
uint64_t &Size,
uint64_t &Alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets);
typedef bool (*LayoutRecordTypeCallback)(
void *baton, const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets);
ClangExternalASTSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
CompleteObjCInterfaceDeclCallback objc_decl_callback,
@@ -121,14 +119,11 @@ public:
virtual void
CompleteType (clang::ObjCInterfaceDecl *objc_decl);
bool
layoutRecordType(const clang::RecordDecl *Record,
uint64_t &Size,
uint64_t &Alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets);
bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets);
void
SetExternalSourceCallbacks (CompleteTagDeclCallback tag_decl_callback,
CompleteObjCInterfaceDeclCallback objc_decl_callback,

View File

@@ -1532,46 +1532,37 @@ ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
while(0);
}
typedef llvm::DenseMap <const FieldDecl *, uint64_t> FieldOffsetMap;
typedef llvm::DenseMap <const CXXRecordDecl *, CharUnits> BaseOffsetMap;
template <class D, class O>
static bool
ImportOffsetMap (llvm::DenseMap <const D*, O> &destination_map,
llvm::DenseMap <const D*, O> &source_map,
ClangASTImporter *importer,
ImportOffsetList(std::vector<std::pair<const D *, O>> &destination_list,
const std::vector<std::pair<const D *, O>> &source_list, ClangASTImporter *importer,
ASTContext &dest_ctx)
{
typedef llvm::DenseMap <const D*, O> MapType;
typedef std::vector<std::pair<const D *, O>> ListType;
for (typename MapType::iterator fi = source_map.begin(), fe = source_map.end();
fi != fe;
++fi)
for (const auto &fi : source_list)
{
DeclFromUser <D> user_decl(const_cast<D*>(fi->first));
DeclFromUser<D> user_decl(const_cast<D *>(fi.first));
DeclFromParser <D> parser_decl(user_decl.Import(importer, dest_ctx));
if (parser_decl.IsInvalid())
return false;
destination_map.insert(std::pair<const D *, O>(parser_decl.decl, fi->second));
destination_list.push_back(std::pair<const D *, O>(parser_decl.decl, fi.second));
}
return true;
}
template <bool IsVirtual> bool ExtractBaseOffsets (const ASTRecordLayout &record_layout,
DeclFromUser<const CXXRecordDecl> &record,
BaseOffsetMap &base_offsets)
template <bool IsVirtual>
bool
ExtractBaseOffsets(const ASTRecordLayout &record_layout, DeclFromUser<const CXXRecordDecl> &record,
ClangASTSource::BaseOffsetList &base_offsets)
{
for (CXXRecordDecl::base_class_const_iterator
bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()),
be = (IsVirtual ? record->vbases_end() : record->bases_end());
bi != be;
++bi)
for (const auto &base : (IsVirtual ? record->vbases() : record->bases()))
{
if (!IsVirtual && bi->isVirtual())
if (!IsVirtual && base.isVirtual())
continue;
const clang::Type *origin_base_type = bi->getType().getTypePtr();
const clang::Type *origin_base_type = base.getType().getTypePtr();
const clang::RecordType *origin_base_record_type = origin_base_type->getAs<RecordType>();
if (!origin_base_record_type)
@@ -1594,19 +1585,16 @@ template <bool IsVirtual> bool ExtractBaseOffsets (const ASTRecordLayout &record
else
base_offset = record_layout.getBaseClassOffset(origin_base_cxx_record.decl);
base_offsets.insert(std::pair<const CXXRecordDecl *, CharUnits>(origin_base_cxx_record.decl, base_offset));
base_offsets.push_back(std::make_pair(origin_base_cxx_record.decl, base_offset));
}
return true;
}
bool
ClangASTSource::layoutRecordType(const RecordDecl *record,
uint64_t &size,
uint64_t &alignment,
FieldOffsetMap &field_offsets,
BaseOffsetMap &base_offsets,
BaseOffsetMap &virtual_base_offsets)
ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size, uint64_t &alignment,
FieldOffsetList &field_offsets, BaseOffsetList &base_offsets,
BaseOffsetList &virtual_base_offsets)
{
ClangASTMetrics::RegisterRecordLayout();
@@ -1627,9 +1615,9 @@ ClangASTSource::layoutRecordType(const RecordDecl *record,
if (origin_record.IsInvalid())
return false;
FieldOffsetMap origin_field_offsets;
BaseOffsetMap origin_base_offsets;
BaseOffsetMap origin_virtual_base_offsets;
FieldOffsetList origin_field_offsets;
BaseOffsetList origin_base_offsets;
BaseOffsetList origin_virtual_base_offsets;
ClangASTContext::GetCompleteDecl(&origin_record->getASTContext(), const_cast<RecordDecl*>(origin_record.decl));
@@ -1640,16 +1628,15 @@ ClangASTSource::layoutRecordType(const RecordDecl *record,
int field_idx = 0, field_count = record_layout.getFieldCount();
for (RecordDecl::field_iterator fi = origin_record->field_begin(), fe = origin_record->field_end();
fi != fe;
++fi)
origin_field_offsets.reserve(field_count);
for (const auto &field : origin_record->fields())
{
if (field_idx >= field_count)
return false; // Layout didn't go well. Bail out.
uint64_t field_offset = record_layout.getFieldOffset(field_idx);
origin_field_offsets.insert(std::pair<const FieldDecl *, uint64_t>(*fi, field_offset));
origin_field_offsets.push_back(std::pair<const FieldDecl *, uint64_t>(field, field_offset));
field_idx++;
}
@@ -1665,9 +1652,9 @@ ClangASTSource::layoutRecordType(const RecordDecl *record,
return false;
}
if (!ImportOffsetMap(field_offsets, origin_field_offsets, m_ast_importer, parser_ast_context) ||
!ImportOffsetMap(base_offsets, origin_base_offsets, m_ast_importer, parser_ast_context) ||
!ImportOffsetMap(virtual_base_offsets, origin_virtual_base_offsets, m_ast_importer, parser_ast_context))
if (!ImportOffsetList(field_offsets, origin_field_offsets, m_ast_importer, parser_ast_context) ||
!ImportOffsetList(base_offsets, origin_base_offsets, m_ast_importer, parser_ast_context) ||
!ImportOffsetList(virtual_base_offsets, origin_virtual_base_offsets, m_ast_importer, parser_ast_context))
return false;
size = record_layout.getSize().getQuantity() * m_ast_context->getCharWidth();
@@ -1685,9 +1672,10 @@ ClangASTSource::layoutRecordType(const RecordDecl *record,
fi != fe;
++fi)
{
log->Printf("LRT[%u] (FieldDecl*)%p, Name = '%s', Offset = %" PRId64 " bits",
current_id, static_cast<void*>(*fi),
fi->getNameAsString().c_str(), field_offsets[*fi]);
log->Printf("LRT[%u] (FieldDecl*)%p, Name = '%s', Offset = %" PRId64 " bits", current_id,
static_cast<void *>(*fi), fi->getNameAsString().c_str(),
record_layout.getFieldOffset(fi->getFieldIndex()));
}
DeclFromParser <const CXXRecordDecl> parser_cxx_record = DynCast<const CXXRecordDecl>(parser_record);
if (parser_cxx_record.IsValid())
@@ -1704,13 +1692,11 @@ ClangASTSource::layoutRecordType(const RecordDecl *record,
DeclFromParser <RecordDecl> base_record(base_record_type->getDecl());
DeclFromParser <CXXRecordDecl> base_cxx_record = DynCast<CXXRecordDecl>(base_record);
log->Printf("LRT[%u] %s(CXXRecordDecl*)%p, Name = '%s', Offset = %" PRId64 " chars",
current_id, (is_virtual ? "Virtual " : ""),
static_cast<void*>(base_cxx_record.decl),
base_cxx_record.decl->getNameAsString().c_str(),
(is_virtual
? virtual_base_offsets[base_cxx_record.decl].getQuantity()
: base_offsets[base_cxx_record.decl].getQuantity()));
clang::CharUnits base_offset = is_virtual ? record_layout.getVBaseClassOffset(base_cxx_record.decl)
: record_layout.getBaseClassOffset(base_cxx_record.decl);
log->Printf("LRT[%u] %s(CXXRecordDecl*)%p, Name = '%s', Offset = %" PRId64 " chars", current_id,
(is_virtual ? "Virtual " : ""), static_cast<void *>(base_cxx_record.decl),
base_cxx_record.decl->getNameAsString().c_str(), base_offset);
}
}
else

View File

@@ -141,12 +141,10 @@ public:
}
bool
layoutRecordType(const clang::RecordDecl *Record,
uint64_t &Size,
uint64_t &Alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets)
layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets)
{
return false;
}

View File

@@ -2073,8 +2073,9 @@ SymbolFileDWARF::ParseChildMembers
GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, word_width),
accessibility,
anon_field_info.bit_size);
layout_info.field_offsets.insert(std::make_pair(unnamed_bitfield_decl, anon_field_info.bit_offset));
layout_info.field_offsets.push_back(
std::make_pair(unnamed_bitfield_decl, anon_field_info.bit_offset));
}
}
last_field_info = this_field_info;
@@ -2124,9 +2125,8 @@ SymbolFileDWARF::ParseChildMembers
bit_size);
GetClangASTContext().SetMetadataAsUserID (field_decl, MakeUserID(die->GetOffset()));
layout_info.field_offsets.insert(std::make_pair(field_decl, field_bit_offset));
layout_info.field_offsets.push_back(std::make_pair(field_decl, field_bit_offset));
}
else
{
@@ -2287,8 +2287,9 @@ SymbolFileDWARF::ParseChildMembers
}
else
{
layout_info.base_offsets.insert(std::make_pair(base_class_clang_type.GetAsCXXRecordDecl(),
clang::CharUnits::fromQuantity(member_byte_offset)));
layout_info.base_offsets.push_back(
std::make_pair(base_class_clang_type.GetAsCXXRecordDecl(),
clang::CharUnits::fromQuantity(member_byte_offset)));
}
}
}
@@ -2669,43 +2670,36 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type)
static_cast<uint32_t>(layout_info.base_offsets.size()),
static_cast<uint32_t>(layout_info.vbase_offsets.size()));
uint32_t idx;
for (const auto &entry : layout_info.field_offsets)
{
llvm::DenseMap <const clang::FieldDecl *, uint64_t>::const_iterator pos, end = layout_info.field_offsets.end();
for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end; ++pos, ++idx)
{
GetObjectFile()->GetModule()->LogMessage (log,
"SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }",
static_cast<void*>(clang_type.GetOpaqueQualType()),
idx,
static_cast<uint32_t>(pos->second),
pos->first->getNameAsString().c_str());
}
GetObjectFile()->GetModule()->LogMessage(
log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field[%u] = "
"{ bit_offset=%u, name='%s' }",
static_cast<void *>(clang_type.GetOpaqueQualType()), entry.first->getFieldIndex(),
static_cast<uint32_t>(entry.second), entry.first->getNameAsString().c_str());
}
uint32_t idx = 0;
for (const auto &entry : layout_info.base_offsets)
{
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator base_pos, base_end = layout_info.base_offsets.end();
for (idx = 0, base_pos = layout_info.base_offsets.begin(); base_pos != base_end; ++base_pos, ++idx)
{
GetObjectFile()->GetModule()->LogMessage (log,
"SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) base[%u] = { byte_offset=%u, name='%s' }",
clang_type.GetOpaqueQualType(),
idx,
(uint32_t)base_pos->second.getQuantity(),
base_pos->first->getNameAsString().c_str());
}
GetObjectFile()->GetModule()->LogMessage(
log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) base[%u] = { "
"byte_offset=%u, name='%s' }",
clang_type.GetOpaqueQualType(), idx, (uint32_t)entry.second.getQuantity(),
entry.first->getNameAsString().c_str());
++idx;
}
idx = 0;
for (const auto &entry : layout_info.vbase_offsets)
{
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator vbase_pos, vbase_end = layout_info.vbase_offsets.end();
for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin(); vbase_pos != vbase_end; ++vbase_pos, ++idx)
{
GetObjectFile()->GetModule()->LogMessage (log,
"SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }",
static_cast<void*>(clang_type.GetOpaqueQualType()),
idx,
static_cast<uint32_t>(vbase_pos->second.getQuantity()),
vbase_pos->first->getNameAsString().c_str());
}
GetObjectFile()->GetModule()->LogMessage(
log, "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) vbase[%u] = "
"{ byte_offset=%u, name='%s' }",
static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
static_cast<uint32_t>(entry.second.getQuantity()),
entry.first->getNameAsString().c_str());
++idx;
}
}
m_record_decl_to_layout_map.insert(std::make_pair(record_decl, layout_info));
@@ -7918,27 +7912,22 @@ SymbolFileDWARF::FindExternalVisibleDeclsByName (void *baton,
}
}
bool
SymbolFileDWARF::LayoutRecordType (void *baton,
const clang::RecordDecl *record_decl,
uint64_t &size,
uint64_t &alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
bool
SymbolFileDWARF::LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size,
uint64_t &alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &field_offsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &base_offsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &vbase_offsets)
{
SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
return symbol_file_dwarf->LayoutRecordType (record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets);
}
bool
SymbolFileDWARF::LayoutRecordType (const clang::RecordDecl *record_decl,
uint64_t &bit_size,
uint64_t &alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
bool
SymbolFileDWARF::LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &field_offsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &base_offsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &vbase_offsets)
{
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find (record_decl);

View File

@@ -151,22 +151,16 @@ public:
clang::DeclarationName Name,
llvm::SmallVectorImpl <clang::NamedDecl *> *results);
static bool
LayoutRecordType (void *baton,
const clang::RecordDecl *record_decl,
uint64_t &size,
uint64_t &alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
static bool
LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets);
bool
LayoutRecordType (const clang::RecordDecl *record_decl,
uint64_t &size,
uint64_t &alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets);
struct LayoutInfo
{
@@ -180,9 +174,9 @@ public:
}
uint64_t bit_size;
uint64_t alignment;
llvm::DenseMap <const clang::FieldDecl *, uint64_t> field_offsets;
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> base_offsets;
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> vbase_offsets;
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> field_offsets;
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> base_offsets;
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> vbase_offsets;
};
//------------------------------------------------------------------
// PluginInterface protocol

View File

@@ -1474,14 +1474,12 @@ SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInte
}
}
bool
SymbolFileDWARFDebugMap::LayoutRecordType (void *baton,
const clang::RecordDecl *record_decl,
uint64_t &size,
uint64_t &alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
bool
SymbolFileDWARFDebugMap::LayoutRecordType(
void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &field_offsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &base_offsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &vbase_offsets)
{
SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
SymbolFileDWARF *oso_dwarf;

View File

@@ -102,16 +102,12 @@ public:
static void
CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
static bool
LayoutRecordType (void *baton,
const clang::RecordDecl *record_decl,
uint64_t &size,
uint64_t &alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &field_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
static bool
LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets);
//------------------------------------------------------------------
// PluginInterface protocol

View File

@@ -141,13 +141,12 @@ ClangExternalASTSourceCallbacks::CompleteType (ObjCInterfaceDecl *objc_decl)
m_callback_objc_decl (m_callback_baton, objc_decl);
}
bool
ClangExternalASTSourceCallbacks::layoutRecordType(const clang::RecordDecl *Record,
uint64_t &Size,
uint64_t &Alignment,
llvm::DenseMap <const clang::FieldDecl *, uint64_t> &FieldOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
llvm::DenseMap <const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets)
bool
ClangExternalASTSourceCallbacks::layoutRecordType(
const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
std::vector<std::pair<const clang::FieldDecl *, uint64_t>> &FieldOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &BaseOffsets,
std::vector<std::pair<const clang::CXXRecordDecl *, clang::CharUnits>> &VirtualBaseOffsets)
{
if (m_callback_layout_record_type)
return m_callback_layout_record_type(m_callback_baton,

View File

@@ -20,7 +20,7 @@ class LibcxxVBoolDataFormatterTestCase(TestBase):
self.data_formatter_commands()
@skipIfLinux # No standard locations for libc++ on Linux, so skip for now
@skipIfWindows # http://llvm.org/pr21800
@skipIfWindows # Windows doesn't have libcxx
@dwarf_test
def test_with_dwarf_and_run_command(self):
"""Test data formatter commands."""

View File

@@ -22,7 +22,6 @@ class StdVBoolDataFormatterTestCase(TestBase):
@expectedFailureFreeBSD("llvm.org/pr20548") # fails to build on lab.llvm.org buildbot
@dwarf_test
@skipIfWindows # http://llvm.org/pr21800
@skipIfDarwin
def test_with_dwarf_and_run_command(self):
"""Test data formatter commands."""

View File

@@ -26,7 +26,6 @@ class BitfieldsTestCase(TestBase):
self.bitfields_variable_python()
@dwarf_test
@unittest2.skipIf(sys.platform.startswith("win32"), "BitFields exhibit crashes in record layout on Windows (http://llvm.org/pr21800)")
def test_with_dwarf_and_run_command(self):
"""Test 'frame variable ...' on a variable with bitfields."""
self.buildDwarf()
@@ -34,7 +33,6 @@ class BitfieldsTestCase(TestBase):
@python_api_test
@dwarf_test
@unittest2.skipIf(sys.platform.startswith("win32"), "BitFields exhibit crashes in record layout on Windows (http://llvm.org/pr21800)")
@expectedFailureGcc # GCC (4.6/4.7) generates incorrect code with unnamed bitfields.
def test_with_dwarf_and_python_api(self):
"""Use Python APIs to inspect a bitfields variable."""