This change fixes pr24916. As associated test has been added.
Details
Diff Detail
Event Timeline
Can you change the name of the folder to something more descripive than pr24916. For example, you could put pr24916 in a comment in the test, but the test itself could have a descriptive name. Enrico at Apple just went and did a sweep removing rdar's from bug trackers. The public tracker is not exactly the same since it's, well, public. But still it requires more mental (and physical) cycles to parse than it does to parse something like limit-debug-info.
Makefile stuff looks good. Is the plan to do the same thing for the previous patch you submitted last week? What's the status of that?
About Makefile changes in other tests, I will one day clean all places where no-limit-debug-info shows up in the Makefile.
Just in case, zturner's comment about Makefiles on the other change came in a day after I landed the change. So, I will have to do it in another change.
So this fix is really to take care of the case where a class methods might be defined on only some class instances? Can you explain more of what this fixes?
I will use an example to explain the problem that this patch is trying to solve.
class.h:
class C { public: C () { c = 0; } virtual int method(); private: int c; };
class.cpp:
#include "class.h" int C::method () { return c; }
main.cpp:
#include "class.h" int main () { C c; return c.method(); }
Compile as follows:
g++|clang++ -g class.cpp main.cpp # on mac you will require -flimit-debug-info
The interesting DWARF for the CU main.cpp is here:
< 1><0x00000029> DW_TAG_class_type DW_AT_name "C" DW_AT_declaration yes(1) DW_AT_sibling <0x00000041> < 2><0x00000030> DW_TAG_subprogram DW_AT_external yes(1) DW_AT_name "C" DW_AT_decl_file 0x00000001 class.h DW_AT_decl_line 0x00000005 DW_AT_accessibility DW_ACCESS_public DW_AT_declaration yes(1) DW_AT_object_pointer <0x0000003a> < 3><0x0000003a> DW_TAG_formal_parameter DW_AT_type <0x00000041> DW_AT_artificial yes(1)
As you can see, there is a method declaration under a class declaration (not definition). The same CU also has subprogram DIEs as follows:
< 1><0x00000047> DW_TAG_subprogram DW_AT_specification <0x00000030> DW_AT_inline DW_INL_declared_not_inlined DW_AT_object_pointer <0x00000055> DW_AT_sibling <0x0000005f> < 2><0x00000055> DW_TAG_formal_parameter DW_AT_name "this" DW_AT_type <0x0000005f> DW_AT_artificial yes(1) < 1><0x0000005f> DW_TAG_const_type DW_AT_type <0x00000041> < 1><0x00000064> DW_TAG_subprogram DW_AT_abstract_origin <0x00000047> DW_AT_linkage_name "_ZN1CC2Ev" DW_AT_low_pc 0x00400640 DW_AT_high_pc <offset-from-lowpc>32 DW_AT_frame_base len 0x0001: 9c: DW_OP_call_frame_cfa DW_AT_object_pointer <0x00000087> DW_AT_GNU_all_call_sites yes(1) DW_AT_sibling <0x00000090> < 2><0x00000087> DW_TAG_formal_parameter DW_AT_abstract_origin <0x00000055> DW_AT_location len 0x0002: 9168: DW_OP_fbreg -24
The DWARF for the CU class.cpp has the full definition of the class (with all its methods), but does not have subprogram DIEs which refer to the methods in the class definition. So, when stopped in C::C, the context resolves to an incomplete class for which a full definition also exists. This patch is essentially saying, "use the complete definition of the class when you find its incomplete definition."
Thanks for the info, now the patch makes more sense. That is some really lame DWARF I must say, but alas we must deal with it. Looks good.