[llvm-dev] RFC: Add DWARF support for yaml2obj

Pavel Labath via llvm-dev llvm-dev at lists.llvm.org
Fri May 22 02:46:24 PDT 2020


On 22/05/2020 10:38, Xing GUO wrote:
>  BTW, I think
> the value of "DW_AT_decl_file" shall be "Str"? Can we map the values
> of different types into same field?
> 
> """
> - Attr: DW_AT_decl_file
>   Str: foo
> """
Yes, that is definitely possible. You just need to make the map calls
conditional on the values of other attributes. Maybe something like this:
IO.mapRequired("Attr", Attr);
IO.mapOptional("Form", Form, getDefaultForm(Attr, Ctx.isSplitDwarf()
/*or whatever*/));
switch (getFormClass(Form)) {
/* The cases could correspond to DWARF5 form classes, but maybe not
completely.*/
case String: IO.mapRequired("Value", Value.String);
case Constant: IO.mapRequired("Value", Value.Int);
case Block: IO.mapRequired("Value", Value.Bytes);
...
}


I think doing something like that would be reasonable, because i expect
a relatively high number of "classes", and I think it might be tricky to
remember which key to use for which value type.

cheers,
Pavel


More information about the llvm-dev mailing list