Skip to content

Commit 878a64f

Browse files
[lldb] Upgrade CompilerType::GetBitSize to return llvm::Expected (#129601)
This patch pushes the error handling boundary for the GetBitSize() methods from Runtime into the Type and CompilerType APIs. This makes it easier to diagnose problems thanks to more meaningful error messages being available. GetBitSize() is often the first thing LLDB asks about a type, so this method is particularly important for a better user experience. rdar://145667239
1 parent 03da079 commit 878a64f

File tree

77 files changed

+505
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+505
-355
lines changed

lldb/include/lldb/Expression/ExpressionVariable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ExpressionVariable
3333

3434
virtual ~ExpressionVariable() = default;
3535

36-
std::optional<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }
36+
llvm::Expected<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }
3737

3838
ConstString GetName() { return m_frozen_sp->GetName(); }
3939

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ class CompilerType {
391391
struct IntegralTemplateArgument;
392392

393393
/// Return the size of the type in bytes.
394-
std::optional<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const;
394+
llvm::Expected<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const;
395395
/// Return the size of the type in bits.
396-
std::optional<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const;
396+
llvm::Expected<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const;
397397

398398
lldb::Encoding GetEncoding(uint64_t &count) const;
399399

lldb/include/lldb/Symbol/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
480480

481481
ConstString GetBaseName();
482482

483-
std::optional<uint64_t> GetByteSize(ExecutionContextScope *exe_scope);
483+
llvm::Expected<uint64_t> GetByteSize(ExecutionContextScope *exe_scope);
484484

485485
llvm::Expected<uint32_t> GetNumChildren(bool omit_empty_base_classes);
486486

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class TypeSystem : public PluginInterface,
312312

313313
virtual const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) = 0;
314314

315-
virtual std::optional<uint64_t>
315+
virtual llvm::Expected<uint64_t>
316316
GetBitSize(lldb::opaque_compiler_type_t type,
317317
ExecutionContextScope *exe_scope) = 0;
318318

lldb/include/lldb/Target/StackFrameRecognizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {
180180
SetName(parent.GetName());
181181
}
182182

183-
std::optional<uint64_t> GetByteSize() override {
183+
llvm::Expected<uint64_t> GetByteSize() override {
184184
return m_parent->GetByteSize();
185185
}
186186
lldb::ValueType GetValueType() const override { return m_type; }

lldb/include/lldb/ValueObject/ValueObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class ValueObject {
357357
virtual bool CanProvideValue();
358358

359359
// Subclasses must implement the functions below.
360-
virtual std::optional<uint64_t> GetByteSize() = 0;
360+
virtual llvm::Expected<uint64_t> GetByteSize() = 0;
361361

362362
virtual lldb::ValueType GetValueType() const = 0;
363363

lldb/include/lldb/ValueObject/ValueObjectCast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ValueObjectCast : public ValueObject {
3030
static lldb::ValueObjectSP Create(ValueObject &parent, ConstString name,
3131
const CompilerType &cast_type);
3232

33-
std::optional<uint64_t> GetByteSize() override;
33+
llvm::Expected<uint64_t> GetByteSize() override;
3434

3535
llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
3636

lldb/include/lldb/ValueObject/ValueObjectChild.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ValueObjectChild : public ValueObject {
2929
public:
3030
~ValueObjectChild() override;
3131

32-
std::optional<uint64_t> GetByteSize() override { return m_byte_size; }
32+
llvm::Expected<uint64_t> GetByteSize() override { return m_byte_size; }
3333

3434
lldb::offset_t GetByteOffset() override { return m_byte_offset; }
3535

lldb/include/lldb/ValueObject/ValueObjectConstResult.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ValueObjectConstResult : public ValueObject {
6464
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
6565
Status &&error);
6666

67-
std::optional<uint64_t> GetByteSize() override;
67+
llvm::Expected<uint64_t> GetByteSize() override;
6868

6969
lldb::ValueType GetValueType() const override;
7070

lldb/include/lldb/ValueObject/ValueObjectDynamicValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ValueObjectDynamicValue : public ValueObject {
3535
public:
3636
~ValueObjectDynamicValue() override = default;
3737

38-
std::optional<uint64_t> GetByteSize() override;
38+
llvm::Expected<uint64_t> GetByteSize() override;
3939

4040
ConstString GetTypeName() override;
4141

0 commit comments

Comments
 (0)