[Lldb-commits] [lldb] [lldb][Format] Reject recursive format entities (PR #174750)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 8 06:57:40 PST 2026


================
@@ -2704,3 +2713,17 @@ Status FormatEntity::Parse(const llvm::StringRef &format_str, Entry &entry) {
   llvm::StringRef modifiable_format(format_str);
   return ParseInternal(modifiable_format, entry, 0);
 }
+
+bool FormatEntity::Formatter::IsInvalidRecursiveFormat(Entry::Type type) {
+  // It is expected that Scope and Root format entities recursively call Format.
+  //
+  // Variable may also be formatted recursively in some special cases. The main
+  // use-case being array summary strings, in which case Format will call itself
+  // with the subrange ValueObject and apply a freshly created Variable entry.
+  // E.g., ${var[1-3]} will format the [1-3] range with ${var%S}.
+  if (llvm::is_contained(
+          {Entry::Type::Scope, Entry::Type::Root, Entry::Type::Variable}, type))
----------------
JDevlieghere wrote:

Nit: might be worth outlining this as a static constexpr for readability and to make it easier when we inevitably have to add another item to the list.

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


More information about the lldb-commits mailing list