return {notes.begin(), notes.end()};
}
+ /// Allow a diagnostic to be converted to 'failure'.
+ operator LogicalResult() const;
+
private:
Diagnostic(const Diagnostic &rhs) = delete;
Diagnostic &operator=(const Diagnostic &rhs) = delete;
// Allow diagnostics emitted during parsing to be converted to failure.
ParseResult(const InFlightDiagnostic &) : LogicalResult(failure()) {}
+ ParseResult(const Diagnostic &) : LogicalResult(failure()) {}
/// Failure is true in a boolean context.
explicit operator bool() const { return failed(*this); }
if (block.empty() || isa<AffineTerminatorOp>(block.back()))
return success();
- op.emitOpError("expects regions to end with '" +
- AffineTerminatorOp::getOperationName() + "'")
- .attachNote()
- << "in custom textual format, the absence of terminator implies '"
- << AffineTerminatorOp::getOperationName() << "'";
- return failure();
+ return op.emitOpError("expects regions to end with '" +
+ AffineTerminatorOp::getOperationName() + "'")
+ .attachNote()
+ << "in custom textual format, the absence of terminator implies '"
+ << AffineTerminatorOp::getOperationName() << "'";
}
// Insert `affine.terminator` at the end of the region's only block if it does
if (block.back().getNumSuccessors() != 0)
continue;
if (!isa<gpu::Return>(&block.back())) {
- block.back()
- .emitError("expected 'gpu.terminator' or a terminator with "
- "successors")
- .attachNote(getLoc())
- << "in '" << getOperationName() << "' body region";
- return failure();
+ return block.back()
+ .emitError("expected 'gpu.terminator' or a terminator with "
+ "successors")
+ .attachNote(getLoc())
+ << "in '" << getOperationName() << "' body region";
}
}
return *notes.back();
}
+/// Allow a diagnostic to be converted to 'failure'.
+Diagnostic::operator LogicalResult() const { return failure(); }
+
//===----------------------------------------------------------------------===//
// InFlightDiagnostic
//===----------------------------------------------------------------------===//
if (block.empty() || isa<TerminatorOp>(block.back()))
return success();
- op.emitOpError("expects regions to end with '" +
- TerminatorOp::getOperationName() + "'")
- .attachNote()
- << "in custom textual format, the absence of terminator implies '"
- << TerminatorOp::getOperationName() << "'";
- return failure();
+ return op.emitOpError("expects regions to end with '" +
+ TerminatorOp::getOperationName() + "'")
+ .attachNote()
+ << "in custom textual format, the absence of terminator implies '"
+ << TerminatorOp::getOperationName() << "'";
}
// Insert `linalg.terminator` at the end of the ForOp only region's only block
// or a forward reference.
if (auto *existing = entries[useInfo.number].first) {
if (!isForwardRefPlaceholder(existing)) {
- emitError(useInfo.loc)
+ return emitError(useInfo.loc)
.append("redefinition of SSA value '", useInfo.name, "'")
.attachNote(getEncodedSourceLocation(entries[useInfo.number].second))
.append("previously defined here");
- return failure();
}
// If it was a forward reference, update everything that used it to use