> I think this is going to be OK. I've got a couple comments though:
>
> - layout.getFieldOffset(fieldNo), tunit, RecordTy);
> + layout.getFieldOffset(fieldNo - 1), tunit,
> RecordTy);
>
> a) There are a few other places that use fieldNo and since you're not
> updating them it'd be nice to have some comments.
I see 4 uses total. One increments it, one decrements it, and this reference
uses the value; it had to become "fieldNo - 1" because the increment isn't
inside the "for" statement anymore. Those uses seem like normal tracking
behavior and don't warrant any extra commentary. If you still want some, let
me know.
The 4th use is in the lambda part of the method where AFAICT it will always be
zero (and possibly should be "fieldno" not "fieldNo", is that a bug? I know
squat about lambdas).
> b) Instead of inlining all the code for CollectRecordStaticVars how about
> outlining it into a couple of static functions?
Hmm, yeah the body of that loop is basically "if static-member do this; else if
field do that;" so factoring out those bits seems reasonable. (The lambda
part, which I didn't touch, probably also could be factored out for similar
reasons, but that might exceed the scope of what I'm doing with this patch.
Let me know.)
> c) Will this handle something like this:
>
> class A {
> static int a;
> };
>
> A a;
>
> where the variable A::a isn't defined in the file (but likely is somewhere
> else).
Sure. You'll get a DIE inside the class with DW_AT_external and
DW_AT_declaration, and no DW_AT_location; and then a global variable DIE for
the global "a" with type A. llvm-dwarfdump fragment attached.
--paulr
0x00000032: DW_TAG_class_type [4] *
0x00000033: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000068] = "A")
0x00000037: DW_AT_byte_size [DW_FORM_data1] (0x01)
0x00000038: DW_AT_decl_file [DW_FORM_data1] (0x01)
0x00000039: DW_AT_decl_line [DW_FORM_data1] (0x01)
0x0000003a: DW_TAG_variable [5]
0x0000003b: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000062] = "a")
0x0000003f: DW_AT_decl_file [DW_FORM_data1] (0x01)
0x00000040: DW_AT_decl_line [DW_FORM_data1] (0x02)
0x00000041: DW_AT_type [DW_FORM_ref4] (cu + 0x0026 => {0x00000026})
0x00000045: DW_AT_external [DW_FORM_flag_present] (true)
0x00000045: DW_AT_declaration [DW_FORM_flag_present] (true)
0x00000045: DW_AT_accessibility [DW_FORM_data1] (0x03)
0x00000046: DW_TAG_subprogram [6] *
0x00000047: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000068] = "A")
0x0000004b: DW_AT_decl_file [DW_FORM_data1] (0x01)
0x0000004c: DW_AT_decl_line [DW_FORM_data1] (0x01)
0x0000004d: DW_AT_declaration [DW_FORM_flag_present] (true)
0x0000004d: DW_AT_artificial [DW_FORM_flag_present] (true)
0x0000004d: DW_AT_external [DW_FORM_flag_present] (true)
0x0000004d: DW_AT_accessibility [DW_FORM_data1] (0x01)
0x0000004e: DW_TAG_formal_parameter [7]
0x0000004f: DW_AT_type [DW_FORM_ref4] (cu + 0x002d => {0x0000002d})
0x00000053: DW_AT_artificial [DW_FORM_flag_present] (true)
0x00000053: NULL
0x00000054: NULL
0x00000055: DW_TAG_variable [8]
0x00000056: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000062] = "a")
0x0000005a: DW_AT_type [DW_FORM_ref4] (cu + 0x0032 => {0x00000032})
0x0000005e: DW_AT_external [DW_FORM_flag_present] (true)
0x0000005e: DW_AT_decl_file [DW_FORM_data1] (0x01)
0x0000005f: DW_AT_decl_line [DW_FORM_data1] (0x05)
0x00000060: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 00 00 00 00 00 00
00 )
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits