diff options
| author | Matthias Braun <matze@braunis.de> | 2015-12-03 22:17:26 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2015-12-03 22:17:26 +0000 |
| commit | e957a9bb1bbff982e2d17debf2f574f593017f5b (patch) | |
| tree | bbf4653050a6e791d83e211e89feae65bb2e1890 /llvm/lib/CodeGen/SelectionDAG | |
| parent | bb599e3a4d105f1f2561a80d56e3d1ffb46cddb4 (diff) | |
| download | bcm5719-llvm-e957a9bb1bbff982e2d17debf2f574f593017f5b.tar.gz bcm5719-llvm-e957a9bb1bbff982e2d17debf2f574f593017f5b.zip | |
raw_ostream: << operator for callables with raw_stream argument
This allows easier construction of print helpers. Example:
Printable PrintLaneMask(unsigned LaneMask) {
return Printable([LaneMask](raw_ostream &OS) {
OS << format("%08X", LaneMask);
});
}
// Usage:
OS << PrintLaneMask(Mask);
Differential Revision: http://reviews.llvm.org/D14348
llvm-svn: 254655
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index d362f98d646..8c3a0f2d81e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -369,25 +369,14 @@ const char *SDNode::getIndexedModeName(ISD::MemIndexedMode AM) { } } -namespace { -class PrintNodeId { - const SDNode &Node; -public: - explicit PrintNodeId(const SDNode &Node) - : Node(Node) {} - void print(raw_ostream &OS) const { +static Printable PrintNodeId(const SDNode &Node) { + return [&Node](raw_ostream &OS) { #ifndef NDEBUG OS << 't' << Node.PersistentId; #else OS << (const void*)&Node; #endif - } -}; - -static inline raw_ostream &operator<<(raw_ostream &OS, const PrintNodeId &P) { - P.print(OS); - return OS; -} + }; } void SDNode::dump() const { dump(nullptr); } |

