constifying utility?

It seems (in principle) feasible for a utility to scan some function
or method and detect that in fact some non-const
parameters can't be modified. In that case it could suggest that that
parameter be made const. Similarly for const methods,
I guess.

Anybody written such a utility, or thought about it and decided not to
for some reason?

hi Bruce,

my attempt was this: <https://github.com/rizsotto/Constantine>

regards,
Laszlo

hi Bruce,

my attempt was this: <https://github.com/rizsotto/Constantine>

Hi Laszlo,

this looks pretty cool - I'd be curious why you made this a plugin instead
of a standalone tool that would be able to insert the const where needed.

Cheers,
/Manuel

hi Manuel,

thanks for the nice words. :slight_smile: i did it as plugin, because i was
learning what libclang can do. i'm gonna give another try next year...
with the new release... and maybe as a standalone tool with rewrite as
you suggested... but for that, i will need to learn more before. :wink:

regards,
Laszlo

hi Manuel,

thanks for the nice words. :slight_smile: i did it as plugin, because i was
learning what libclang can do. i'm gonna give another try next year...
with the new release... and maybe as a standalone tool with rewrite as
you suggested... but for that, i will need to learn more before. :wink:

Looking forward to it :slight_smile: I know a few people who would be very interested
in such a tool...

Me, too!

I’ve written about possible use cases here:
http://marshall.calepin.co/a-const-tool-for-llvm.html
(which contains a link to Constantine)

— Marshall