[PATCH] D158598: [RFC][GlobalISel] Remove const from most MatchTableExecutor methods
Pierre van Houtryve via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 05:22:05 PDT 2023
Pierre-vh added a comment.
Additional context: While refactoring this area for some upcoming diffs (removing the deprecated GICombiner backend), I changed some data members from `T&` to `T` and got a lot of errors due to this.
While I usually favor const-correctness as much as possible, it's really never respected here. We always use references or pointers, which means we can always call non-const functions on those even in a const function.
Example:
struct Foo {
int foo() {
return 0;
}
};
struct Bar {
Foo &F;
void bar() const {
F.foo();
}
};
So there's two solutions, the first one is for me to use `mutable` whenever I run into a case like this when refactoring, or we can just eliminate `const` where it doesn't make sense.
I'm fine with both, but I think it's cleaner to just eliminate these "fake const" that don't really guarantee anything in terms of semantics. Hence why this diff is a RFC.
e.g. we constantly mutate state - directly or indirectly - in those functions through the MIR builder, MRI, Observers, etc.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158598/new/
https://reviews.llvm.org/D158598
More information about the llvm-commits
mailing list