[PATCH] D64999: [yaml2obj] - Change how we handle implicit sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 00:50:54 PDT 2019


grimar added inline comments.


================
Comment at: tools/yaml2obj/yaml2elf.cpp:205
+
+    std::unique_ptr<ELFYAML::Section> Sec = llvm::make_unique<ELFYAML::Section>(
+        ELFYAML::Section::SectionKind::RawContent);
----------------
MaskRay wrote:
> ```
> Doc.Sections.emplace_back(ELFYAML::Section::SectionKind::RawContent, true)
> Doc.Sections.back()->Name = SecName; // After llvm migrates to C++17, we can leverage the reference return type of emplace_back.
> ```;
> Doc.Sections.emplace_back(ELFYAML::Section::SectionKind::RawContent, true)

I can't do this. `Doc.Sections` is a vector of `unique_ptr<Section>` And compiler reasonably barks:

> 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xmemory0(881): error C2664: 'std::unique_ptr<llvm::ELFYAML::Section,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': cannot convert argument 1 from '_Ty' to 'llvm::ELFYAML::Section *'
> 1>        with
> 1>        [
> 1>            _Ty=llvm::ELFYAML::Section
> 1>        ]
> 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xmemory0(881): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
> 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vector(902): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,llvm::ELFYAML::Section::SectionKind,bool>(_Alloc &,_Objty *const ,llvm::ELFYAML::Section::SectionKind &&,bool &&)' being compiled
> 1>        with
> 1>        [
> 1>            _Alloc=std::allocator<std::unique_ptr<llvm::ELFYAML::Section,std::default_delete<llvm::ELFYAML::Section>>>,
> 1>            _Ty=std::unique_ptr<llvm::ELFYAML::Section,std::default_delete<llvm::ELFYAML::Section>>,
> 1>            _Objty=std::unique_ptr<llvm::ELFYAML::Section,std::default_delete<llvm::ELFYAML::Section>>
> 1>        ]




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

https://reviews.llvm.org/D64999





More information about the llvm-commits mailing list