From 6dd7893e8c7234d65cdc47e3f3ce251fdfb35768 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Oct 2013 21:29:16 +0000 Subject: [PATCH] yaml2coff/elf: Touchup for compatibility. * std::string::append(int, int) can be ambiguous. * std::vector<>::data() is a C++11 feature, use ArrayRef abstraction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192542 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/yaml2obj/yaml2coff.cpp | 2 +- tools/yaml2obj/yaml2elf.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/yaml2obj/yaml2coff.cpp b/tools/yaml2obj/yaml2coff.cpp index 11aae0e68b6..c757eb64fb7 100644 --- a/tools/yaml2obj/yaml2coff.cpp +++ b/tools/yaml2obj/yaml2coff.cpp @@ -32,7 +32,7 @@ struct COFFParser { COFFParser(COFFYAML::Object &Obj) : Obj(Obj) { // A COFF string table always starts with a 4 byte size field. Offsets into // it include this size, so allocate it now. - StringTable.append(4, 0); + StringTable.append(4, char(0)); } bool parseSections() { diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp index d3b25ecf09b..d46e1549877 100644 --- a/tools/yaml2obj/yaml2elf.cpp +++ b/tools/yaml2obj/yaml2elf.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "yaml2obj.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Object/ELFObjectFile.h" #include "llvm/Object/ELFYAML.h" #include "llvm/Support/ELF.h" @@ -119,13 +120,13 @@ public: } // end anonymous namespace template -static size_t vectorDataSize(const std::vector &Vec) { - return Vec.size() * sizeof(T); +static size_t arrayDataSize(ArrayRef A) { + return A.size() * sizeof(T); } template -static void writeVectorData(raw_ostream &OS, const std::vector &Vec) { - OS.write((const char *)Vec.data(), vectorDataSize(Vec)); +static void writeArrayData(raw_ostream &OS, ArrayRef A) { + OS.write((const char *)A.data(), arrayDataSize(A)); } template @@ -235,8 +236,9 @@ handleSymtabSectionHeader(const ELFYAML::LocalGlobalWeakSymbols &Symbols, addSymbols(Symbols.Weak, State, Syms, ELF::STB_WEAK); ContiguousBlobAccumulator &CBA = State.getSectionContentAccum(); - writeVectorData(CBA.getOSAndAlignedOffset(SHeader.sh_offset), Syms); - SHeader.sh_size = vectorDataSize(Syms); + writeArrayData(CBA.getOSAndAlignedOffset(SHeader.sh_offset), + makeArrayRef(Syms)); + SHeader.sh_size = arrayDataSize(makeArrayRef(Syms)); } template @@ -359,7 +361,7 @@ static int writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) { SHeaders.push_back(SHStrTabSHeader); OS.write((const char *)&Header, sizeof(Header)); - writeVectorData(OS, SHeaders); + writeArrayData(OS, makeArrayRef(SHeaders)); CBA.writeBlobToStream(OS); return 0; } -- 2.34.1