Skip to content

Commit

Permalink
[DWARF] Now that Optional is standard layout, put it into an union in…
Browse files Browse the repository at this point in the history
…stead of splatting it.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317028 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Oct 31, 2017
1 parent aeaa65a commit 159d0ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 4 additions & 11 deletions include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ class DWARFAbbreviationDeclaration {
assert(isImplicitConst());
}
AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize)
: Attr(A), Form(F) {
: Attr(A), Form(F), ByteSize(ByteSize) {
assert(!isImplicitConst());
this->ByteSize.HasByteSize = ByteSize.hasValue();
if (this->ByteSize.HasByteSize)
this->ByteSize.ByteSize = *ByteSize;
}

dwarf::Attribute Attr;
Expand All @@ -48,21 +45,17 @@ class DWARFAbbreviationDeclaration {
/// 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 HasByteSize is true:
/// * Form != DW_FORM_implicit_const and ByteSize has a value:
/// ByteSize contains the fixed size in bytes for the Form in this
/// object.
/// * Form != DW_FORM_implicit_const and HasByteSize is false:
/// * Form != DW_FORM_implicit_const and ByteSize is None:
/// 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 {
ByteSizeStorage ByteSize;
Optional<uint8_t> ByteSize;
int64_t Value;
};

Expand Down
4 changes: 2 additions & 2 deletions lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ Optional<int64_t> DWARFAbbreviationDeclaration::AttributeSpec::getByteSize(
const DWARFUnit &U) const {
if (isImplicitConst())
return 0;
if (ByteSize.HasByteSize)
return ByteSize.ByteSize;
if (ByteSize)
return *ByteSize;
Optional<int64_t> S;
auto FixedByteSize =
DWARFFormValue::getFixedByteSize(Form, U.getFormParams());
Expand Down

0 comments on commit 159d0ec

Please sign in to comment.