Skip to content

Commit

Permalink
-Wdeprecated clean by making LogBuilder move constructible so it can …
Browse files Browse the repository at this point in the history
…be returned by value (in DifferenceEngine::logf)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244129 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dwblaikie committed Aug 5, 2015
1 parent 8cfa23f commit 0caff99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tools/llvm-diff/DiffLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
using namespace llvm;

LogBuilder::~LogBuilder() {
consumer.logf(*this);
if (consumer)
consumer->logf(*this);
}

StringRef LogBuilder::getFormat() const { return Format; }
Expand Down
10 changes: 7 additions & 3 deletions tools/llvm-diff/DiffLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 0caff99

Please sign in to comment.