[libc-commits] [libc] [libc] Template the printf / scanf parser class (PR #66277)

via libc-commits libc-commits at lists.llvm.org
Tue Sep 19 09:55:46 PDT 2023


================
@@ -142,6 +148,439 @@ class Parser {
 #endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
 };
 
+#ifndef LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
+#define WRITE_ARG_VAL_SIMPLEST(dst, arg_type, index)                           \
+  {                                                                            \
+    auto temp = get_arg_value<arg_type>(index);                                \
+    if (!temp.has_value()) {                                                   \
+      section.has_conv = false;                                                \
+    } else {                                                                   \
+      dst = cpp::bit_cast<int_type_of_v<arg_type>>(temp.value());              \
+    }                                                                          \
+  }
+#else
+#define WRITE_ARG_VAL_SIMPLEST(dst, arg_type, _)                               \
+  dst = cpp::bit_cast<int_type_of_v<arg_type>>(get_next_arg_value<arg_type>())
+#endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
+
+template <typename ArgProvider>
----------------
michaelrj-google wrote:

it looks like the functions are still templated here and in scanf. Is that intended?

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


More information about the libc-commits mailing list