Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,18 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
// We are processing .debug_info section, implicit_const attribute
// values are not really stored here, but in .debug_abbrev section.
auto GetAsUnsignedConstant = [&]() -> int64_t {
return AttrSpec.isImplicitConst() ? AttrSpec.getImplicitConstValue()
: *FormValue.getAsUnsignedConstant();
if (AttrSpec.isImplicitConst())
return AttrSpec.getImplicitConstValue();
if (std::optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
return *Val;
return 0;
};

auto GetFlag = [](const DWARFFormValue &FormValue) -> bool {
return FormValue.isFormClass(DWARFFormValue::FC_Flag);
};

auto GetBoundValue = [](const DWARFFormValue &FormValue) -> int64_t {
auto GetBoundValue = [&AttrSpec](const DWARFFormValue &FormValue) -> int64_t {
switch (FormValue.getForm()) {
case dwarf::DW_FORM_ref_addr:
case dwarf::DW_FORM_ref1:
Expand All @@ -283,6 +286,8 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
return *FormValue.getAsUnsignedConstant();
case dwarf::DW_FORM_sdata:
return *FormValue.getAsSignedConstant();
case dwarf::DW_FORM_implicit_const:
return AttrSpec.getImplicitConstValue();
default:
return 0;
}
Expand All @@ -295,13 +300,13 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,

switch (AttrSpec.Attr) {
case dwarf::DW_AT_accessibility:
CurrentElement->setAccessibilityCode(*FormValue.getAsUnsignedConstant());
CurrentElement->setAccessibilityCode(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_artificial:
CurrentElement->setIsArtificial();
break;
case dwarf::DW_AT_bit_size:
CurrentElement->setBitSize(*FormValue.getAsUnsignedConstant());
CurrentElement->setBitSize(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_call_file:
CurrentElement->setCallFilenameIndex(IncrementFileIndex
Expand Down Expand Up @@ -333,13 +338,12 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
Stream << hexString(Value, 2);
CurrentElement->setValue(Stream.str());
} else
CurrentElement->setValue(
hexString(*FormValue.getAsUnsignedConstant(), 2));
CurrentElement->setValue(hexString(GetAsUnsignedConstant(), 2));
} else
CurrentElement->setValue(dwarf::toStringRef(FormValue));
break;
case dwarf::DW_AT_count:
CurrentElement->setCount(*FormValue.getAsUnsignedConstant());
CurrentElement->setCount(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_decl_line:
CurrentElement->setLineNumber(GetAsUnsignedConstant());
Expand All @@ -358,10 +362,10 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
CurrentElement->setIsExternal();
break;
case dwarf::DW_AT_GNU_discriminator:
CurrentElement->setDiscriminator(*FormValue.getAsUnsignedConstant());
CurrentElement->setDiscriminator(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_inline:
CurrentElement->setInlineCode(*FormValue.getAsUnsignedConstant());
CurrentElement->setInlineCode(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_lower_bound:
CurrentElement->setLowerBound(GetBoundValue(FormValue));
Expand All @@ -381,7 +385,7 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
CurrentElement->setUpperBound(GetBoundValue(FormValue));
break;
case dwarf::DW_AT_virtuality:
CurrentElement->setVirtualityCode(*FormValue.getAsUnsignedConstant());
CurrentElement->setVirtualityCode(GetAsUnsignedConstant());
break;

case dwarf::DW_AT_abstract_origin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] 2 {Function} extern not_inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [002] 2 {Function} extern inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'
; ONE-NEXT: [003] 2 {Parameter} 'Param' -> 'int'
; ONE-NEXT: [003] 3 {Variable} 'Var_1' -> 'int'
; ONE-NEXT: [002] 11 {Function} extern not_inlined 'test' -> 'int'
; ONE-NEXT: [003] 12 {Variable} 'A' -> 'int'
; ONE-NEXT: [003] 13 {InlinedFunction} not_inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] 13 {InlinedFunction} inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [004] {Block}
; ONE-NEXT: [005] {Variable} 'Var_2' -> 'int'
; ONE-NEXT: [004] {Parameter} 'Param' -> 'int'
Expand Down
Loading