[Lldb-commits] [lldb] [lldb] Print register enum types only once (PR #204818)

Felipe de Azevedo Piovezan via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 1 02:46:33 PDT 2026


================
@@ -286,9 +287,14 @@ static void DumpEnumerators(StreamString &strm, size_t indent,
 }
 
 std::string RegisterFlags::DumpEnums(uint32_t max_width) const {
-  StreamString strm;
-  bool printed_enumerators_once = false;
-
+  struct TypeToFields {
+    const FieldEnum *enum_type;
+    std::string field_names;
+  };
+  std::vector<TypeToFields> enum_types;
----------------
felipepiovezan wrote:

I would personally have used a `MapVector<FieldEnum *, std::vector<std::string>>` to collapse most of the code to:

```
for (const auto &field : m_fields) {
   ....
   enum_types[entry.enum_type].push_back(field.GetType));
}

....
for (auto [enum_type, fields] : enum_types) {
...
  std::string name_string;
 
  llvm::interleave_comma(llvm::raw_string_ostream(name_string), fields);
  name_string += ": "
...
}

https://github.com/llvm/llvm-project/pull/204818


More information about the lldb-commits mailing list