Skip to content

Commit e5d6984

Browse files
committed
Remove unnecessary arguments, add error output from GetDereferencedType.
1 parent 06769af commit e5d6984

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
@@ -439,14 +439,13 @@ class CompilerType {
439439
uint32_t *bitfield_bit_size_ptr = nullptr,
440440
bool *is_bitfield_ptr = nullptr) const;
441441

442-
llvm::Expected<CompilerType> GetDereferencedType(
443-
ExecutionContext *exe_ctx, bool transparent_pointers,
444-
bool omit_empty_base_classes, bool ignore_array_bounds,
445-
std::string &child_name, uint32_t &child_byte_size,
446-
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
447-
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
448-
bool &child_is_deref_of_parent, ValueObject *valobj,
449-
uint64_t &language_flags, bool &type_valid) const;
442+
llvm::Expected<CompilerType>
443+
GetDereferencedType(ExecutionContext *exe_ctx, std::string &child_name,
444+
uint32_t &child_byte_size, int32_t &child_byte_offset,
445+
uint32_t &child_bitfield_bit_size,
446+
uint32_t &child_bitfield_bit_offset,
447+
bool &child_is_base_class, ValueObject *valobj,
448+
uint64_t &language_flags, bool &type_valid) const;
450449

451450
llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
452451
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
@@ -6203,21 +6203,19 @@ uint32_t TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
62036203

62046204
llvm::Expected<CompilerType> TypeSystemClang::GetDereferencedType(
62056205
lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
6206-
bool transparent_pointers, bool omit_empty_base_classes,
6207-
bool ignore_array_bounds, std::string &child_name,
6208-
uint32_t &child_byte_size, int32_t &child_byte_offset,
6209-
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6210-
bool &child_is_base_class, bool &child_is_deref_of_parent,
6206+
std::string &child_name, uint32_t &child_byte_size,
6207+
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
6208+
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
62116209
ValueObject *valobj, uint64_t &language_flags, bool &type_valid) {
62126210
type_valid = IsPointerOrReferenceType(type, nullptr) ||
62136211
IsArrayType(type, nullptr, nullptr, nullptr);
62146212
if (!type_valid)
6215-
return CompilerType();
6213+
return llvm::createStringError("not a pointer, reference or array type");
6214+
bool child_is_deref_of_parent;
62166215
return GetChildCompilerTypeAtIndex(
6217-
type, exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
6218-
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6219-
child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
6220-
child_is_deref_of_parent, valobj, language_flags);
6216+
type, exe_ctx, 0, false, true, false, child_name, child_byte_size,
6217+
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6218+
child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
62216219
}
62226220

62236221
llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
@@ -6584,8 +6582,6 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
65846582
return size_or_err.takeError();
65856583
child_byte_size = *size_or_err;
65866584
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6587-
if (idx == 0)
6588-
child_is_deref_of_parent = true;
65896585
return element_type;
65906586
}
65916587
}

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
@@ -913,21 +913,17 @@ uint32_t CompilerType::GetIndexOfFieldWithName(
913913
}
914914

915915
llvm::Expected<CompilerType> CompilerType::GetDereferencedType(
916-
ExecutionContext *exe_ctx, bool transparent_pointers,
917-
bool omit_empty_base_classes, bool ignore_array_bounds,
918-
std::string &child_name, uint32_t &child_byte_size,
919-
int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
920-
uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
921-
bool &child_is_deref_of_parent, ValueObject *valobj,
922-
uint64_t &language_flags, bool &type_valid) const {
916+
ExecutionContext *exe_ctx, std::string &child_name,
917+
uint32_t &child_byte_size, int32_t &child_byte_offset,
918+
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
919+
bool &child_is_base_class, ValueObject *valobj, uint64_t &language_flags,
920+
bool &type_valid) const {
923921
if (IsValid())
924922
if (auto type_system_sp = GetTypeSystem())
925923
return type_system_sp->GetDereferencedType(
926-
m_type, exe_ctx, transparent_pointers, omit_empty_base_classes,
927-
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
924+
m_type, exe_ctx, child_name, child_byte_size, child_byte_offset,
928925
child_bitfield_bit_size, child_bitfield_bit_offset,
929-
child_is_base_class, child_is_deref_of_parent, valobj, language_flags,
930-
type_valid);
926+
child_is_base_class, valobj, language_flags, type_valid);
931927
return CompilerType();
932928
}
933929

