[PATCH] D71872: [yaml2obj/obj2yaml] - Add support for SHT_RELR sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 29 04:15:18 PST 2019


grimar added inline comments.


================
Comment at: llvm/tools/obj2yaml/elf2yaml.cpp:745
+    for (Elf_Relr Rel : *Relrs)
+      S->Entries->emplace_back(Rel);
+    return S.release();
----------------
MaskRay wrote:
> Nit: when there is a choice between push_back and emplace_back with the same arguments, push_back may be more readable, because push_back expresses the intent more specifically.
> 
> For example, for `std::vector<std::vector<int>> a`, it accepts `a.emplace_back(10)` but not `a.push_back(10)`. push_back makes the reader think less.
I can't use `push_back` here: 

```
Error	C2664	'void std::vector<llvm::yaml::Hex64,std::allocator<_Ty>>::push_back(_Ty &&)':
cannot convert argument 1 from 'llvm::support::detail::packed_endian_specific_integral<uint64_t,llvm::support::little,1,1>'
to 'const _Ty &'	obj2yaml	D:\Work3\LLVM\llvm-project\llvm\tools\obj2yaml\elf2yaml.cpp	745	
```

It happens because `Entries` is a `std::vector<llvm::yaml::Hex64>`.
I need to insert `Elf_Relr`, which is `packed<uint>`.
`emplace_back` is needed to use Hex64's constructor: `Hex64(const uint64_t v)`



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71872/new/

https://reviews.llvm.org/D71872





More information about the llvm-commits mailing list