This patch emits DW_AT_accessibility attribute for class/struct/union types.
Sample program :
class A { public: struct B { }; public: B b; }; struct C { private: union D { }; public: D d; }; union E { private: class F { }; class G { }; public: F f; G g; };
Debug info without this patch:
0x0000013d: DW_TAG_class_type DW_AT_name ("A") 0x00000143: DW_TAG_member DW_AT_name ("b") DW_AT_accessibility (DW_ACCESS_public) 0x0000014e: DW_TAG_structure_type DW_AT_name ("B") // no accessibility attribute is present, private access is assumed for B. 0x00000155: DW_TAG_structure_type DW_AT_name ("C") 0x0000015b: DW_TAG_member DW_AT_name ("d") 0x00000165: DW_TAG_union_type DW_AT_name ("D") // no accessibility attribute is present, public access is assumed for D. 0x0000016c: DW_TAG_union_type DW_AT_name ("E") 0x00000172: DW_TAG_member DW_AT_name ("f") 0x0000017c: DW_TAG_class_type DW_AT_name ("F") // no accessibility attribute is present, public access is assumed for F. 0x00000182: DW_TAG_member DW_AT_name ("g") 0x0000018c: DW_TAG_class_type DW_AT_name ("G") // no accessibility attribute is present, public access is assumed for G.
Will we generate a redundant flag if we define a private type in the class or a public type in the struct/union? Maybe we could add a case for that too.