diff options
| -rw-r--r-- | llvm/tools/llvm-diff/DiffLog.cpp | 3 | ||||
| -rw-r--r-- | llvm/tools/llvm-diff/DiffLog.h | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/llvm/tools/llvm-diff/DiffLog.cpp b/llvm/tools/llvm-diff/DiffLog.cpp index 24a1b08d545..ed86058f1af 100644 --- a/llvm/tools/llvm-diff/DiffLog.cpp +++ b/llvm/tools/llvm-diff/DiffLog.cpp @@ -20,7 +20,8 @@ using namespace llvm; LogBuilder::~LogBuilder() { - consumer.logf(*this); + if (consumer) + consumer->logf(*this); } StringRef LogBuilder::getFormat() const { return Format; } diff --git a/llvm/tools/llvm-diff/DiffLog.h b/llvm/tools/llvm-diff/DiffLog.h index 8eb53ffffcc..8f28461afdd 100644 --- a/llvm/tools/llvm-diff/DiffLog.h +++ b/llvm/tools/llvm-diff/DiffLog.h @@ -27,7 +27,7 @@ namespace llvm { /// A temporary-object class for building up log messages. class LogBuilder { - Consumer &consumer; + Consumer *consumer; /// The use of a stored StringRef here is okay because /// LogBuilder should be used only as a temporary, and as a @@ -38,8 +38,12 @@ namespace llvm { SmallVector<Value*, 4> Arguments; public: - LogBuilder(Consumer &c, StringRef Format) - : consumer(c), Format(Format) {} + LogBuilder(Consumer &c, StringRef Format) : consumer(&c), Format(Format) {} + LogBuilder(LogBuilder &&L) + : consumer(L.consumer), Format(L.Format), + Arguments(std::move(L.Arguments)) { + L.consumer = nullptr; + } LogBuilder &operator<<(Value *V) { Arguments.push_back(V); |

