[PATCH] D34281: [Format] Simplify some of the formatter template glue

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 02:14:36 PDT 2017


labath resigned from this revision.
labath added a comment.

I am not sure I can bring much to this, so I'll take a back seat.



================
Comment at: llvm/include/llvm/Support/FormatProviders.h:28-33
+#define FORMATTER(Type)                                                        \
+  namespace llvm {                                                             \
+  void format_one_item(Type &&Item, raw_ostream &S, StringRef Options);        \
+  }                                                                            \
+  inline void llvm::format_one_item(Type &&Value, raw_ostream &Stream,         \
+                                    StringRef Style)
----------------
dblaikie wrote:
> Not sure this benefits much from being a macro, does it?
> 
> Calls to these functions look like they're ADL compatible, so there's no need to put them in the llvm namespace - they can go in whatever namespace the Type is in, probably? (doesn't matter too much in the LLVM project - we don't need to protect the llvm namespace, etc, but is perhaps a more generic extensibility mechanism than users having to write function definitions in the library's namespace)
I don't know about the technical feasibility of this, but I did feel awkward every time I had to write "namespace llvm" to write a lldb pretty-printer.


https://reviews.llvm.org/D34281





More information about the llvm-commits mailing list