llvm.org GIT mirror llvm / 2b1d3d7
Add StringRef based APIs to BitstreamWriter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79904 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
1 changed file(s) with 18 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1414 #ifndef BITSTREAM_WRITER_H
1515 #define BITSTREAM_WRITER_H
1616
17 #include "llvm/ADT/StringRef.h"
1718 #include "llvm/Bitcode/BitCodes.h"
1819 #include
1920
292293 /// known to exist at the end of the the record.
293294 template
294295 void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl &Vals,
295 const char *BlobData, unsigned BlobLen) {
296 const StringRef &Blob) {
297 const char *BlobData = Blob.data();
298 unsigned BlobLen = (unsigned) Blob.size();
296299 unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
297300 assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
298301 BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];
408411 /// the first entry.
409412 template
410413 void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl &Vals) {
411 EmitRecordWithAbbrevImpl(Abbrev, Vals, 0, 0);
414 EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef());
412415 }
413416
414417 /// EmitRecordWithBlob - Emit the specified record to the stream, using an
418421 /// of the record.
419422 template
420423 void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals,
424 const StringRef &Blob) {
425 EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob);
426 }
427 template
428 void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals,
421429 const char *BlobData, unsigned BlobLen) {
422 EmitRecordWithAbbrevImpl(Abbrev, Vals, BlobData, BlobLen);
430 return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(BlobData, BlobLen));
423431 }
424432
425433 /// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records
426434 /// that end with an array.
427435 template
428436 void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals,
437 const StringRef &Array) {
438 EmitRecordWithAbbrevImpl(Abbrev, Vals, Array);
439 }
440 template
441 void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals,
429442 const char *ArrayData, unsigned ArrayLen) {
430 EmitRecordWithAbbrevImpl(Abbrev, Vals, ArrayData, ArrayLen);
443 return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(ArrayData,
444 ArrayLen));
431445 }
432446
433447 //===--------------------------------------------------------------------===//