forked from OSchip/llvm-project
Simplify code by using Optional::getValueOr()
llvm-svn: 351264
This commit is contained in:
parent
76cb3089de
commit
222474b9ff
|
@ -112,9 +112,7 @@ uint64_t ValueObjectVariable::GetByteSize() {
|
||||||
if (!type.IsValid())
|
if (!type.IsValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
llvm::Optional<uint64_t> size =
|
return type.GetByteSize(exe_ctx.GetBestExecutionContextScope()).getValueOr(0);
|
||||||
type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
|
|
||||||
return size ? *size : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lldb::ValueType ValueObjectVariable::GetValueType() const {
|
lldb::ValueType ValueObjectVariable::GetValueType() const {
|
||||||
|
|
|
@ -577,8 +577,7 @@ private:
|
||||||
ReturnValueExtractor(Thread &thread, CompilerType &type,
|
ReturnValueExtractor(Thread &thread, CompilerType &type,
|
||||||
RegisterContext *reg_ctx, ProcessSP process_sp)
|
RegisterContext *reg_ctx, ProcessSP process_sp)
|
||||||
: m_thread(thread), m_type(type),
|
: m_thread(thread), m_type(type),
|
||||||
m_byte_size(m_type.GetByteSize(nullptr) ? *m_type.GetByteSize(nullptr)
|
m_byte_size(m_type.GetByteSize(nullptr).getValueOr(0)),
|
||||||
: 0),
|
|
||||||
m_data_ap(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
|
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_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
|
||||||
m_addr_size(
|
m_addr_size(
|
||||||
|
|
|
@ -337,9 +337,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
|
log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
|
||||||
m_result_name.GetCString(),
|
m_result_name.GetCString(),
|
||||||
m_result_type.GetByteSize(nullptr)
|
m_result_type.GetByteSize(nullptr).getValueOr(0));
|
||||||
? *m_result_type.GetByteSize(nullptr)
|
|
||||||
: 0);
|
|
||||||
|
|
||||||
// Construct a new result global and set up its metadata
|
// Construct a new result global and set up its metadata
|
||||||
|
|
||||||
|
|
|
@ -513,11 +513,11 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
|
||||||
CompilerType ivar_type =
|
CompilerType ivar_type =
|
||||||
encoding_to_type_sp->RealizeType(type, for_expression);
|
encoding_to_type_sp->RealizeType(type, for_expression);
|
||||||
if (ivar_type) {
|
if (ivar_type) {
|
||||||
llvm::Optional<uint64_t> ivar_size = ivar_type.GetByteSize(nullptr);
|
|
||||||
LLDB_LOGV(log,
|
LLDB_LOGV(log,
|
||||||
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
|
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
|
||||||
"{3}, type_size = {4}",
|
"{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;
|
Scalar offset_scalar;
|
||||||
Status error;
|
Status error;
|
||||||
const int offset_ptr_size = 4;
|
const int offset_ptr_size = 4;
|
||||||
|
|
Loading…
Reference in New Issue