Skip to content

Commit 69c0ddc

Browse files
committed
Remove unnecessary arguments, add error output from GetDereferencedType.
1 parent 1ca8c5f commit 69c0ddc

File tree

7 files changed

+46
-61
lines changed

7 files changed

+46
-61
lines changed

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,13 @@ class CompilerType {
433433

434434
CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const;
435435

436-
llvm::Expected<CompilerType> GetDereferencedType(
437-
ExecutionContext *exe_ctx, bool transparent_pointers,
438-
bool omit_empty_base_classes, bool ignore_array_bounds,
439-
std::string &child_name, uint32_t &child_byte_size,
440-
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
441-
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
442-
bool &child_is_deref_of_parent, ValueObject *valobj,
443-
uint64_t &language_flags, bool &type_valid) const;
436+
llvm::Expected<CompilerType>
437+
GetDereferencedType(ExecutionContext *exe_ctx, std::string &child_name,
438+
uint32_t &child_byte_size, int32_t &child_byte_offset,
439+
uint32_t &child_bitfield_bit_size,
440+
uint32_t &child_bitfield_bit_offset,
441+
bool &child_is_base_class, ValueObject *valobj,
442+
uint64_t &language_flags, bool &type_valid) const;
444443

445444
llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
446445
ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,9 @@ class TypeSystem : public PluginInterface,
366366

367367
virtual llvm::Expected<CompilerType> GetDereferencedType(
368368
lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
369-
bool transparent_pointers, bool omit_empty_base_classes,
370-
bool ignore_array_bounds, std::string &child_name,
371-
uint32_t &child_byte_size, int32_t &child_byte_offset,
372-
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
373-
bool &child_is_base_class, bool &child_is_deref_of_parent,
369+
std::string &child_name, uint32_t &child_byte_size,
370+
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
371+
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
374372
ValueObject *valobj, uint64_t &language_flags, bool &type_valid) = 0;
375373

376374
virtual llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6182,21 +6182,19 @@ uint32_t TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
61826182

61836183
llvm::Expected<CompilerType> TypeSystemClang::GetDereferencedType(
61846184
lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
6185-
bool transparent_pointers, bool omit_empty_base_classes,
6186-
bool ignore_array_bounds, std::string &child_name,
6187-
uint32_t &child_byte_size, int32_t &child_byte_offset,
6188-
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6189-
bool &child_is_base_class, bool &child_is_deref_of_parent,
6185+
std::string &child_name, uint32_t &child_byte_size,
6186+
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
6187+
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
61906188
ValueObject *valobj, uint64_t &language_flags, bool &type_valid) {
61916189
type_valid = IsPointerOrReferenceType(type, nullptr) ||
61926190
IsArrayType(type, nullptr, nullptr, nullptr);
61936191
if (!type_valid)
6194-
return CompilerType();
6192+
return llvm::createStringError("not a pointer, reference or array type");
6193+
bool child_is_deref_of_parent;
61956194
return GetChildCompilerTypeAtIndex(
6196-
type, exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
6197-
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6198-
child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
6199-
child_is_deref_of_parent, valobj, language_flags);
6195+
type, exe_ctx, 0, false, true, false, child_name, child_byte_size,
6196+
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6197+
child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
62006198
}
62016199

62026200
llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
@@ -6563,8 +6561,6 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
65636561
return size_or_err.takeError();
65646562
child_byte_size = *size_or_err;
65656563
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6566-
if (idx == 0)
6567-
child_is_deref_of_parent = true;
65686564
return element_type;
65696565
}
65706566
}

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,11 +891,9 @@ class TypeSystemClang : public TypeSystem {
891891

892892
llvm::Expected<CompilerType> GetDereferencedType(
893893
lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
894-
bool transparent_pointers, bool omit_empty_base_classes,
895-
bool ignore_array_bounds, std::string &child_name,
896-
uint32_t &child_byte_size, int32_t &child_byte_offset,
897-
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
898-
bool &child_is_base_class, bool &child_is_deref_of_parent,
894+
std::string &child_name, uint32_t &child_byte_size,
895+
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
896+
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
899897
ValueObject *valobj, uint64_t &language_flags, bool &type_valid) override;
900898

901899
llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(

lldb/source/Symbol/CompilerType.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -894,21 +894,17 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const {
894894
}
895895

896896
llvm::Expected<CompilerType> CompilerType::GetDereferencedType(
897-
ExecutionContext *exe_ctx, bool transparent_pointers,
898-
bool omit_empty_base_classes, bool ignore_array_bounds,
899-
std::string &child_name, uint32_t &child_byte_size,
900-
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
901-
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
902-
bool &child_is_deref_of_parent, ValueObject *valobj,
903-
uint64_t &language_flags, bool &type_valid) const {
897+
ExecutionContext *exe_ctx, std::string &child_name,
898+
uint32_t &child_byte_size, int32_t &child_byte_offset,
899+
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
900+
bool &child_is_base_class, ValueObject *valobj, uint64_t &language_flags,
901+
bool &type_valid) const {
904902
if (IsValid())
905903
if (auto type_system_sp = GetTypeSystem())
906904
return type_system_sp->GetDereferencedType(
907-
m_type, exe_ctx, transparent_pointers, omit_empty_base_classes,
908-
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
905+
m_type, exe_ctx, child_name, child_byte_size, child_byte_offset,
909906
child_bitfield_bit_size, child_bitfield_bit_offset,
910-
child_is_base_class, child_is_deref_of_parent, valobj, language_flags,
911-
type_valid);
907+
child_is_base_class, valobj, language_flags, type_valid);
912908
return CompilerType();
913909
}
914910

lldb/source/ValueObject/ValueObject.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,16 +2794,12 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
27942794
if (m_deref_valobj)
27952795
return m_deref_valobj->GetSP();
27962796

2797-
bool omit_empty_base_classes = true;
2798-
bool ignore_array_bounds = false;
27992797
std::string child_name_str;
28002798
uint32_t child_byte_size = 0;
28012799
int32_t child_byte_offset = 0;
28022800
uint32_t child_bitfield_bit_size = 0;
28032801
uint32_t child_bitfield_bit_offset = 0;
28042802
bool child_is_base_class = false;
2805-
bool child_is_deref_of_parent = false;
2806-
const bool transparent_pointers = false;
28072803
CompilerType compiler_type = GetCompilerType();
28082804
uint64_t language_flags = 0;
28092805
bool is_valid_dereference_type = false;
@@ -2812,17 +2808,20 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28122808

28132809
CompilerType child_compiler_type;
28142810
auto child_compiler_type_or_err = compiler_type.GetDereferencedType(
2815-
&exe_ctx, transparent_pointers, omit_empty_base_classes,
2816-
ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
2811+
&exe_ctx, child_name_str, child_byte_size, child_byte_offset,
28172812
child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
2818-
child_is_deref_of_parent, this, language_flags,
2819-
is_valid_dereference_type);
2813+
this, language_flags, is_valid_dereference_type);
28202814

