summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2017-10-31 19:40:03 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2017-10-31 19:40:03 +0000
commit8732bbec1ec96d78c9d79df3c24aae686a7b7a91 (patch)
tree4730799d98e68902bf1b8c5bb5460310622e9e4b
parent992fc4ea2de587f73684c4a17d1c27eecbc9afb5 (diff)
downloadbcm5719-llvm-8732bbec1ec96d78c9d79df3c24aae686a7b7a91.tar.gz
bcm5719-llvm-8732bbec1ec96d78c9d79df3c24aae686a7b7a91.zip
[DWARF] Now that Optional is standard layout, put it into an union instead of splatting it.
No functionality change intended. llvm-svn: 317028
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h15
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp4
2 files changed, 6 insertions, 13 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
index 84b23398b8c..de49be5c0b5 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
@@ -33,11 +33,8 @@ public:
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;
@@ -48,21 +45,17 @@ 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 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;
};
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
index a88dcfcf542..1fc54d2065e 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.HasByteSize)
- return ByteSize.ByteSize;
+ if (ByteSize)
+ return *ByteSize;
Optional<int64_t> S;
auto FixedByteSize =
DWARFFormValue::getFixedByteSize(Form, U.getFormParams());
OpenPOWER on IntegriCloud