[cfe-dev] Proposal: A "Const tool" for clang

Marshall Clow mclow.lists at gmail.com
Tue Feb 5 09:03:40 PST 2013

On Feb 4, 2013, at 9:58 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> On Tue, Feb 5, 2013 at 2:55 AM, Marshall Clow <mclow.lists at gmail.com> wrote:
>> Broadly speaking, there are three places where const can be added to an existing code base:
>>        * Parameters that are passed by reference or pointer can be passed by const pointer or const reference.
>>        * object methods can be marked as const
>>        * Return values that are returned by pointer or reference can be returned by const reference or const pointer. This may involve adding an additional function alongside the original, differing only in the return value.
> Local variables might require adding 'const', too.  A dumb example:
> int f(Z *z) {
>  Z *a = z->getA();
>  return a->getInt();
> }
> If there's a const and non-const overload of getA() and getInt(), then
> one can actually add const everywhere in this example.

Nice example - thanks!

-- Marshall

Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki

More information about the cfe-dev mailing list