diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -259,6 +259,10 @@ struct CallSiteParameter { DWARFExpression LocationInCallee; DWARFExpression LocationInCaller; + + CallSiteParameter(DWARFExpression &LocationInCallee, + DWARFExpression &LocationInCaller) + : LocationInCallee(LocationInCallee), LocationInCaller(LocationInCaller) {} }; /// A vector of \c CallSiteParameter. diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1896,18 +1896,16 @@ if (!size) return false; llvm::APInt apint(*size, uval64, is_signed); - template_param_infos.args.push_back( - clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed), - ClangUtil::GetQualType(clang_type))); - } else { - template_param_infos.args.push_back( - clang::TemplateArgument(ClangUtil::GetQualType(clang_type))); - } + template_param_infos.args.emplace_back( + ast, llvm::APSInt(apint, !is_signed), + ClangUtil::GetQualType(clang_type)); + } else + template_param_infos.args.emplace_back( + ClangUtil::GetQualType(clang_type)); } else { auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name); template_param_infos.names.push_back(name); - template_param_infos.args.push_back( - clang::TemplateArgument(clang::TemplateName(tplt_type))); + template_param_infos.args.emplace_back(clang::TemplateName(tplt_type)); } } } @@ -2743,10 +2741,10 @@ ClangASTMetadata metadata; metadata.SetUserID(die.GetID()); - delayed_properties.push_back(DelayedAddObjCClassProperty( + delayed_properties.emplace_back( class_clang_type, prop_name, member_type->GetLayoutCompilerType(), ivar_decl, prop_setter_name, prop_getter_name, prop_attributes, - &metadata)); + &metadata); if (ivar_decl) m_ast.SetMetadataAsUserID(ivar_decl, die.GetID()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp @@ -60,7 +60,7 @@ if (form == DW_FORM_implicit_const) val.value.sval = data.GetULEB128(offset_ptr); - m_attributes.push_back(DWARFAttribute(attr, form, val)); + m_attributes.emplace_back(attr, form, val); } return llvm::make_error( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -52,8 +52,10 @@ DWARFAttributes(); ~DWARFAttributes(); - void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, - dw_attr_t attr, dw_form_t form); + void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, + dw_form_t form) { + m_infos.emplace_back(cu, attr_die_offset, attr, form); + } const DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; } @@ -77,6 +79,11 @@ // case we have DW_FORM_ref_addr values dw_offset_t die_offset; DWARFAttribute attr; + + AttributeValue(const DWARFUnit *cu, dw_offset_t die_offset, dw_attr_t attr, + dw_form_t form) + : cu(cu), die_offset(die_offset), + attr(attr, form, DWARFFormValue::ValueType()) {} }; typedef llvm::SmallVector collection; collection m_infos; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -25,13 +25,6 @@ return UINT32_MAX; } -void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, - dw_attr_t attr, dw_form_t form) { - AttributeValue attr_value = { - cu, attr_die_offset, {attr, form, DWARFFormValue::ValueType()}}; - m_infos.push_back(attr_value); -} - bool DWARFAttributes::ExtractFormValueAtIndex( uint32_t i, DWARFFormValue &form_value) const { const DWARFUnit *cu = CompileUnitAtIndex(i); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -382,33 +382,33 @@ parent.GetDeclContext(context); switch (tag) { case DW_TAG_module: - context.push_back({CompilerContextKind::Module, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Module, ConstString(GetName())); break; case DW_TAG_namespace: - context.push_back({CompilerContextKind::Namespace, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Namespace, ConstString(GetName())); break; case DW_TAG_structure_type: - context.push_back({CompilerContextKind::Struct, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Struct, ConstString(GetName())); break; case DW_TAG_union_type: - context.push_back({CompilerContextKind::Union, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Union, ConstString(GetName())); break; case DW_TAG_class_type: - context.push_back({CompilerContextKind::Class, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Class, ConstString(GetName())); break; case DW_TAG_enumeration_type: - context.push_back({CompilerContextKind::Enum, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Enum, ConstString(GetName())); break; case DW_TAG_subprogram: - context.push_back( - {CompilerContextKind::Function, ConstString(GetPubname())}); + context.emplace_back(CompilerContextKind::Function, + ConstString(GetPubname())); break; case DW_TAG_variable: - context.push_back( - {CompilerContextKind::Variable, ConstString(GetPubname())}); + context.emplace_back(CompilerContextKind::Variable, + ConstString(GetPubname())); break; case DW_TAG_typedef: - context.push_back({CompilerContextKind::Typedef, ConstString(GetName())}); + context.emplace_back(CompilerContextKind::Typedef, ConstString(GetName())); break; default: break; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h @@ -33,6 +33,14 @@ struct Descriptor { dw_addr_t address; dw_addr_t length; + + static_assert(sizeof(address) == sizeof(length), + "DWARFDebugArangeSet::Descriptor.address and " + "DWARFDebugArangeSet::Descriptor.length must have same size"); + + Descriptor(dw_addr_t address, dw_addr_t length) + : address(address), length(length) {} + dw_addr_t end_address() const { return address + length; } }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp @@ -98,23 +98,16 @@ *offset_ptr = m_offset + first_tuple_offset; - Descriptor arangeDescriptor; - - static_assert(sizeof(arangeDescriptor.address) == - sizeof(arangeDescriptor.length), - "DWARFDebugArangeSet::Descriptor.address and " - "DWARFDebugArangeSet::Descriptor.length must have same size"); - while (data.ValidOffset(*offset_ptr)) { - arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size); - arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size); + dw_addr_t address = data.GetMaxU64(offset_ptr, m_header.addr_size); + dw_attr_t length = data.GetMaxU64(offset_ptr, m_header.addr_size); // Each set of tuples is terminated by a 0 for the address and 0 for // the length. - if (!arangeDescriptor.address && !arangeDescriptor.length) + if (!address && !length) return llvm::ErrorSuccess(); - m_arange_descriptors.push_back(arangeDescriptor); + m_arange_descriptors.emplace_back(address, length); } return llvm::make_error( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -72,6 +72,8 @@ struct Atom { AtomType type; dw_form_t form; + + Atom(AtomType &type, dw_form_t &form) : type(type), form(form) {} }; typedef std::vector DIEInfoArray; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -154,7 +154,7 @@ } void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) { - atoms.push_back({type, form}); + atoms.emplace_back(type, form); atom_mask |= 1u << type; switch (form) { case DW_FORM_indirect: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3638,10 +3638,8 @@ LocationInCaller = parse_simple_location(i); } - if (LocationInCallee && LocationInCaller) { - CallSiteParameter param = {*LocationInCallee, *LocationInCaller}; - parameters.push_back(param); - } + if (LocationInCallee && LocationInCaller) + parameters.emplace_back(*LocationInCallee, *LocationInCaller); } return parameters; }