[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 8 11:31:07 PST 2024


================
@@ -1084,3 +1084,43 @@ bool lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
                                         dataobj, size);
 }
+
+bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider(
+    ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  // These are the names used in the C++20 ostream operator. Since LLVM uses
+  // C++17 it's not possible to use the ostream operator directly.
+  static const std::array<std::string_view, 12> months = {
+      "January", "February", "March",     "April",   "May",      "June",
+      "July",    "August",   "September", "October", "November", "December"};
+
+  unsigned month = valobj.GetChildMemberWithName("__m_")->GetValueAsUnsigned(0);
----------------
Michael137 wrote:

```suggestion
  const unsigned month = valobj.GetChildMemberWithName("__m_")->GetValueAsUnsigned(0);
```

Also we should probably check that `GetChildMemberWithName` returns a valid pointer

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


More information about the lldb-commits mailing list