2821-
if (!child_compiler_type_or_err && is_valid_dereference_type)
2822-
LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
2823-
child_compiler_type_or_err.takeError(),
2824-
"could not find child: {0}");
2825-
else
2815+
std::string deref_error;
2816+
if (!child_compiler_type_or_err) {
2817+
auto err = child_compiler_type_or_err.takeError();
2818+
if (err.isA<llvm::StringError>()) {
2819+
deref_error = llvm::toString(std::move(err));
2820+
LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
2821+
llvm::createStringError(deref_error),
2822+
"could not find child: {0}");
2823+
}
2824+
} else
28262825
child_compiler_type = *child_compiler_type_or_err;
28272826

28282827
if (is_valid_dereference_type) {
@@ -2834,8 +2833,7 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28342833
m_deref_valobj = new ValueObjectChild(
28352834
*this, child_compiler_type, child_name, child_byte_size,
28362835
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
2837-
child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
2838-
language_flags);
2836+
child_is_base_class, true, eAddressTypeInvalid, language_flags);
28392837
}
28402838

28412839
// In case of incomplete child compiler type, use the pointee type and try
@@ -2855,8 +2853,8 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28552853
m_deref_valobj = new ValueObjectChild(
28562854
*this, child_compiler_type, child_name, child_byte_size,
28572855
child_byte_offset, child_bitfield_bit_size,
2858-
child_bitfield_bit_offset, child_is_base_class,
2859-
child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
2856+
child_bitfield_bit_offset, child_is_base_class, true,
2857+
eAddressTypeInvalid, language_flags);
28602858
}
28612859
}
28622860
}
@@ -2871,13 +2869,13 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28712869
StreamString strm;
28722870
GetExpressionPath(strm);
28732871

2874-
if (is_valid_dereference_type)
2872+
if (deref_error.empty())
28752873
error = Status::FromErrorStringWithFormat(
28762874
"dereference failed: (%s) %s",
28772875
GetTypeName().AsCString("<invalid type>"), strm.GetData());
28782876
else
28792877
error = Status::FromErrorStringWithFormat(
2880-
"not a pointer or reference type: (%s) %s",
2878+
"dereference failed: %s: (%s) %s", deref_error.c_str(),
28812879
GetTypeName().AsCString("<invalid type>"), strm.GetData());
28822880
return ValueObjectSP();
28832881
}

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def cleanup():
8888
self.expect(
8989
"frame variable *number_not_engaged",
9090
error=True,
91-
substrs=["not a pointer or reference type"],
91+
substrs=["dereference failed: not a"],
9292
)
9393

9494
@add_test_categories(["libc++"])

0 commit comments

Comments
 (0)