class Location;
class OpBuilder;
-raw_ostream &operator<<(raw_ostream &os, Range &range);
+raw_ostream &operator<<(raw_ostream &os, const Range &range);
/// Return the list of Range (i.e. offset, size, stride). Each Range
/// entry contains either the dynamic value or a ConstantIndexOp constructed
}
/// Allow printing to a stream.
-inline raw_ostream &operator<<(raw_ostream &os, OpState &op) {
+inline raw_ostream &operator<<(raw_ostream &os, OpState op) {
op.print(os, OpPrintingFlags().useLocalScope());
return os;
}
size_t numTrailingObjects(OverloadToken<Region>) const { return numRegions; }
};
-inline raw_ostream &operator<<(raw_ostream &os, Operation &op) {
- op.print(os, OpPrintingFlags().useLocalScope());
+inline raw_ostream &operator<<(raw_ostream &os, const Operation &op) {
+ const_cast<Operation &>(op).print(os, OpPrintingFlags().useLocalScope());
return os;
}
return produceSubViewErrorMsg(result, op, expectedType, errMsg);
}
-raw_ostream &mlir::operator<<(raw_ostream &os, Range &range) {
+raw_ostream &mlir::operator<<(raw_ostream &os, const Range &range) {
return os << "range " << range.offset << ":" << range.size << ":"
<< range.stride;
}
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/BitVector.h"
+#include "llvm/Support/FormatVariadic.h"
#include "gtest/gtest.h"
using namespace mlir;
containerOp->destroy();
}
+TEST(OperationFormatPrintTest, CanUseVariadicFormat) {
+ MLIRContext context;
+ Builder builder(&context);
+
+ Operation *op = createOp(&context);
+
+ std::string str = formatv("{0}", *op).str();
+ ASSERT_STREQ(str.c_str(), "\"foo.bar\"() : () -> ()");
+}
+
} // end namespace