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 <mehdi.amini@apple.com>
llvm-svn: 247215
This commit is contained in:
Mehdi Amini 2015-09-10 00:05:09 +00:00
parent defa546551
commit c7aa5ca8a8
1 changed files with 22 additions and 21 deletions

View File

@ -15,6 +15,7 @@
#ifndef LLVM_BITCODE_BITSTREAMWRITER_H #ifndef LLVM_BITCODE_BITSTREAMWRITER_H
#define LLVM_BITCODE_BITSTREAMWRITER_H #define LLVM_BITCODE_BITSTREAMWRITER_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.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 /// 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 /// it is the record code to emit before the Vals, which must not contain
/// the code. /// the code.
template<typename uintty> template <typename uintty>
void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, void EmitRecordWithAbbrevImpl(unsigned Abbrev, ArrayRef<uintty> Vals,
StringRef Blob, Optional<unsigned> Code) { StringRef Blob, Optional<unsigned> Code) {
const char *BlobData = Blob.data(); const char *BlobData = Blob.data();
unsigned BlobLen = (unsigned) Blob.size(); unsigned BlobLen = (unsigned) Blob.size();
@ -412,15 +413,15 @@ public:
return; return;
} }
EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(), Code); EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(), Code);
} }
/// EmitRecordWithAbbrev - Emit a record with the specified abbreviation. /// EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
/// Unlike EmitRecord, the code for the record should be included in Vals as /// Unlike EmitRecord, the code for the record should be included in Vals as
/// the first entry. /// the first entry.
template<typename uintty> template <typename Container>
void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl<uintty> &Vals) { void EmitRecordWithAbbrev(unsigned Abbrev, const Container &Vals) {
EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(), None); EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(), None);
} }
/// EmitRecordWithBlob - Emit the specified record to the stream, using an /// 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 /// 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 /// EmitRecord, this routine expects that the first entry in Vals is the code
/// of the record. /// of the record.
template<typename uintty> template <typename Container>
void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
StringRef Blob) { StringRef Blob) {
EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob, None); EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None);
} }
template<typename uintty> template <typename Container>
void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
const char *BlobData, unsigned BlobLen) { const char *BlobData, unsigned BlobLen) {
return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(BlobData, BlobLen), return EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals),
None); StringRef(BlobData, BlobLen), None);
} }
/// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records /// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records
/// that end with an array. /// that end with an array.
template<typename uintty> template <typename Container>
void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, void EmitRecordWithArray(unsigned Abbrev, const Container &Vals,
StringRef Array) { StringRef Array) {
EmitRecordWithAbbrevImpl(Abbrev, Vals, Array, None); EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Array, None);
} }
template<typename uintty> template <typename Container>
void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl<uintty> &Vals, void EmitRecordWithArray(unsigned Abbrev, const Container &Vals,
const char *ArrayData, unsigned ArrayLen) { const char *ArrayData, unsigned ArrayLen) {
return EmitRecordWithAbbrevImpl(Abbrev, Vals, return EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals),
StringRef(ArrayData, ArrayLen), None); StringRef(ArrayData, ArrayLen), None);
} }