diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 18:45:14 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 18:45:14 +0000 |
| commit | 38e660c46fb9f2b2a33b2f771dc8777d50ace53a (patch) | |
| tree | 316b04d5f7db0352a4ebe6c9447ad3f5ff86af59 /source/Core/Value.cpp | |
| parent | 94994d372d014ce4c8758b9605d63fae651bd8aa (diff) | |
Notes
Diffstat (limited to 'source/Core/Value.cpp')
| -rw-r--r-- | source/Core/Value.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp index 8e18458b90c2..98a39ea95315 100644 --- a/source/Core/Value.cpp +++ b/source/Core/Value.cpp @@ -210,31 +210,35 @@ 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()) { - if (error_ptr) - error_ptr->Clear(); - return GetRegisterInfo()->byte_size; - } + if (GetRegisterInfo()) + byte_size = GetRegisterInfo()->byte_size; break; case eContextTypeInvalid: case eContextTypeLLDBType: // Type * case eContextTypeVariable: // Variable * { - 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; + 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(); + } } - if (error_ptr && error_ptr->Success()) - error_ptr->SetErrorString("Unable to determine byte size."); - return 0; + return byte_size; } const CompilerType &Value::GetCompilerType() { |
