jurahul wrote: > Do Init objects have any methods that can modify them? `const` was explicitly > removed from some uses a long time ago > [af8ee2c](https://github.com/llvm/llvm-project/commit/af8ee2cdeeb2ed35fdf0db8f7c06254c5d333ac4). > > Here's a very old thread about removing `const` from IR `Type` pointers > because they are immutable. > https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20110711/124192.html > I assume a similar thinking was being applied to Init objects.
That's a good point. Though I do see "const Type*" pointers in the code. I'd think there is a difference between an implementation detail of "this class is uniqued in the impl and therefore immutable" vs "irrespective of being uniqued or not, in this code I do not intend to modify it". The const-ness of pointers expresses the second one, regardless of the implementation detail of whether the object itself is immutable or not. But I'll let the reviewers decide. Note that some changes of this nature have been committed earlier for Clang and MLIR tablegen backends (as a prep for this one). Also, this enables us to get rid of a bunch of const_casts<> in the various Init::Fold() methods (which are const, but currently return non-const Init ptr, and when the Fold is unresolved have to const_cast<> this to non-const pointer to return it). So making them const just seems to play nicer with C++. https://github.com/llvm/llvm-project/pull/112705 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits