Skip to content

Commit 0d5348a

Browse files
committed
Remove unnecessary arguments, add error output from GetDereferencedType.
1 parent ca45436 commit 0d5348a

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
@@ -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
@@ -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
@@ -2850,16 +2850,12 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28502850
if (m_deref_valobj)
28512851
return m_deref_valobj->GetSP();
28522852

2853-
bool omit_empty_base_classes = true;
2854-
bool ignore_array_bounds = false;
28552853
std::string child_name_str;
28562854
uint32_t child_byte_size = 0;
28572855
int32_t child_byte_offset = 0;
28582856
uint32_t child_bitfield_bit_size = 0;
28592857
uint32_t child_bitfield_bit_offset = 0;
28602858
bool child_is_base_class = false;
2861-
bool child_is_deref_of_parent = false;
2862-
const bool transparent_pointers = false;
28632859
CompilerType compiler_type = GetCompilerType();
28642860
uint64_t language_flags = 0;
28652861
bool is_valid_dereference_type = false;
@@ -2868,17 +2864,20 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28682864

28692865
CompilerType child_compiler_type;
28702866
auto child_compiler_type_or_err = compiler_type.GetDereferencedType(
2871-
&exe_ctx, transparent_pointers, omit_empty_base_classes,
2872-
ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
2867+
&exe_ctx, child_name_str, child_byte_size, child_byte_offset,
28732868
child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
2874-
child_is_deref_of_parent, this, language_flags,
2875-
is_valid_dereference_type);
2869+
this, language_flags, is_valid_dereference_type);
28762870

2877-
if (!child_compiler_type_or_err && is_valid_dereference_type)
2878-
LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
2879-
child_compiler_type_or_err.takeError(),
2880-
"could not find child: {0}");
2881-
else
2871+
std::string deref_error;
2872+
if (!child_compiler_type_or_err) {
2873+
auto err = child_compiler_type_or_err.takeError();
2874+
if (err.isA<llvm::StringError>()) {
2875+
deref_error = llvm::toString(std::move(err));
2876+
LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
2877+
llvm::createStringError(deref_error),
2878+
"could not find child: {0}");
2879+
}
2880+
} else
28822881
child_compiler_type = *child_compiler_type_or_err;
28832882

28842883
if (is_valid_dereference_type) {
@@ -2890,8 +2889,7 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
28902889
m_deref_valobj = new ValueObjectChild(
28912890
*this, child_compiler_type, child_name, child_byte_size,
28922891
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
2893-
child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
2894-
language_flags);
2892+
child_is_base_class, true, eAddressTypeInvalid, language_flags);
28952893
}
28962894

28972895
// In case of incomplete child compiler type, use the pointee type and try
@@ -2911,8 +2909,8 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
29112909
m_deref_valobj = new ValueObjectChild(
29122910
*this, child_compiler_type, child_name, child_byte_size,
29132911
child_byte_offset, child_bitfield_bit_size,
2914-
child_bitfield_bit_offset, child_is_base_class,
2915-
child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
2912+
child_bitfield_bit_offset, child_is_base_class, true,
2913+
eAddressTypeInvalid, language_flags);
29162914
}
29172915
}
29182916
}
@@ -2930,13 +2928,13 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
29302928
StreamString strm;
29312929
GetExpressionPath(strm);
29322930

2933-
if (is_valid_dereference_type)
2931+
if (deref_error.empty())
29342932
error = Status::FromErrorStringWithFormat(
29352933
"dereference failed: (%s) %s",
29362934
GetTypeName().AsCString("<invalid type>"), strm.GetData());
29372935
else
29382936
error = Status::FromErrorStringWithFormat(
2939-
"not a pointer or reference type: (%s) %s",
2937+
"dereference failed: %s: (%s) %s", deref_error.c_str(),
29402938
GetTypeName().AsCString("<invalid type>"), strm.GetData());
29412939
return ValueObjectSP();
29422940
}

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)