summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-24 09:29:31 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-24 09:29:31 +0000
commit2b1d3d76d78353d3d7c793d437c6ee355dd0f9ab (patch)
tree05bd17848c1f2db75d175bc0015112cc08b21969
parent1464869cb325e30673005a16accaf47da8b6ba1b (diff)
downloadllvm-2b1d3d76d78353d3d7c793d437c6ee355dd0f9ab.tar.gz
llvm-2b1d3d76d78353d3d7c793d437c6ee355dd0f9ab.tar.bz2
llvm-2b1d3d76d78353d3d7c793d437c6ee355dd0f9ab.tar.xz
Add StringRef based APIs to BitstreamWriter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79904 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Bitcode/BitstreamWriter.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h
index 55dd4dd49b..e48a190833 100644
--- a/include/llvm/Bitcode/BitstreamWriter.h
+++ b/include/llvm/Bitcode/BitstreamWriter.h
@@ -15,6 +15,7 @@
#ifndef BITSTREAM_WRITER_H
#define BITSTREAM_WRITER_H
+#include "llvm/ADT/StringRef.h"
#include "llvm/Bitcode/BitCodes.h"
#include <vector>
@@ -293,7 +294,9 @@ private:
/// known to exist at the end of the the record.
template<typename uintty>
void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl<uintty> &Vals,
- const char *BlobData, unsigned BlobLen) {
+ const StringRef &Blob) {
+ const char *BlobData = Blob.data();
+ unsigned BlobLen = (unsigned) Blob.size();
unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];
@@ -409,7 +412,7 @@ public:
/// the first entry.
template<typename uintty>
void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl<uintty> &Vals) {
- EmitRecordWithAbbrevImpl(Abbrev, Vals, 0, 0);
+ EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef());
}
/// EmitRecordWithBlob - Emit the specified record to the stream, using an
@@ -419,16 +422,27 @@ public:
/// of the record.
template<typename uintty>
void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl<uintty> &Vals,
+ const StringRef &Blob) {
+ EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob);
+ }
+ template<typename uintty>
+ void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl<uintty> &Vals,
const char *BlobData, unsigned BlobLen) {
- EmitRecordWithAbbrevImpl(Abbrev, Vals, BlobData, BlobLen);
+ return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(BlobData, BlobLen));
}
/// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records
/// that end with an array.
template<typename uintty>
void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl<uintty> &Vals,
+ const StringRef &Array) {
+ EmitRecordWithAbbrevImpl(Abbrev, Vals, Array);
+ }
+ template<typename uintty>
+ void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl<uintty> &Vals,
const char *ArrayData, unsigned ArrayLen) {
- EmitRecordWithAbbrevImpl(Abbrev, Vals, ArrayData, ArrayLen);
+ return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(ArrayData,
+ ArrayLen));
}
//===--------------------------------------------------------------------===//