[Mlir-commits] [mlir] [MLIR] Add 'const' qualifier to some functions (PR #72430)
Akash Banerjee
llvmlistbot at llvm.org
Thu Nov 16 02:09:46 PST 2023
================
@@ -182,10 +182,10 @@ class Value {
/// Replace all uses of 'this' value with 'newValue' if the given callback
/// returns true.
void replaceUsesWithIf(Value newValue,
- function_ref<bool(OpOperand &)> shouldReplace);
+ function_ref<bool(OpOperand &)> shouldReplace) const;
----------------
TIFitis wrote:
It builds fine after adding the `const` qualifier, and the sibling functions - `mlir::Value::replaceAllUsesWith` and `mlir::Value::replaceAllUsesExcept` also already use the `const` qualifier.
I just happened to be working with some code where `replaceAllUsesWith` worked fine, but changing the function to `replaceUsesWithIf` I got the const qualification error.
At a first glance it looked like a bug/oversight to me to have the functions `replaceAllUsesWith` and `replaceAllUsesExcept` as `const` members but not `replaceUsesWithIf`, and hence I thought I'd fix it.
However, I'm not an expert at MLIR. If you feel like `replaceAllUsesWith` is different enough in this context to `replaceUsesWithIf` where there former can have the `const` qualifier while the latter not, then it doesn't particularly affect me in any way and we can close this PR.
https://github.com/llvm/llvm-project/pull/72430
More information about the Mlir-commits
mailing list