From: Mehdi Amini Date: Thu, 10 Sep 2015 00:05:09 +0000 (+0000) Subject: Bitcode Writer: EmitRecordWith* takes an ArrayRef instead of a SmallVector (NFC) X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=a8544fbcdbe94b8a9ca829bcf1d3bb552e671685 Bitcode Writer: EmitRecordWith* takes an ArrayRef instead of a SmallVector (NFC) This reapply commit r247178 after post-commit review from D.Blaikie in a way that makes it compatible with the existing API. From: Mehdi Amini git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247215 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h index 648a06e202e..1fded87295d 100644 --- a/include/llvm/Bitcode/BitstreamWriter.h +++ b/include/llvm/Bitcode/BitstreamWriter.h @@ -15,6 +15,7 @@ #ifndef LLVM_BITCODE_BITSTREAMWRITER_H #define LLVM_BITCODE_BITSTREAMWRITER_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -289,8 +290,8 @@ private: /// known to exist at the end of the record. If Code is specified, then /// it is the record code to emit before the Vals, which must not contain /// the code. - template - void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl &Vals, + template + void EmitRecordWithAbbrevImpl(unsigned Abbrev, ArrayRef Vals, StringRef Blob, Optional Code) { const char *BlobData = Blob.data(); unsigned BlobLen = (unsigned) Blob.size(); @@ -412,15 +413,15 @@ public: return; } - EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(), Code); + EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(), Code); } /// EmitRecordWithAbbrev - Emit a record with the specified abbreviation. /// Unlike EmitRecord, the code for the record should be included in Vals as /// the first entry. - template - void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl &Vals) { - EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(), None); + template + void EmitRecordWithAbbrev(unsigned Abbrev, const Container &Vals) { + EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(), None); } /// EmitRecordWithBlob - Emit the specified record to the stream, using an @@ -428,29 +429,29 @@ public: /// specified by the pointer and length specified at the end. In contrast to /// EmitRecord, this routine expects that the first entry in Vals is the code /// of the record. - template - void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals, + template + void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, StringRef Blob) { - EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob, None); + EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None); } - template - void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals, + template + void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, const char *BlobData, unsigned BlobLen) { - return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(BlobData, BlobLen), - None); + return EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), + StringRef(BlobData, BlobLen), None); } /// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records /// that end with an array. - template - void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals, - StringRef Array) { - EmitRecordWithAbbrevImpl(Abbrev, Vals, Array, None); + template + void EmitRecordWithArray(unsigned Abbrev, const Container &Vals, + StringRef Array) { + EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Array, None); } - template - void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals, - const char *ArrayData, unsigned ArrayLen) { - return EmitRecordWithAbbrevImpl(Abbrev, Vals, + template + void EmitRecordWithArray(unsigned Abbrev, const Container &Vals, + const char *ArrayData, unsigned ArrayLen) { + return EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(ArrayData, ArrayLen), None); }