[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue May 28 10:35:36 PDT 2024
AaronBallman wrote:
> My philosophy on problems like that is that the first step to getting out of a hole is to stop digging the hole. We aren't going to make all of clang const-correct overnight, right?
Yup! I think we're in agreement with the long-term goal and how we get there. The devil is in the details (as always). For example, one thing we do all over the place in Clang is `const_cast` away constness of AST nodes, safe in the knowledge that they have to have been dynamically allocated, and thus we can never hit the UB of "original declaration of the object was const". I'd like to see us move away from this sort of "technically correct" and towards "obviously correct", and this moves in the right direction IMO.
> To me, this commit is considering the bigger picture. Rather than just saying "Oh, I am going to change the interface of Module so that it can control its invariants and to do that I need to make just these parts const-correct", I noticed I needed to make that change in some parts so as a preparatory commit (this one) I first make sure we are as const-correct as we can be with the current Module interface. Then I'll be going through and adding more const later on as I refactor more of Module.
Okay, that's good to know, thank you!
> I could agree on being const correct here, but mostly by removing const, not adding more, in the general case.
Errr, not certain I agree with this -- that basically is "admit defeat and stop aiming for const correctness."
https://github.com/llvm/llvm-project/pull/93493
More information about the cfe-commits
mailing list