llvm.org GIT mirror llvm / a8544fb
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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247215 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 5 years ago
1 changed file(s) with 24 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
1414 #ifndef LLVM_BITCODE_BITSTREAMWRITER_H
1515 #define LLVM_BITCODE_BITSTREAMWRITER_H
1616
17 #include "llvm/ADT/ArrayRef.h"
1718 #include "llvm/ADT/Optional.h"
1819 #include "llvm/ADT/SmallVector.h"
1920 #include "llvm/ADT/StringRef.h"
288289 /// known to exist at the end of the record. If Code is specified, then
289290 /// it is the record code to emit before the Vals, which must not contain
290291 /// the code.
291 template
292 void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl &Vals,
292 template
293 void EmitRecordWithAbbrevImpl(unsigned Abbrev, ArrayRef Vals,
293294 StringRef Blob, Optional Code) {
294295 const char *BlobData = Blob.data();
295296 unsigned BlobLen = (unsigned) Blob.size();
411412 return;
412413 }
413414
414 EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(), Code);
415 EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(), Code);
415416 }
416417
417418 /// EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
418419 /// Unlike EmitRecord, the code for the record should be included in Vals as
419420 /// the first entry.
420 template
421 void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl &Vals) {
422 EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(), None);
421 template
422 void EmitRecordWithAbbrev(unsigned Abbrev, const Container &Vals) {
423 EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), StringRef(), None);
423424 }
424425
425426 /// EmitRecordWithBlob - Emit the specified record to the stream, using an
427428 /// specified by the pointer and length specified at the end. In contrast to
428429 /// EmitRecord, this routine expects that the first entry in Vals is the code
429430 /// of the record.
430 template
431 void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals,
431 template
432 void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
432433 StringRef Blob) {
433 EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob, None);
434 }
435 template
436 void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals,
434 EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None);
435 }
436 template
437 void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
437438 const char *BlobData, unsigned BlobLen) {
438 return EmitRecordWithAbbrevImpl(Abbrev, Vals, StringRef(BlobData, BlobLen),
439 None);
439 return EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals),
440 StringRef(BlobData, BlobLen), None);
440441 }
441442
442443 /// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records
443444 /// that end with an array.
444 template
445 void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals,
446 StringRef Array) {
447 EmitRecordWithAbbrevImpl(Abbrev, Vals, Array, None);
448 }
449 template
450 void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals,
451 const char *ArrayData, unsigned ArrayLen) {
452 return EmitRecordWithAbbrevImpl(Abbrev, Vals,
445 template
446 void EmitRecordWithArray(unsigned Abbrev, const Container &Vals,
447 StringRef Array) {
448 EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Array, None);
449 }
450 template
451 void EmitRecordWithArray(unsigned Abbrev, const Container &Vals,
452 const char *ArrayData, unsigned ArrayLen) {
453 return EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals),
453454 StringRef(ArrayData, ArrayLen), None);
454455 }
455456