diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -432,7 +432,7 @@ /// Emit a diagnostic using the registered issue handler if present, or with /// the default behavior if not. - void emit(Diagnostic diag); + void emit(Diagnostic &diag); private: friend class MLIRContextImpl; diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -191,7 +191,7 @@ // If this diagnostic is still inflight and it hasn't been abandoned, then // report it. if (isInFlight()) { - owner->emit(std::move(*impl)); + owner->emit(*impl); owner = nullptr; } impl.reset(); @@ -277,7 +277,7 @@ /// Emit a diagnostic using the registered issue handler if present, or with /// the default behavior if not. -void DiagnosticEngine::emit(Diagnostic diag) { +void DiagnosticEngine::emit(Diagnostic &diag) { assert(diag.getSeverity() != DiagnosticSeverity::Note && "notes should not be emitted directly"); impl->emit(std::move(diag)); @@ -869,13 +869,12 @@ return; // Emit the diagnostics back to the context. - emitDiagnostics([&](Diagnostic diag) { - return context->getDiagEngine().emit(std::move(diag)); - }); + emitDiagnostics( + [&](Diagnostic &diag) { return context->getDiagEngine().emit(diag); }); } /// Utility method to emit any held diagnostics. - void emitDiagnostics(llvm::function_ref emitFn) const { + void emitDiagnostics(llvm::function_ref emitFn) const { // Stable sort all of the diagnostics that were emitted. This creates a // deterministic ordering for the diagnostics based upon which order id they // were emitted for. @@ -883,7 +882,7 @@ // Emit each diagnostic to the context again. for (ThreadDiagnostic &diag : diagnostics) - emitFn(std::move(diag.diag)); + emitFn(diag.diag); } /// Set the order id for the current thread.