This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Add a way to set default values for macros used in a YAML.
ClosedPublic

Authored by grimar on Jun 24 2020, 5:40 AM.

Details

Summary

Currently we have to override all macros that are declared. But in many
cases it is convenient to use default values and to override only
a particular one or two.

This provides a way to set a default value for any macro:

Symbols:
  - Name: [[FOO=foo]]

Diff Detail

Event Timeline

grimar created this revision.Jun 24 2020, 5:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2020, 5:40 AM
MaskRay added inline comments.Jun 24 2020, 12:08 PM
llvm/test/tools/yaml2obj/macro.yaml
68

The two YAML !ELF documents can be merged to make the file simpler.

llvm/tools/yaml2obj/yaml2obj.cpp
84

a default macro value if present.

"YAML description" is implied from the context.

90

!Default.empty() || MacroExpr.endswith("=")

jhenderson accepted this revision.Jun 25 2020, 12:41 AM

Thanks for looking at this. I've had a few times where this might have been useful already. Do we need a way of escaping the = in the event somebody wants to explicitly include it? Not sure I can think of a use-case for that, so probably not, but something to think about.

LGTM, with @MaskRay's comments and one nit addressed.

llvm/tools/yaml2obj/yaml2obj.cpp
83

a value provided -> the provided value

This revision is now accepted and ready to land.Jun 25 2020, 12:41 AM

Do we need a way of escaping the = in the event somebody wants to explicitly include it? Not sure I can think of a use-case for that, so probably not, but something to think about.

I thought that we might add a --nomacro option. But I doubt that we really need it too.

grimar updated this revision to Diff 273311.Jun 25 2020, 5:03 AM
grimar marked 4 inline comments as done.
  • Addressed review comments.
jhenderson accepted this revision.Jun 26 2020, 1:27 AM

Latest version LGTM.

This revision was automatically updated to reflect the committed changes.