summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-01-16 12:19:22 +0000
committerPavel Labath <pavel@labath.sk>2019-01-16 12:19:22 +0000
commitc2ec4c18228e59c85b6a4ec7f56d1aa7a91767d1 (patch)
tree5648caad952c69ebc5d105f6d66e4b8e336f2897
parent54fb3f658780179d46c8f12b79c1482887464a26 (diff)
Revert "Simplify Value::GetValueByteSize()"
This reverts commit r351250 because it breaks the SymbolFile/NativePDB/function-types-builtins.cpp.
-rw-r--r--lldb/source/Core/Value.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 8e18458b90c..98a39ea9531 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/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() {