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

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon May 27 18:33:53 PDT 2024


ChuanqiXu9 wrote:

> > Can you make sure that at every place this PR touches `const` makes sense? I found out recently that we can be quite good at pretending that something is `const`, all the way down until we realize we need a `const_cast`, because modification is required in that one place.
> 
> I'm not quite sure I understand the question. This PR doesn't add any `const_cast`, and `const` is checked by the compiler so a successful build shows that we're never modifying something declared `const`. What additional work are you wanting?

The question is that it may be fine to be `const` today but it becomes not the case later. So we may have to make const  function back to non-const function again. So one style to do such things is to understand that the new `const` decorated places are meant to be `const`. Otherwise I'll suggest to only mark the places that need to be change by the following patch as `const`.

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


More information about the cfe-commits mailing list