diff options
-rw-r--r-- | llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h | 15 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp | 4 |
2 files changed, 13 insertions, 6 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h index de49be5c0b5..84b23398b8c 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -33,8 +33,11 @@ public: assert(isImplicitConst()); } AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize) - : Attr(A), Form(F), ByteSize(ByteSize) { + : Attr(A), Form(F) { assert(!isImplicitConst()); + this->ByteSize.HasByteSize = ByteSize.hasValue(); + if (this->ByteSize.HasByteSize) + this->ByteSize.ByteSize = *ByteSize; } dwarf::Attribute Attr; @@ -45,17 +48,21 @@ public: /// attributes and as value for implicit_const ones, indicated by /// Form == DW_FORM_implicit_const. /// The following cases are distinguished: - /// * Form != DW_FORM_implicit_const and ByteSize has a value: + /// * Form != DW_FORM_implicit_const and HasByteSize is true: /// ByteSize contains the fixed size in bytes for the Form in this /// object. - /// * Form != DW_FORM_implicit_const and ByteSize is None: + /// * Form != DW_FORM_implicit_const and HasByteSize is false: /// byte size of Form either varies according to the DWARFUnit /// that it is contained in or the value size varies and must be /// decoded from the debug information in order to determine its size. /// * Form == DW_FORM_implicit_const: /// Value contains value for the implicit_const attribute. + struct ByteSizeStorage { + bool HasByteSize; + uint8_t ByteSize; + }; union { - Optional<uint8_t> ByteSize; + ByteSizeStorage ByteSize; int64_t Value; }; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp index 1fc54d2065e..a88dcfcf542 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp @@ -214,8 +214,8 @@ Optional<int64_t> DWARFAbbreviationDeclaration::AttributeSpec::getByteSize( const DWARFUnit &U) const { if (isImplicitConst()) return 0; - if (ByteSize) - return *ByteSize; + if (ByteSize.HasByteSize) + return ByteSize.ByteSize; Optional<int64_t> S; auto FixedByteSize = DWARFFormValue::getFixedByteSize(Form, U.getFormParams()); |