[PATCH] D101341: Initialize optional members of ELFYAML types.

Vyacheslav Zakharin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 26 21:10:40 PDT 2021


vzakhari created this revision.
Herald added subscribers: atanasyan, arichardson, sdardis.
vzakhari requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This change-set initializes optional memrbers of `ELFYAML` types to their default values (as defined in `ELFYAML.cpp` mapping traits).

For example, since `Section` has a user-defined constructor, one cannot neither default-initialize (e.g. with `Section MySection;`) nor zero-initilize it (e.g. with `Section MySection{};`) completely.  The optional members will be uninitialized.  The same is true for `MipsABIFlags`.

Moreover, `YamlIO` documentation says that the native types must have default constructors that must initialize the optional members: https://llvm.org/docs/YamlIO.html#default-values

This change-set is almost no-op, since I have not found uses that output `ELFYAML` structures as YAML.  The new unit test seems to be the first such use.  The unit test will fail in an undefined way, if the optional members are not properly initialized.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101341

Files:
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/unittests/ObjectYAML/ELFYAMLTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101341.340719.patch
Type: text/x-patch
Size: 12394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/31825518/attachment.bin>


More information about the llvm-commits mailing list