@@ -278,11 +278,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
278
278
OS << formatv (" [{0}]" , Form);
279
279
280
280
DWARFUnit *U = Die.getDwarfUnit ();
281
- DWARFFormValue formValue (Form);
282
-
283
- if (!formValue.extractValue (U->getDebugInfoExtractor (), OffsetPtr,
284
- U->getFormParams (), U))
285
- return ;
281
+ DWARFFormValue FormValue = DWARFFormValue::createFromUnit (Form, U, OffsetPtr);
286
282
287
283
OS << " \t (" ;
288
284
@@ -293,35 +289,35 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
293
289
Color = HighlightColor::String;
294
290
if (const auto *LT = U->getContext ().getLineTableForUnit (U))
295
291
if (LT->getFileNameByIndex (
296
- formValue .getAsUnsignedConstant ().getValue (),
292
+ FormValue .getAsUnsignedConstant ().getValue (),
297
293
U->getCompilationDir (),
298
294
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) {
299
295
File = ' "' + File + ' "' ;
300
296
Name = File;
301
297
}
302
- } else if (Optional<uint64_t > Val = formValue .getAsUnsignedConstant ())
298
+ } else if (Optional<uint64_t > Val = FormValue .getAsUnsignedConstant ())
303
299
Name = AttributeValueString (Attr, *Val);
304
300
305
301
if (!Name.empty ())
306
302
WithColor (OS, Color) << Name;
307
303
else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line)
308
- OS << *formValue .getAsUnsignedConstant ();
304
+ OS << *FormValue .getAsUnsignedConstant ();
309
305
else if (Attr == DW_AT_high_pc && !DumpOpts.ShowForm && !DumpOpts.Verbose &&
310
- formValue .getAsUnsignedConstant ()) {
306
+ FormValue .getAsUnsignedConstant ()) {
311
307
if (DumpOpts.ShowAddresses ) {
312
308
// Print the actual address rather than the offset.
313
309
uint64_t LowPC, HighPC, Index;
314
310
if (Die.getLowAndHighPC (LowPC, HighPC, Index))
315
311
OS << format (" 0x%016" PRIx64, HighPC);
316
312
else
317
- formValue .dump (OS, DumpOpts);
313
+ FormValue .dump (OS, DumpOpts);
318
314
}
319
315
} else if (Attr == DW_AT_location || Attr == DW_AT_frame_base ||
320
316
Attr == DW_AT_data_member_location ||
321
317
Attr == DW_AT_GNU_call_site_value)
322
- dumpLocation (OS, formValue , U, sizeof (BaseIndent) + Indent + 4 , DumpOpts);
318
+ dumpLocation (OS, FormValue , U, sizeof (BaseIndent) + Indent + 4 , DumpOpts);
323
319
else
324
- formValue .dump (OS, DumpOpts);
320
+ FormValue .dump (OS, DumpOpts);
325
321
326
322
std::string Space = DumpOpts.ShowAddresses ? " " : " " ;
327
323
@@ -330,25 +326,25 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
330
326
// interesting. These attributes are handled below.
331
327
if (Attr == DW_AT_specification || Attr == DW_AT_abstract_origin) {
332
328
if (const char *Name =
333
- Die.getAttributeValueAsReferencedDie (formValue ).getName (
329
+ Die.getAttributeValueAsReferencedDie (FormValue ).getName (
334
330
DINameKind::LinkageName))
335
331
OS << Space << " \" " << Name << ' \" ' ;
336
332
} else if (Attr == DW_AT_type) {
337
333
OS << Space << " \" " ;
338
- dumpTypeName (OS, Die.getAttributeValueAsReferencedDie (formValue ));
334
+ dumpTypeName (OS, Die.getAttributeValueAsReferencedDie (FormValue ));
339
335
OS << ' "' ;
340
336
} else if (Attr == DW_AT_APPLE_property_attribute) {
341
- if (Optional<uint64_t > OptVal = formValue .getAsUnsignedConstant ())
337
+ if (Optional<uint64_t > OptVal = FormValue .getAsUnsignedConstant ())
342
338
dumpApplePropertyAttribute (OS, *OptVal);
343
339
} else if (Attr == DW_AT_ranges) {
344
340
const DWARFObject &Obj = Die.getDwarfUnit ()->getContext ().getDWARFObj ();
345
341
// For DW_FORM_rnglistx we need to dump the offset separately, since
346
342
// we have only dumped the index so far.
347
- if (formValue .getForm () == DW_FORM_rnglistx)
343
+ if (FormValue .getForm () == DW_FORM_rnglistx)
348
344
if (auto RangeListOffset =
349
- U->getRnglistOffset (*formValue .getAsSectionOffset ())) {
350
- DWARFFormValue FV (dwarf::DW_FORM_sec_offset);
351
- FV. setUValue ( *RangeListOffset);
345
+ U->getRnglistOffset (*FormValue .getAsSectionOffset ())) {
346
+ DWARFFormValue FV = DWARFFormValue::createFromUValue (
347
+ dwarf::DW_FORM_sec_offset, *RangeListOffset);
352
348
FV.dump (OS, DumpOpts);
353
349
}
354
350
if (auto RangesOrError = Die.getAddressRanges ())
@@ -689,14 +685,11 @@ void DWARFDie::attribute_iterator::updateForIndex(
689
685
AttrValue.Attr = AbbrDecl.getAttrByIndex (Index);
690
686
// Add the previous byte size of any previous attribute value.
691
687
AttrValue.Offset += AttrValue.ByteSize ;
692
- AttrValue.Value .setForm (AbbrDecl.getFormByIndex (Index));
693
688
uint32_t ParseOffset = AttrValue.Offset ;
694
689
auto U = Die.getDwarfUnit ();
695
690
assert (U && " Die must have valid DWARF unit" );
696
- bool b = AttrValue.Value .extractValue (U->getDebugInfoExtractor (),
697
- &ParseOffset, U->getFormParams (), U);
698
- (void )b;
699
- assert (b && " extractValue cannot fail on fully parsed DWARF" );
691
+ AttrValue.Value = DWARFFormValue::createFromUnit (
692
+ AbbrDecl.getFormByIndex (Index), U, &ParseOffset);
700
693
AttrValue.ByteSize = ParseOffset - AttrValue.Offset ;
701
694
} else {
702
695
assert (Index == NumAttrs && " Indexes should be [0, NumAttrs) only" );
0 commit comments