From: Chris Lattner Date: Sun, 20 Jan 2013 01:06:48 +0000 (+0000) Subject: stringref'ize readRecord and properly capitalize it. Add a compatibility method... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=194ef24dfedf62642c853a851db4d7e528d27460;p=oota-llvm.git stringref'ize readRecord and properly capitalize it. Add a compatibility method to easy the transition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172940 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index d6d9e34868d..3e8d880da44 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -506,9 +506,20 @@ public: /// skipRecord - Read the current record and discard it. void skipRecord(unsigned AbbrevID); + unsigned readRecord(unsigned AbbrevID, SmallVectorImpl &Vals, + StringRef *Blob = 0); + unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl &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 &Vals, const char *&BlobStart, unsigned &BlobLen) { return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen); diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp index be70f5213bc..84d5ca6150c 100644 --- a/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/lib/Bitcode/Reader/BitstreamReader.cpp @@ -198,9 +198,9 @@ void BitstreamCursor::skipRecord(unsigned AbbrevID) { } } -unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID, +unsigned BitstreamCursor::readRecord(unsigned AbbrevID, SmallVectorImpl &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));