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

Dmitri Gribenko gribozavr at gmail.com
Mon Feb 4 21:58:57 PST 2013

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.


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the cfe-dev mailing list