[llvm-commits] [llvm] r79904 - /llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h

Daniel Dunbar daniel at zuster.org
Mon Aug 24 02:29:31 PDT 2009


Author: ddunbar
Date: Mon Aug 24 04:29:31 2009
New Revision: 79904

URL: http://llvm.org/viewvc/llvm-project?rev=79904&view=rev
Log:
Add StringRef based APIs to BitstreamWriter.

Modified:
    llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h

Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=79904&r1=79903&r2=79904&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon Aug 24 04:29:31 2009
@@ -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 @@
   /// 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 @@
   /// 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 @@
   /// 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));
   }
   
   //===--------------------------------------------------------------------===//





More information about the llvm-commits mailing list