https://github.com/Teemperor updated https://github.com/llvm/llvm-project/pull/200939
>From 2ef96fe603239038e30147391d4d93e109e699f8 Mon Sep 17 00:00:00 2001 From: Raphael Isemann <[email protected]> Date: Mon, 1 Jun 2026 21:29:42 +0100 Subject: [PATCH] [lldb] Add size checks for frequently allocated classes Given how frequently we allocate these classes (or classes containing these classes) on the heap, we should only grow them intentionally. See also bd1b3d47462acf4f854f593bdd77b3f127adea46 --- lldb/include/lldb/Core/Address.h | 2 ++ lldb/include/lldb/Core/AddressRange.h | 2 ++ lldb/include/lldb/Core/Mangled.h | 3 +++ lldb/include/lldb/Symbol/LineTable.h | 4 ++++ lldb/include/lldb/Utility/ConstString.h | 2 ++ 5 files changed, 13 insertions(+) diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 2b669aeba20ec..15fc30a2e3f92 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -501,6 +501,8 @@ class Address { // know if this address used to have a valid section. bool SectionWasDeletedPrivate() const; }; +static_assert(sizeof(Address) <= sizeof(lldb::addr_t) + sizeof(lldb::SectionWP), + "High-volume object, size of object must be increased with care"); // NOTE: Be careful using this operator. It can correctly compare two // addresses from the same Module correctly. It can't compare two addresses diff --git a/lldb/include/lldb/Core/AddressRange.h b/lldb/include/lldb/Core/AddressRange.h index 68a3ad0edd2d7..af26bb3b351a3 100644 --- a/lldb/include/lldb/Core/AddressRange.h +++ b/lldb/include/lldb/Core/AddressRange.h @@ -249,6 +249,8 @@ class AddressRange { Address m_base_addr; ///< The section offset base address of this range. lldb::addr_t m_byte_size = 0; ///< The size in bytes of this address range. }; +static_assert(sizeof(AddressRange) <= sizeof(Address) + sizeof(lldb::addr_t), + "High-volume object, size of object must be increased with care"); // Forward-declarable wrapper. class AddressRanges : public std::vector<lldb_private::AddressRange> { diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index e1ac0e8761f70..6c6f2574ad22e 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -332,6 +332,9 @@ class Mangled { /// parts of the name (e.g., basename, arguments, etc.) begin and end. mutable std::unique_ptr<DemangledNameInfo> m_demangled_info; }; +static_assert(sizeof(Mangled) <= 2 * sizeof(ConstString) + + sizeof(std::unique_ptr<DemangledNameInfo>), + "High-volume object, size of object must be increased with care"); Stream &operator<<(Stream &s, const Mangled &obj); diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h index 8dda9c7362f12..1d43a7c1b94b9 100644 --- a/lldb/include/lldb/Symbol/LineTable.h +++ b/lldb/include/lldb/Symbol/LineTable.h @@ -286,6 +286,10 @@ class LineTable { /// is no file information. uint16_t file_idx = 0; }; + static_assert( + sizeof(Entry) <= + sizeof(lldb::addr_t) + sizeof(uint32_t) + 2 * sizeof(uint16_t), + "High-volume object, size of object must be increased with care"); class Sequence { public: diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h index 3d85a14a7ae39..98b389987fc77 100644 --- a/lldb/include/lldb/Utility/ConstString.h +++ b/lldb/include/lldb/Utility/ConstString.h @@ -412,6 +412,8 @@ class ConstString { const char *m_string = nullptr; }; +static_assert(sizeof(ConstString) <= sizeof(const char *), + "High-volume object, size of object must be increased with care"); /// Stream the string value \a str to the stream \a s Stream &operator<<(Stream &s, ConstString str); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
