Page MenuHome

Avoid shadow warning with class member `ptr` and local `ptr` variable.
Needs RevisionPublic

Authored by Campbell Barton (campbellbarton) on Jul 8 2019, 11:40 AM.

Details

Summary

Avoids shadowing, makes it easier to follow which variables are members, which are local.

Warnings from clang:

<scratch space>:47:1: note: expanded from here
COLLECTION_PROPERTY_LOOKUP_INT_false
^
source/blender/makesrna/intern/RNA_blender_cpp.h:111:74: note: expanded from macro 'COLLECTION_PROPERTY_LOOKUP_INT_false'
    inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \
                                                                         ^
source/blender/makesrna/intern/RNA_blender_cpp.h:193:16: note: declared here
    PointerRNA ptr;
               ^
source/blender/makesrna/intern/RNA_blender_cpp.h:38795:2: warning: parameter 'ptr' shadows member inherited from type 'Pointer' [-Wshadow-field]
        COLLECTION_PROPERTY(MaskLayers, MaskLayer, Mask, layers, false, false, false)
        ^
source/blender/makesrna/intern/RNA_blender_cpp.h:176:5: note: expanded from macro 'COLLECTION_PROPERTY'
    COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \
    ^
<scratch space>:60:1: note: expanded from here
COLLECTION_PROPERTY_LOOKUP_STRING_false
^
source/blender/makesrna/intern/RNA_blender_cpp.h:139:77: note: expanded from macro 'COLLECTION_PROPERTY_LOOKUP_STRING_false'
    inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \
                                                                            ^
source/blender/makesrna/intern/RNA_blender_cpp.h:193:16: note: declared here
    PointerRNA ptr;
               ^

Diff Detail

Repository
rB Blender
Branch
TEMP-RNA-SHADOW-PTR (branched from master)
Build Status
Buildable 3990
Build 3990: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from Avoid shadow warning with ptr and local ptr variable. to Avoid shadow warning with class member `ptr` and local `ptr` variable..
Sergey Sharybin (sergey) requested changes to this revision.Jul 8 2019, 11:54 AM

Avoids shadowing, makes it easier to follow which variables are members, which are local.

This is code-generated thing, nobody is supposed to look at it. This is still a mess around (PointerRNA *ptr, const char *key, PointerRNA *r_ptr). ptr, r_ptr ouch.

This change breaks Cycles: we do need access ptr there, and using m_ptr is wrong. m_ prefix or _ suffix is not supposed to be used on a public members.
To me it seems actual fix would be to address other ptrs. Some of them should become current_ptr when iterating. And solve the mystery of input/output parameters mentioned above.

This revision now requires changes to proceed.Jul 8 2019, 11:54 AM