Skip to content

Commit 0fbd2b5

Browse files
committed
Merging r351327:
------------------------------------------------------------------------ r351327 | labath | 2019-01-16 13:19:22 +0100 (Wed, 16 Jan 2019) | 4 lines Revert "Simplify Value::GetValueByteSize()" This reverts commit r351250 because it breaks the SymbolFile/NativePDB/function-types-builtins.cpp. ------------------------------------------------------------------------ llvm-svn: 351342
1 parent ebec3ce commit 0fbd2b5

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

lldb/source/Core/Value.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,31 +210,35 @@ bool Value::ValueOf(ExecutionContext *exe_ctx) {
210210
}
211211

212212
uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
213+
uint64_t byte_size = 0;
214+
213215
switch (m_context_type) {
214216
case eContextTypeRegisterInfo: // RegisterInfo *
215-
if (GetRegisterInfo()) {
216-
if (error_ptr)
217-
error_ptr->Clear();
218-
return GetRegisterInfo()->byte_size;
219-
}
217+
if (GetRegisterInfo())
218+
byte_size = GetRegisterInfo()->byte_size;
220219
break;
221220

222221
case eContextTypeInvalid:
223222
case eContextTypeLLDBType: // Type *
224223
case eContextTypeVariable: // Variable *
225224
{
226-
auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
227-
if (llvm::Optional<uint64_t> size = GetCompilerType().GetByteSize(scope)) {
228-
if (error_ptr)
229-
error_ptr->Clear();
230-
return *size;
231-
}
232-
break;
225+
const CompilerType &ast_type = GetCompilerType();
226+
if (ast_type.IsValid())
227+
if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
228+
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
229+
byte_size = *size;
230+
} break;
233231
}
232+
233+
if (error_ptr) {
234+
if (byte_size == 0) {
235+
if (error_ptr->Success())
236+
error_ptr->SetErrorString("Unable to determine byte size.");
237+
} else {
238+
error_ptr->Clear();
239+
}
234240
}
235-
if (error_ptr && error_ptr->Success())
236-
error_ptr->SetErrorString("Unable to determine byte size.");
237-
return 0;
241+
return byte_size;
238242
}
239243

240244
const CompilerType &Value::GetCompilerType() {

0 commit comments

Comments
 (0)