summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-01-15 21:26:03 +0000
committerAdrian Prantl <aprantl@apple.com>2019-01-15 21:26:03 +0000
commit0216ac2bcd2c3cb3fdf663fe8d36dcb661caa568 (patch)
tree2dd2749c861986e9af23070b31b1ec425ae85c87
parent8a888b51301480da868a7fcfce68432ad76b6939 (diff)
Simplify Value::GetValueByteSize()
-rw-r--r--lldb/source/Core/Value.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 873bd6672fd..b8f95de9393 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -210,35 +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())
- if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
- exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
- byte_size = *size;
- } 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() {