Skip to content

Commit 642dcd7

Browse files
committed
[lldb] Upgrade CompilerType::GetBitSize to return llvm::Expected (llvm#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 (cherry picked from commit 878a64f)
1 parent 638f45c commit 642dcd7

File tree

80 files changed

+588
-369
lines changed

Some content is hidden

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

80 files changed

+588
-369
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,10 @@ class CompilerType {
418418
struct IntegralTemplateArgument;
419419

420420
/// Return the size of the type in bytes.
421-
std::optional<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const;
421+
llvm::Expected<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const;
422422
/// Return the size of the type in bits.
423-
std::optional<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const;
423+
llvm::Expected<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const;
424+
424425
/// Return the stride of the type in bits.
425426
std::optional<uint64_t>
426427
GetByteStride(ExecutionContextScope *exe_scope) const;

lldb/include/lldb/Symbol/Type.h

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

461461
ConstString GetBaseName();
462462

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

465465
llvm::Expected<uint32_t> GetNumChildren(bool omit_empty_base_classes);
466466

lldb/include/lldb/Symbol/TypeSystem.h

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

342342
virtual const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) = 0;
343343

344-
virtual std::optional<uint64_t>
344+
virtual llvm::Expected<uint64_t>
345345
GetBitSize(lldb::opaque_compiler_type_t type,
346346
ExecutionContextScope *exe_scope) = 0;
347347

lldb/include/lldb/Target/StackFrameRecognizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {
177177
SetName(parent.GetName());
178178
}
179179

180-
std::optional<uint64_t> GetByteSize() override {
180+
llvm::Expected<uint64_t> GetByteSize() override {
181181
return m_parent->GetByteSize();
182182
}
183183
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)