[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

David Stone via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 10:51:36 PDT 2024


davidstone wrote:

> > Errr, not certain I agree with this -- that basically is "admit defeat and stop aiming for const correctness."
> 
> Well, I am saying, add const to places we are pretty sure we will never change, and leave const out when in doubt. Don't add const just because we don't need mutation today.

That's the opposite of my view. Mutation needs to be justified. "What if we need it later" can be used to justify anything, and if we do need it later then we change the code then. Until that point, readers can see `const` and know that things aren't being changed out from under them while reasoning about what the code does.

https://github.com/llvm/llvm-project/pull/93493


More information about the cfe-commits mailing list