MCPcopy Create free account
hub / github.com/GANGE666/xVMP / initStream

Function initStream

src/lib/Bitcode/Reader/BitcodeReader.cpp:123–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123static Expected<BitstreamCursor> initStream(MemoryBufferRef Buffer) {
124 const unsigned char *BufPtr = (const unsigned char *)Buffer.getBufferStart();
125 const unsigned char *BufEnd = BufPtr + Buffer.getBufferSize();
126
127 if (Buffer.getBufferSize() & 3)
128 return error("Invalid bitcode signature");
129
130 // If we have a wrapper header, parse it and ignore the non-bc file contents.
131 // The magic number is 0x0B17C0DE stored in little endian.
132 if (isBitcodeWrapper(BufPtr, BufEnd))
133 if (SkipBitcodeWrapperHeader(BufPtr, BufEnd, true))
134 return error("Invalid bitcode wrapper header");
135
136 BitstreamCursor Stream(ArrayRef<uint8_t>(BufPtr, BufEnd));
137 if (!hasValidBitcodeHeader(Stream))
138 return error("Invalid bitcode signature");
139
140 return std::move(Stream);
141}
142
143/// Convert a string from a record into an std::string, return true on failure.
144template <typename StrTy>

Calls 7

isBitcodeWrapperFunction · 0.85
SkipBitcodeWrapperHeaderFunction · 0.85
hasValidBitcodeHeaderFunction · 0.85
errorFunction · 0.70
moveFunction · 0.50
getBufferStartMethod · 0.45
getBufferSizeMethod · 0.45

Tested by

no test coverage detected