[llvm-commits] [llvm] r136485 - /llvm/trunk/utils/TableGen/
David A. Greene
greened at obbligato.org
Fri Jul 29 14:45:11 PDT 2011
David Blaikie <dblaikie at gmail.com> writes:
>> "const" is most definitely NOT just noise. It conveys semantics and
>> catches errors at compile time.
>
> Can't really catch errors on a type that has no mutation.
Sure you can. What happens when someone accidentally adds a mutating
method? Or forgets about auto-generated operations? Or derives from
said type and adds mutating methods? Or writes code that takes a
non-const reference and tries to do something to mutate it? Or does
something in a supposedly non-mutating method that ends up changing
state?
There are lots of ways const can catch logical errors even if the
underlying type doesn't have mutating methods.
> & while I agree with you to an extent (in my own code I think I'd
> still be inclined to use const on types that are immutable - as I'd
> use C++ style casts, std::tie, etc), I think LLVM's code base has some
> of these attitudes sufficiently ingrained as to make it unreasonable
> to diverge from them at this point. (heck, I helped remove the const
> from llvm::Type, even if it didn't exactly match my own personal
> coding conventions)
I was actually asked to break out the constification change separately,
which is why this is additionally a bit confusing to me.
-Dave
More information about the llvm-commits
mailing list