Author: Alex Langford Date: 2023-07-03T09:35:24-07:00 New Revision: a2ff2921e84aa435e124ad275f70855a185cfb1c
URL: https://github.com/llvm/llvm-project/commit/a2ff2921e84aa435e124ad275f70855a185cfb1c DIFF: https://github.com/llvm/llvm-project/commit/a2ff2921e84aa435e124ad275f70855a185cfb1c.diff LOG: [lldb][NFCI] TypeSystemClang::CreateStructForIdentifier should take a StringRef This doesn't really use fast comparison or string uniqueness. In fact, all of the current callers pass an empty string for type_name. The only reason I don't remove it is because it looks like it is used downstream for swift. Differential Revision: https://reviews.llvm.org/D153810 Added: Modified: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h Removed: ################################################################################ diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp index 40ffe96737926d..c92ac4bdec1480 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -78,10 +78,10 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd { const char *const FuncPtr_name("__FuncPtr"); m_block_struct_type = clang_ast_context->CreateStructForIdentifier( - ConstString(), {{isa_name, isa_type}, - {flags_name, flags_type}, - {reserved_name, reserved_type}, - {FuncPtr_name, function_pointer_type}}); + llvm::StringRef(), {{isa_name, isa_type}, + {flags_name, flags_type}, + {reserved_name, reserved_type}, + {FuncPtr_name, function_pointer_type}}); } ~BlockPointerSyntheticFrontEnd() override = default; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index de4f23bf95c33c..cb601603a3c43d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -338,7 +338,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { // +-----------------------------+ // CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( - ConstString(), + llvm::StringRef(), {{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, {"ptr1", @@ -503,7 +503,7 @@ bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: // +-----------------------------+ // CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( - ConstString(), + llvm::StringRef(), {{"__next_", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 585ab43b6af07a..092a4120376b7f 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -291,7 +291,7 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset( if (!ast_ctx) return; CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( - ConstString(), + llvm::StringRef(), {{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index 3d29739c19adfd..7abc71a1c53fe2 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -244,7 +244,7 @@ CompilerType PlatformFreeBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_fault", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_trapno", int_type}, }), @@ -252,7 +252,7 @@ CompilerType PlatformFreeBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_timer", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_timerid", int_type}, {"_overrun", int_type}, @@ -261,7 +261,7 @@ CompilerType PlatformFreeBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_mesgq", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_mqd", int_type}, }), @@ -269,7 +269,7 @@ CompilerType PlatformFreeBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_poll", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_band", long_type}, }), diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 755c13defa9886..149f541a5d3d96 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -360,13 +360,14 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "", clang::TTK_Union, lldb::eLanguageTypeC); ast->StartTagDeclarationDefinition(sigfault_bounds_type); - ast->AddFieldToRecordType(sigfault_bounds_type, "_addr_bnd", - ast->CreateStructForIdentifier(ConstString(), + ast->AddFieldToRecordType( + sigfault_bounds_type, "_addr_bnd", + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_lower", voidp_type}, {"_upper", voidp_type}, }), - lldb::eAccessPublic, 0); + lldb::eAccessPublic, 0); ast->AddFieldToRecordType(sigfault_bounds_type, "_pkey", uint_type, lldb::eAccessPublic, 0); ast->CompleteTagDeclarationDefinition(sigfault_bounds_type); @@ -404,7 +405,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_kill", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"si_pid", pid_type}, {"si_uid", uid_type}, @@ -413,7 +414,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_timer", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"si_tid", int_type}, {"si_overrun", int_type}, @@ -423,7 +424,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_rt", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"si_pid", pid_type}, {"si_uid", uid_type}, @@ -433,7 +434,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_sigchld", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"si_pid", pid_type}, {"si_uid", uid_type}, @@ -445,7 +446,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_sigfault", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"si_addr", voidp_type}, {"si_addr_lsb", short_type}, @@ -455,7 +456,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_sigpoll", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"si_band", band_type}, {"si_fd", int_type}, @@ -465,7 +466,7 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { // NB: SIGSYS is not present on ia64 but we don't seem to support that ast->AddFieldToRecordType( union_type, "_sigsys", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_call_addr", voidp_type}, {"_syscall", int_type}, diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index 59bbc3f638af19..393519d708d366 100644 --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -277,7 +277,7 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_rt", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_pid", pid_type}, {"_uid", uid_type}, @@ -287,7 +287,7 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_child", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_pid", pid_type}, {"_uid", uid_type}, @@ -299,7 +299,7 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_fault", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_addr", voidp_type}, {"_trap", int_type}, @@ -310,7 +310,7 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_poll", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_band", long_type}, {"_fd", int_type}, @@ -319,7 +319,7 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType(union_type, "_syscall", ast->CreateStructForIdentifier( - ConstString(), + llvm::StringRef(), { {"_sysnum", int_type}, {"_retval", int_type.GetArrayType(2)}, @@ -330,7 +330,7 @@ CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { ast->AddFieldToRecordType( union_type, "_ptrace_state", - ast->CreateStructForIdentifier(ConstString(), + ast->CreateStructForIdentifier(llvm::StringRef(), { {"_pe_report_event", int_type}, {"_option", ptrace_option_type}, diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 441dab29b1c3a9..8933e6c60e1984 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -2308,12 +2308,12 @@ CompilerType TypeSystemClang::CreateArrayType(const CompilerType &element_type, } CompilerType TypeSystemClang::CreateStructForIdentifier( - ConstString type_name, + llvm::StringRef type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed) { CompilerType type; - if (!type_name.IsEmpty() && + if (!type_name.empty() && (type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name)) .IsValid()) { lldbassert(0 && "Trying to create a type for an existing name"); @@ -2321,8 +2321,7 @@ CompilerType TypeSystemClang::CreateStructForIdentifier( } type = CreateRecordType(nullptr, OptionalClangModuleID(), lldb::eAccessPublic, - type_name.GetCString(), clang::TTK_Struct, - lldb::eLanguageTypeC); + type_name, clang::TTK_Struct, lldb::eLanguageTypeC); StartTagDeclarationDefinition(type); for (const auto &field : type_fields) AddFieldToRecordType(type, field.first, field.second, lldb::eAccessPublic, @@ -2334,7 +2333,7 @@ CompilerType TypeSystemClang::CreateStructForIdentifier( } CompilerType TypeSystemClang::GetOrCreateStructForIdentifier( - ConstString type_name, + llvm::StringRef type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed) { diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index a3ddc5323b6e1a..acd1c6e3e8d81c 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -280,13 +280,13 @@ class TypeSystemClang : public TypeSystem { } CompilerType CreateStructForIdentifier( - ConstString type_name, + llvm::StringRef type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed = false); CompilerType GetOrCreateStructForIdentifier( - ConstString type_name, + llvm::StringRef type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed = false); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits