[clang] [clang-tools-extra] [clang][NFC] Un-constify `MultiLevelTemplateArgumentList` (PR #104687)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 19 08:02:06 PDT 2024


cor3ntin wrote:

> I can’t say I know the full scope of this refactor (as in, what it would actually take to remove all of these const_casts for good, because if I understand this correctly, this is only supposed to be the first step here because it ends up adding more const_casts than it removes, from what I can tell), but I guess my two cents is that, while that statement makes sense to me, my understanding is that e.g. AST nodes in general aren’t really supposed to be modified after creation, but we have to do that in a bunch of places anyway. This just seems like another example of that.

_have to_ does a lot of heavy lifting in the present case.
What we do here is "temporarily pretend this argument has not been deduced yet during this instantiation" which we implement by the mean of "set this to null for the duration of this scope".
There are other ways to do that.

But the template argument list is certainly _morally_ const and it is certainly immutable from the point of view of the caller.
I think if we remove all the consts there is a higher chance that we actually end up mutating arguments in a persistent manner and that would be bad.



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


More information about the cfe-commits mailing list