Shadowing a class member: wrong?
Posted Jan 29, 2010 16:35 UTC (Fri) by giraffedata
In reply to: LCA: Static analysis with GCC plugins
Parent article: LCA: Static analysis with GCC plugins
I'd say an even more basic goal is to provide the coder with tools to assist in his personal coding style. If you like to use local variables that shadow class members, fine. Don't turn on this checker. But if you avoid that because you find you do it wrong too often, turn on the checker.
Personally, I wouldn't use this, but would really like to see a checker that catches every time I refer to a class member implicitly (i.e. without "this->". To prevent confusion about what is a class member and what is local, I observe a discipline of always referring to the former with this->, but get burned sometimes when I neglect to define a local variable and implicitly get a class member instead.
to post comments)