lldb/source/ValueObject/ValueObject.cpp

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

2847-
bool omit_empty_base_classes = true;
2848-
bool ignore_array_bounds = false;
28492847
std::string child_name_str;
28502848
uint32_t child_byte_size = 0;
28512849
int32_t child_byte_offset = 0;
28522850
uint32_t child_bitfield_bit_size = 0;
28532851
uint32_t child_bitfield_bit_offset = 0;
28542852
bool child_is_base_class = false;
2855-
bool child_is_deref_of_parent = false;
2856-
const bool transparent_pointers = false;
28572853
CompilerType compiler_type = GetCompilerType();
28582854
uint64_t language_flags = 0;
28592855
bool is_valid_dereference_type = false;
@@ -2862,17 +2858,20 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28622858

28632859
CompilerType child_compiler_type;
28642860
auto child_compiler_type_or_err = compiler_type.GetDereferencedType(
2865-
&exe_ctx, transparent_pointers, omit_empty_base_classes,
2866-
ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
2861+
&exe_ctx, child_name_str, child_byte_size, child_byte_offset,
28672862
child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
2868-
child_is_deref_of_parent, this, language_flags,
2869-
is_valid_dereference_type);
2863+
this, language_flags, is_valid_dereference_type);
28702864

2871-
if (!child_compiler_type_or_err && is_valid_dereference_type)
2872-
LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
2873-
child_compiler_type_or_err.takeError(),
2874-
"could not find child: {0}");
2875-
else
2865+
std::string deref_error;
2866+
if (!child_compiler_type_or_err) {
2867+
auto err = child_compiler_type_or_err.takeError();
2868+
if (err.isA<llvm::StringError>()) {
2869+
deref_error = llvm::toString(std::move(err));
2870+
LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
2871+
llvm::createStringError(deref_error),
2872+
"could not find child: {0}");
2873+
}
2874+
} else
28762875
child_compiler_type = *child_compiler_type_or_err;
28772876

28782877
if (is_valid_dereference_type) {
@@ -2884,8 +2883,7 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28842883
m_deref_valobj = new ValueObjectChild(
28852884
*this, child_compiler_type, child_name, child_byte_size,
28862885
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
2887-
child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
2888-
language_flags);
2886+
child_is_base_class, true, eAddressTypeInvalid, language_flags);
28892887
}
28902888

28912889
// In case of incomplete child compiler type, use the pointee type and try
@@ -2905,8 +2903,8 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
29052903
m_deref_valobj = new ValueObjectChild(
29062904
*this, child_compiler_type, child_name, child_byte_size,
29072905
child_byte_offset, child_bitfield_bit_size,
2908-
child_bitfield_bit_offset, child_is_base_class,
2909-
child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
2906+
child_bitfield_bit_offset, child_is_base_class, true,
2907+
eAddressTypeInvalid, language_flags);
29102908
}
29112909
}
29122910
}
@@ -2924,13 +2922,13 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
29242922
StreamString strm;
29252923
GetExpressionPath(strm);
29262924

2927-
if (is_valid_dereference_type)
2925+
if (deref_error.empty())
29282926
error = Status::FromErrorStringWithFormat(
29292927
"dereference failed: (%s) %s",
29302928
GetTypeName().AsCString("<invalid type>"), strm.GetData());
29312929
else
29322930
error = Status::FromErrorStringWithFormat(
2933-
"not a pointer or reference type: (%s) %s",
2931+
"dereference failed: %s: (%s) %s", deref_error.c_str(),
29342932
GetTypeName().AsCString("<invalid type>"), strm.GetData());
29352933
return ValueObjectSP();
29362934
}

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)