struct LogicalResult;
class MLIRContext;
class Operation;
+class OperationName;
class Type;
namespace detail {
/// Stream in an Identifier.
Diagnostic &operator<<(Identifier val);
+ /// Stream in an OperationName.
+ Diagnostic &operator<<(OperationName val);
+
/// Stream in a range.
template <typename T> Diagnostic &operator<<(llvm::iterator_range<T> range) {
return appendRange(range);
return *this;
}
+/// Stream in an OperationName.
+Diagnostic &Diagnostic::operator<<(OperationName val) {
+ // An OperationName is stored in the context, so we don't need to worry about
+ // the lifetime of its data.
+ arguments.push_back(DiagnosticArgument(val.getStringRef()));
+ return *this;
+}
+
/// Outputs this diagnostic to a stream.
void Diagnostic::print(raw_ostream &os) const {
for (auto &arg : getArguments())
/// Emit an error with the op name prefixed, like "'dim' op " which is
/// convenient for verifiers.
InFlightDiagnostic Operation::emitOpError(const Twine &message) {
- return emitError() << "'" << getName().getStringRef() << "' op " << message;
+ return emitError() << "'" << getName() << "' op " << message;
}
//===----------------------------------------------------------------------===//
return false;
}
- opInst.emitError("unsupported or non-LLVM operation: " +
- opInst.getName().getStringRef());
+ opInst.emitError("unsupported or non-LLVM operation: ") << opInst.getName();
return true;
}