[MLIR][ODS] Make dialect attribute helper member functions const (NFC) (#181111)

This commit marks member functions of dialect attribute helpers as
constant. This ensures that these helpers can be used as members of
rewrite patterns, whose `matchAndRewrite` functions are marked as const
as well.
This commit is contained in:
Christian Ulmann 2026-02-13 07:38:06 +01:00 committed by GitHub
parent da6851f9ef
commit 54c080da2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -207,23 +207,23 @@ static const char *const discardableAttrHelperDecl = R"(
static constexpr ::llvm::StringLiteral getNameStr() {{
return "{4}.{1}";
}
constexpr ::mlir::StringAttr getName() {{
constexpr ::mlir::StringAttr getName() const {{
return name;
}
{0}AttrHelper(::mlir::MLIRContext *ctx)
explicit {0}AttrHelper(::mlir::MLIRContext *ctx)
: name(::mlir::StringAttr::get(ctx, getNameStr())) {{}
{2} getAttr(::mlir::Operation *op) {{
{2} getAttr(::mlir::Operation *op) const {{
return op->getAttrOfType<{2}>(name);
}
void setAttr(::mlir::Operation *op, {2} val) {{
void setAttr(::mlir::Operation *op, {2} val) const {{
op->setAttr(name, val);
}
bool isAttrPresent(::mlir::Operation *op) {{
bool isAttrPresent(::mlir::Operation *op) const {{
return op->hasAttrOfType<{2}>(name);
}
void removeAttr(::mlir::Operation *op) {{
void removeAttr(::mlir::Operation *op) const {{
assert(op->hasAttrOfType<{2}>(name));
op->removeAttr(name);
}