stringref'ize readRecord and properly capitalize it. Add a compatibility method...
authorChris Lattner <sabre@nondot.org>
Sun, 20 Jan 2013 01:06:48 +0000 (01:06 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 20 Jan 2013 01:06:48 +0000 (01:06 +0000)
the transition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172940 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Bitcode/BitstreamReader.h
lib/Bitcode/Reader/BitstreamReader.cpp

index d6d9e34868d6232e034831e758e53c0d103a8bc7..3e8d880da4431d000950f8603e5f5454c9a83a61 100644 (file)
@@ -506,9 +506,20 @@ public:
   /// skipRecord - Read the current record and discard it.
   void skipRecord(unsigned AbbrevID);
   
+  unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
+                      StringRef *Blob = 0);
+
   unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
-                      const char **BlobStart = 0, unsigned *BlobLen = 0);
-  
+                      const char **BlobStart = 0, unsigned *BlobLen = 0) {
+    if (!BlobStart)
+      return readRecord(AbbrevID, Vals);
+    StringRef S;
+    unsigned X = readRecord(AbbrevID, Vals, &S);
+    *BlobStart = S.data();
+    *BlobLen = S.size();
+    return X;
+  }
+
   unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
                       const char *&BlobStart, unsigned &BlobLen) {
     return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen);
index be70f5213bc844af0acc8db9a84963053aefa4b5..84d5ca6150caf8ec2406446dbc4d57bd7d210aa2 100644 (file)
@@ -198,9 +198,9 @@ void BitstreamCursor::skipRecord(unsigned AbbrevID) {
   }
 }
 
-unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,
+unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
                                      SmallVectorImpl<uint64_t> &Vals,
-                                     const char **BlobStart, unsigned *BlobLen){
+                                     StringRef *Blob) {
   if (AbbrevID == bitc::UNABBREV_RECORD) {
     unsigned Code = ReadVBR(6);
     unsigned NumElts = ReadVBR(6);
@@ -256,10 +256,11 @@ unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,
     
     // Otherwise, read the number of bytes.  If we can return a reference to
     // the data, do so to avoid copying it.
-    if (BlobStart) {
-      *BlobStart = (const char*)BitStream->getBitcodeBytes().getPointer(
-                                                            NextChar, NumElts);
-      *BlobLen = NumElts;
+    if (Blob) {
+      *Blob =
+        StringRef((const char*)BitStream->getBitcodeBytes().getPointer(
+                                                            NextChar, NumElts),
+                NumElts);
     } else {
       for (; NumElts; ++NextChar, --NumElts)
         Vals.push_back(getByte(NextChar));