@@ -253,15 +253,18 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
253
253
// We are processing .debug_info section, implicit_const attribute
254
254
// values are not really stored here, but in .debug_abbrev section.
255
255
auto GetAsUnsignedConstant = [&]() -> int64_t {
256
- return AttrSpec.isImplicitConst () ? AttrSpec.getImplicitConstValue ()
257
- : *FormValue.getAsUnsignedConstant ();
256
+ if (AttrSpec.isImplicitConst ())
257
+ return AttrSpec.getImplicitConstValue ();
258
+ if (std::optional<uint64_t > Val = FormValue.getAsUnsignedConstant ())
259
+ return *Val;
260
+ return 0 ;
258
261
};
259
262
260
263
auto GetFlag = [](const DWARFFormValue &FormValue) -> bool {
261
264
return FormValue.isFormClass (DWARFFormValue::FC_Flag);
262
265
};
263
266
264
- auto GetBoundValue = [](const DWARFFormValue &FormValue) -> int64_t {
267
+ auto GetBoundValue = [&AttrSpec ](const DWARFFormValue &FormValue) -> int64_t {
265
268
switch (FormValue.getForm ()) {
266
269
case dwarf::DW_FORM_ref_addr:
267
270
case dwarf::DW_FORM_ref1:
@@ -282,6 +285,8 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
282
285
return *FormValue.getAsUnsignedConstant ();
283
286
case dwarf::DW_FORM_sdata:
284
287
return *FormValue.getAsSignedConstant ();
288
+ case dwarf::DW_FORM_implicit_const:
289
+ return AttrSpec.getImplicitConstValue ();
285
290
default :
286
291
return 0 ;
287
292
}
@@ -294,13 +299,13 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
294
299
295
300
switch (AttrSpec.Attr ) {
296
301
case dwarf::DW_AT_accessibility:
297
- CurrentElement->setAccessibilityCode (*FormValue. getAsUnsignedConstant ());
302
+ CurrentElement->setAccessibilityCode (GetAsUnsignedConstant ());
298
303
break ;
299
304
case dwarf::DW_AT_artificial:
300
305
CurrentElement->setIsArtificial ();
301
306
break ;
302
307
case dwarf::DW_AT_bit_size:
303
- CurrentElement->setBitSize (*FormValue. getAsUnsignedConstant ());
308
+ CurrentElement->setBitSize (GetAsUnsignedConstant ());
304
309
break ;
305
310
case dwarf::DW_AT_call_file:
306
311
CurrentElement->setCallFilenameIndex (IncrementFileIndex
@@ -332,13 +337,12 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
332
337
Stream << hexString (Value, 2 );
333
338
CurrentElement->setValue (Stream.str ());
334
339
} else
335
- CurrentElement->setValue (
336
- hexString (*FormValue.getAsUnsignedConstant (), 2 ));
340
+ CurrentElement->setValue (hexString (GetAsUnsignedConstant (), 2 ));
337
341
} else
338
342
CurrentElement->setValue (dwarf::toStringRef (FormValue));
339
343
break ;
340
344
case dwarf::DW_AT_count:
341
- CurrentElement->setCount (*FormValue. getAsUnsignedConstant ());
345
+ CurrentElement->setCount (GetAsUnsignedConstant ());
342
346
break ;
343
347
case dwarf::DW_AT_decl_line:
344
348
CurrentElement->setLineNumber (GetAsUnsignedConstant ());
@@ -357,10 +361,10 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
357
361
CurrentElement->setIsExternal ();
358
362
break ;
359
363
case dwarf::DW_AT_GNU_discriminator:
360
- CurrentElement->setDiscriminator (*FormValue. getAsUnsignedConstant ());
364
+ CurrentElement->setDiscriminator (GetAsUnsignedConstant ());
361
365
break ;
362
366
case dwarf::DW_AT_inline:
363
- CurrentElement->setInlineCode (*FormValue. getAsUnsignedConstant ());
367
+ CurrentElement->setInlineCode (GetAsUnsignedConstant ());
364
368
break ;
365
369
case dwarf::DW_AT_lower_bound:
366
370
CurrentElement->setLowerBound (GetBoundValue (FormValue));
@@ -380,7 +384,7 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
380
384
CurrentElement->setUpperBound (GetBoundValue (FormValue));
381
385
break ;
382
386
case dwarf::DW_AT_virtuality:
383
- CurrentElement->setVirtualityCode (*FormValue. getAsUnsignedConstant ());
387
+ CurrentElement->setVirtualityCode (GetAsUnsignedConstant ());
384
388
break ;
385
389
386
390
case dwarf::DW_AT_abstract_origin:
0 commit comments