summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-01-15 22:30:01 +0000
committerAdrian Prantl <aprantl@apple.com>2019-01-15 22:30:01 +0000
commit326ef9a6ea2dccdb5ea5559b85560b4a20f9daa5 (patch)
tree62d094eeb09fe3e092901791b795596216af3e1a
parentba99eb0841cbb57e2c246705e69b646ac0f1f8d9 (diff)
Simplify code by using Optional::getValueOr()
-rw-r--r--lldb/source/Core/ValueObjectVariable.cpp4
-rw-r--r--lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp3
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp4
4 files changed, 5 insertions, 10 deletions
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index f026d77c9fa..4d401c56249 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -112,9 +112,7 @@ uint64_t ValueObjectVariable::GetByteSize() {
if (!type.IsValid())
return 0;
- llvm::Optional<uint64_t> size =
- type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
- return size ? *size : 0;
+ return type.GetByteSize(exe_ctx.GetBestExecutionContextScope()).getValueOr(0);
}
lldb::ValueType ValueObjectVariable::GetValueType() const {
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index b6240d90878..fb46b7dc7fb 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -577,8 +577,7 @@ private:
ReturnValueExtractor(Thread &thread, CompilerType &type,
RegisterContext *reg_ctx, ProcessSP process_sp)
: m_thread(thread), m_type(type),
- m_byte_size(m_type.GetByteSize(nullptr) ? *m_type.GetByteSize(nullptr)
- : 0),
+ m_byte_size(m_type.GetByteSize(nullptr).getValueOr(0)),
m_data_ap(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
m_addr_size(
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index d66ee83e0fe..3a7cd58b70a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -337,9 +337,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
if (log)
log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
m_result_name.GetCString(),
- m_result_type.GetByteSize(nullptr)
- ? *m_result_type.GetByteSize(nullptr)
- : 0);
+ m_result_type.GetByteSize(nullptr).getValueOr(0));
// Construct a new result global and set up its metadata
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 8253fc8cfb4..679c3c850e5 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -513,11 +513,11 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
CompilerType ivar_type =
encoding_to_type_sp->RealizeType(type, for_expression);
if (ivar_type) {
- llvm::Optional<uint64_t> ivar_size = ivar_type.GetByteSize(nullptr);
LLDB_LOGV(log,
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
"{3}, type_size = {4}",
- name, type, offset_ptr, size, ivar_size ? *ivar_size : 0);
+ name, type, offset_ptr, size,
+ ivar_type.GetByteSize(nullptr).getValueOr(0));
Scalar offset_scalar;
Status error;
const int offset_ptr_size = 4;