[llvm] r192542 - yaml2coff/elf: Touchup for compatibility.

Will Dietz wdietz2 at illinois.edu
Sat Oct 12 14:29:17 PDT 2013


Author: wdietz2
Date: Sat Oct 12 16:29:16 2013
New Revision: 192542

URL: http://llvm.org/viewvc/llvm-project?rev=192542&view=rev
Log:
yaml2coff/elf: Touchup for compatibility.

* std::string::append(int, int) can be ambiguous.
* std::vector<>::data() is a C++11 feature, use ArrayRef abstraction.

Modified:
    llvm/trunk/tools/yaml2obj/yaml2coff.cpp
    llvm/trunk/tools/yaml2obj/yaml2elf.cpp

Modified: llvm/trunk/tools/yaml2obj/yaml2coff.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2coff.cpp?rev=192542&r1=192541&r2=192542&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2coff.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2coff.cpp Sat Oct 12 16:29:16 2013
@@ -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() {

Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=192542&r1=192541&r2=192542&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Sat Oct 12 16:29:16 2013
@@ -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 <class T>
-static size_t vectorDataSize(const std::vector<T> &Vec) {
-  return Vec.size() * sizeof(T);
+static size_t arrayDataSize(ArrayRef<T> A) {
+  return A.size() * sizeof(T);
 }
 
 template <class T>
-static void writeVectorData(raw_ostream &OS, const std::vector<T> &Vec) {
-  OS.write((const char *)Vec.data(), vectorDataSize(Vec));
+static void writeArrayData(raw_ostream &OS, ArrayRef<T> A) {
+  OS.write((const char *)A.data(), arrayDataSize(A));
 }
 
 template <class T>
@@ -235,8 +236,9 @@ handleSymtabSectionHeader(const ELFYAML:
   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 <class ELFT>
@@ -359,7 +361,7 @@ static int writeELF(raw_ostream &OS, con
   SHeaders.push_back(SHStrTabSHeader);
 
   OS.write((const char *)&Header, sizeof(Header));
-  writeVectorData(OS, SHeaders);
+  writeArrayData(OS, makeArrayRef(SHeaders));
   CBA.writeBlobToStream(OS);
   return 0;
 }





More information about the llvm-commits mailing list