getAsInstruction is the only non-const member method.
It is impossible to enforce const-correctness because of it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM, but in which cases are we enforcing const-correctness? const-correctness is not a property LLVM enforces almost anywhere because of its virality.
@jmolloy in our case we use LLVM as a library. We use getAsInstruction down the road and it forces us to remove all const qualifiers from a custom InstVisitor even though we only read the values and do not modify anything.
Hi Alex,
Thanks. That's fair, and because this is the only member that wasn't const-correct I approved this change. But bear in mind in general that LLVM is not intended to be const-correct by design. More invasive patches may get more pushback.
Cheers,
James
Thanks for the heads up @jmolloy. Unfortunately, I learned the hard way that const qualified objects in LLVM are not necessarily constant and should not be considered as such.