diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -76,8 +76,8 @@ } /// Print the attribute. - void print(raw_ostream &os) const; - void print(raw_ostream &os, AsmState &state) const; + void print(raw_ostream &os, bool elideType = false) const; + void print(raw_ostream &os, AsmState &state, bool elideType = false) const; void dump() const; /// Get an opaque pointer to the attribute. diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -3262,17 +3262,20 @@ // print and dump methods //===----------------------------------------------------------------------===// -void Attribute::print(raw_ostream &os) const { +void Attribute::print(raw_ostream &os, bool elideType) const { if (!*this) { os << "<>"; return; } AsmState state(getContext()); - print(os, state); + print(os, state, elideType); } -void Attribute::print(raw_ostream &os, AsmState &state) const { - AsmPrinter::Impl(os, state.getImpl()).printAttribute(*this); +void Attribute::print(raw_ostream &os, AsmState &state, bool elideType) const { + using AttrTypeElision = AsmPrinter::Impl::AttrTypeElision; + AsmPrinter::Impl(os, state.getImpl()) + .printAttribute(*this, elideType ? AttrTypeElision::Must + : AttrTypeElision::Never); } void Attribute::dump() const {