-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LLDB][NFC] Remove dead code #68927
[LLDB][NFC] Remove dead code #68927
Conversation
ddea911
to
8671fd2
Compare
@llvm/pr-subscribers-lldb Author: Walter Erquinigo (walter-erquinigo) ChangesI found this type/typesystem code that is dead and seems to have been replaced by the ValueObjectPrinter. Patch is 25.20 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/68927.diff 7 Files Affected:
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 2d7092d2c93f84d..1443487229eb83b 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -437,12 +437,6 @@ class CompilerType {
LLVM_DUMP_METHOD void dump() const;
#endif
- void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
- const DataExtractor &data, lldb::offset_t data_offset,
- size_t data_byte_size, uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset, bool show_types,
- bool show_summary, bool verbose, uint32_t depth);
-
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data,
lldb::offset_t data_offset, size_t data_byte_size,
uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 046501931d211a7..d7bccae5f413511 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -148,15 +148,6 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
ConstString GetQualifiedName();
- void DumpValue(ExecutionContext *exe_ctx, Stream *s,
- const DataExtractor &data, uint32_t data_offset,
- bool show_type, bool show_summary, bool verbose,
- lldb::Format format = lldb::eFormatDefault);
-
- bool DumpValueInMemory(ExecutionContext *exe_ctx, Stream *s,
- lldb::addr_t address, AddressType address_type,
- bool show_types, bool show_summary, bool verbose);
-
bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address,
AddressType address_type, DataExtractor &data);
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index eb6e453e1aec0d0..3dde07504598680 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -384,13 +384,15 @@ class TypeSystem : public PluginInterface,
dump(lldb::opaque_compiler_type_t type) const = 0;
#endif
- virtual void DumpValue(lldb::opaque_compiler_type_t type,
- ExecutionContext *exe_ctx, Stream &s,
- lldb::Format format, const DataExtractor &data,
- lldb::offset_t data_offset, size_t data_byte_size,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset, bool show_types,
- bool show_summary, bool verbose, uint32_t depth) = 0;
+ /*
+ virtual void DumpValue(lldb::opaque_compiler_type_t type,
+ ExecutionContext *exe_ctx, Stream &s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool show_types,
+ bool show_summary, bool verbose, uint32_t depth) = 0;
+ */
virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s,
lldb::Format format, const DataExtractor &data,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 69cff0f35ae4ab2..9702ed45f06d305 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -8512,380 +8512,6 @@ void TypeSystemClang::DumpFromSymbolFile(Stream &s,
}
}
-void TypeSystemClang::DumpValue(
- lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream &s,
- lldb::Format format, const lldb_private::DataExtractor &data,
- lldb::offset_t data_byte_offset, size_t data_byte_size,
- uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types,
- bool show_summary, bool verbose, uint32_t depth) {
- if (!type)
- return;
-
- clang::QualType qual_type(GetQualType(type));
- switch (qual_type->getTypeClass()) {
- case clang::Type::Record:
- if (GetCompleteType(type)) {
- const clang::RecordType *record_type =
- llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- uint32_t field_bit_offset = 0;
- uint32_t field_byte_offset = 0;
- const clang::ASTRecordLayout &record_layout =
- getASTContext().getASTRecordLayout(record_decl);
- uint32_t child_idx = 0;
-
- const clang::CXXRecordDecl *cxx_record_decl =
- llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl) {
- // We might have base classes to print out first
- clang::CXXRecordDecl::base_class_const_iterator base_class,
- base_class_end;
- for (base_class = cxx_record_decl->bases_begin(),
- base_class_end = cxx_record_decl->bases_end();
- base_class != base_class_end; ++base_class) {
- const clang::CXXRecordDecl *base_class_decl =
- llvm::cast<clang::CXXRecordDecl>(
- base_class->getType()->getAs<clang::RecordType>()->getDecl());
-
- // Skip empty base classes
- if (!verbose && !TypeSystemClang::RecordHasFields(base_class_decl))
- continue;
-
- if (base_class->isVirtual())
- field_bit_offset =
- record_layout.getVBaseClassOffset(base_class_decl)
- .getQuantity() *
- 8;
- else
- field_bit_offset = record_layout.getBaseClassOffset(base_class_decl)
- .getQuantity() *
- 8;
- field_byte_offset = field_bit_offset / 8;
- assert(field_bit_offset % 8 == 0);
- if (child_idx == 0)
- s.PutChar('{');
- else
- s.PutChar(',');
-
- clang::QualType base_class_qual_type = base_class->getType();
- std::string base_class_type_name(base_class_qual_type.getAsString());
-
- // Indent and print the base class type name
- s.Format("\n{0}{1}", llvm::fmt_repeat(" ", depth + DEPTH_INCREMENT),
- base_class_type_name);
-
- clang::TypeInfo base_class_type_info =
- getASTContext().getTypeInfo(base_class_qual_type);
-
- // Dump the value of the member
- CompilerType base_clang_type = GetType(base_class_qual_type);
- base_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- base_clang_type
- .GetFormat(), // The format with which to display the member
- data, // Data buffer containing all bytes for this type
- data_byte_offset + field_byte_offset, // Offset into "data" where
- // to grab value from
- base_class_type_info.Width / 8, // Size of this type in bytes
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable
- // types
- show_summary, // Boolean indicating if we should show a summary
- // for the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have
- // children
-
- ++child_idx;
- }
- }
- uint32_t field_idx = 0;
- clang::RecordDecl::field_iterator field, field_end;
- for (field = record_decl->field_begin(),
- field_end = record_decl->field_end();
- field != field_end; ++field, ++field_idx, ++child_idx) {
- // Print the starting squiggly bracket (if this is the first member) or
- // comma (for member 2 and beyond) for the struct/union/class member.
- if (child_idx == 0)
- s.PutChar('{');
- else
- s.PutChar(',');
-
- // Indent
- s.Printf("\n%*s", depth + DEPTH_INCREMENT, "");
-
- clang::QualType field_type = field->getType();
- // Print the member type if requested
- // Figure out the type byte size (field_type_info.first) and alignment
- // (field_type_info.second) from the AST context.
- clang::TypeInfo field_type_info =
- getASTContext().getTypeInfo(field_type);
- assert(field_idx < record_layout.getFieldCount());
- // Figure out the field offset within the current struct/union/class
- // type
- field_bit_offset = record_layout.getFieldOffset(field_idx);
- field_byte_offset = field_bit_offset / 8;
- uint32_t field_bitfield_bit_size = 0;
- uint32_t field_bitfield_bit_offset = 0;
- if (FieldIsBitfield(*field, field_bitfield_bit_size))
- field_bitfield_bit_offset = field_bit_offset % 8;
-
- if (show_types) {
- std::string field_type_name(field_type.getAsString());
- if (field_bitfield_bit_size > 0)
- s.Printf("(%s:%u) ", field_type_name.c_str(),
- field_bitfield_bit_size);
- else
- s.Printf("(%s) ", field_type_name.c_str());
- }
- // Print the member name and equal sign
- s.Printf("%s = ", field->getNameAsString().c_str());
-
- // Dump the value of the member
- CompilerType field_clang_type = GetType(field_type);
- field_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- field_clang_type
- .GetFormat(), // The format with which to display the member
- data, // Data buffer containing all bytes for this type
- data_byte_offset + field_byte_offset, // Offset into "data" where to
- // grab value from
- field_type_info.Width / 8, // Size of this type in bytes
- field_bitfield_bit_size, // Bitfield bit size
- field_bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable
- // types
- show_summary, // Boolean indicating if we should show a summary for
- // the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have
- // children
- }
-
- // Indent the trailing squiggly bracket
- if (child_idx > 0)
- s.Printf("\n%*s}", depth, "");
- }
- return;
-
- case clang::Type::Enum:
- if (GetCompleteType(type)) {
- const clang::EnumType *enutype =
- llvm::cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enutype->getDecl();
- assert(enum_decl);
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- lldb::offset_t offset = data_byte_offset;
- const int64_t enum_value = data.GetMaxU64Bitfield(
- &offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(),
- enum_end_pos = enum_decl->enumerator_end();
- enum_pos != enum_end_pos; ++enum_pos) {
- if (enum_pos->getInitVal() == enum_value) {
- s.Printf("%s", enum_pos->getNameAsString().c_str());
- return;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the enum
- // decl, so just print the integer.
- s.Printf("%" PRIi64, enum_value);
- }
- return;
-
- case clang::Type::ConstantArray: {
- const clang::ConstantArrayType *array =
- llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr());
- bool is_array_of_characters = false;
- clang::QualType element_qual_type = array->getElementType();
-
- const clang::Type *canonical_type =
- element_qual_type->getCanonicalTypeInternal().getTypePtr();
- if (canonical_type)
- is_array_of_characters = canonical_type->isCharType();
-
- const uint64_t element_count = array->getSize().getLimitedValue();
-
- clang::TypeInfo field_type_info =
- getASTContext().getTypeInfo(element_qual_type);
-
- uint32_t element_idx = 0;
- uint32_t element_offset = 0;
- uint64_t element_byte_size = field_type_info.Width / 8;
- uint32_t element_stride = element_byte_size;
-
- if (is_array_of_characters) {
- s.PutChar('"');
- DumpDataExtractor(data, &s, data_byte_offset, lldb::eFormatChar,
- element_byte_size, element_count, UINT32_MAX,
- LLDB_INVALID_ADDRESS, 0, 0);
- s.PutChar('"');
- return;
- } else {
- CompilerType element_clang_type = GetType(element_qual_type);
- lldb::Format element_format = element_clang_type.GetFormat();
-
- for (element_idx = 0; element_idx < element_count; ++element_idx) {
- // Print the starting squiggly bracket (if this is the first member) or
- // comman (for member 2 and beyong) for the struct/union/class member.
- if (element_idx == 0)
- s.PutChar('{');
- else
- s.PutChar(',');
-
- // Indent and print the index
- s.Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx);
-
- // Figure out the field offset within the current struct/union/class
- // type
- element_offset = element_idx * element_stride;
-
- // Dump the value of the member
- element_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- element_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset +
- element_offset, // Offset into "data" where to grab value from
- element_byte_size, // Size of this type in bytes
- 0, // Bitfield bit size
- 0, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable
- // types
- show_summary, // Boolean indicating if we should show a summary for
- // the current type
- verbose, // Verbose output?
- depth + DEPTH_INCREMENT); // Scope depth for any types that have
- // children
- }
-
- // Indent the trailing squiggly bracket
- if (element_idx > 0)
- s.Printf("\n%*s}", depth, "");
- }
- }
- return;
-
- case clang::Type::Typedef: {
- clang::QualType typedef_qual_type =
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType();
-
- CompilerType typedef_clang_type = GetType(typedef_qual_type);
- lldb::Format typedef_format = typedef_clang_type.GetFormat();
- clang::TypeInfo typedef_type_info =
- getASTContext().getTypeInfo(typedef_qual_type);
- uint64_t typedef_byte_size = typedef_type_info.Width / 8;
-
- return typedef_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- typedef_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- typedef_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the
- // current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- } break;
-
- case clang::Type::Auto: {
- clang::QualType elaborated_qual_type =
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType();
- CompilerType elaborated_clang_type = GetType(elaborated_qual_type);
- lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
- clang::TypeInfo elaborated_type_info =
- getASTContext().getTypeInfo(elaborated_qual_type);
- uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
-
- return elaborated_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- elaborated_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- elaborated_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the
- // current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- } break;
-
- case clang::Type::Elaborated: {
- clang::QualType elaborated_qual_type =
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
- CompilerType elaborated_clang_type = GetType(elaborated_qual_type);
- lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
- clang::TypeInfo elaborated_type_info =
- getASTContext().getTypeInfo(elaborated_qual_type);
- uint64_t elaborated_byte_size = elaborated_type_info.Width / 8;
-
- return elaborated_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- elaborated_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- elaborated_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the
- // current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- } break;
-
- case clang::Type::Paren: {
- clang::QualType desugar_qual_type =
- llvm::cast<clang::ParenType>(qual_type)->desugar();
- CompilerType desugar_clang_type = GetType(desugar_qual_type);
-
- lldb::Format desugar_format = desugar_clang_type.GetFormat();
- clang::TypeInfo desugar_type_info =
- getASTContext().getTypeInfo(desugar_qual_type);
- uint64_t desugar_byte_size = desugar_type_info.Width / 8;
-
- return desugar_clang_type.DumpValue(
- exe_ctx,
- &s, // Stream to dump to
- desugar_format, // The format with which to display the element
- data, // Data buffer containing all bytes for this type
- data_byte_offset, // Offset into "data" where to grab value from
- desugar_byte_size, // Size of this type in bytes
- bitfield_bit_size, // Bitfield bit size
- bitfield_bit_offset, // Bitfield bit offset
- show_types, // Boolean indicating if we should show the variable types
- show_summary, // Boolean indicating if we should show a summary for the
- // current type
- verbose, // Verbose output?
- depth); // Scope depth for any types that have children
- } break;
-
- default:
- // We are down to a scalar type that we just need to display.
- DumpDataExtractor(data, &s, data_byte_offset, format, data...
[truncated]
|
/* | ||
virtual void DumpValue(lldb::opaque_compiler_type_t type, | ||
ExecutionContext *exe_ctx, Stream &s, | ||
lldb::Format format, const DataExtractor &data, | ||
lldb::offset_t data_offset, size_t data_byte_size, | ||
uint32_t bitfield_bit_size, | ||
uint32_t bitfield_bit_offset, bool show_types, | ||
bool show_summary, bool verbose, uint32_t depth) = 0; | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this, don't just comment it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had updated the patch where I effectively removed it. Sorry, it seems you saw the oldest version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still here even with "show all commits"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, I had stashed the change where I delete the code.
@clayborg , now this patch should be fine
de55d41
to
fd9b542
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me, but anyone at Apple might need to comment to make sure it doesn't take away something needed for Swift.
@@ -183,8 +181,6 @@ class CompilerType { | |||
|
|||
bool IsPointerToScalarType() const; | |||
|
|||
bool IsRuntimeGeneratedType() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swift uses this one.
Swift uses the |
I found this type/typesystem code that is dead and seems to have been replaced by the ValueObjectPrinter.
fd9b542
to
fa598fa
Compare
@jimingham , thanks! I reverted the changes to that method and left a tiny comment mentioning that it's used by swift. |
I applied this patch downstream (and removed the corresponding overloads in |
Thanks, @JDevlieghere ! |
@clayborg PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to clean this up, and thanks for taking the time to make sure this wouldn't hurt us downstream with swift!
@bulbazord , thanks!! I'll try to improve the type system and other parts of the LLDB as I add support for my language. |
I found some type/typesystem code that is dead and some of it seems to have been replaced by the ValueObjectPrinter.