diff options
Diffstat (limited to 'source/Core/Value.cpp')
-rw-r--r-- | source/Core/Value.cpp | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp index 254c9008babb..8e18458b90c2 100644 --- a/source/Core/Value.cpp +++ b/source/Core/Value.cpp @@ -9,9 +9,8 @@ #include "lldb/Core/Value.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -21,20 +20,21 @@ #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Endian.h" // for InlHostByteOrder -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/Endian.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for DataBufferSP, ModuleSP -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include <memory> // for make_shared -#include <string> // for string +#include <memory> +#include <string> -#include <inttypes.h> // for PRIx64 +#include <inttypes.h> using namespace lldb; using namespace lldb_private; @@ -210,34 +210,31 @@ bool Value::ValueOf(ExecutionContext *exe_ctx) { } uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) { - uint64_t byte_size = 0; - switch (m_context_type) { case eContextTypeRegisterInfo: // RegisterInfo * - if (GetRegisterInfo()) - byte_size = GetRegisterInfo()->byte_size; + if (GetRegisterInfo()) { + if (error_ptr) + error_ptr->Clear(); + return GetRegisterInfo()->byte_size; + } break; case eContextTypeInvalid: case eContextTypeLLDBType: // Type * case eContextTypeVariable: // Variable * { - const CompilerType &ast_type = GetCompilerType(); - if (ast_type.IsValid()) - byte_size = ast_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr); - } break; - } - - if (error_ptr) { - if (byte_size == 0) { - if (error_ptr->Success()) - error_ptr->SetErrorString("Unable to determine byte size."); - } else { - error_ptr->Clear(); + auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; + if (llvm::Optional<uint64_t> size = GetCompilerType().GetByteSize(scope)) { + if (error_ptr) + error_ptr->Clear(); + return *size; } + break; } - return byte_size; + } + if (error_ptr && error_ptr->Success()) + error_ptr->SetErrorString("Unable to determine byte size."); + return 0; } const CompilerType &Value::GetCompilerType() { @@ -344,10 +341,9 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, uint32_t limit_byte_size = UINT32_MAX; - if (ast_type.IsValid()) { - limit_byte_size = ast_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr); - } + if (llvm::Optional<uint64_t> size = ast_type.GetByteSize( + exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)) + limit_byte_size = *size; if (limit_byte_size <= m_value.GetByteSize()) { if (m_value.GetData(data, limit_byte_size)) |