llvm.org GIT mirror llvm / 0282a55
Revert "[Coverage] Clarify ownership of a MemoryBuffer in the reader (NFC)" This reverts commit 1037ef2574adde2103ad221d63834c3e1df4a776. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274105 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 4 years ago
3 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
180180
181181 public:
182182 static Expected>
183 create(MemoryBuffer &ObjectBuffer, StringRef Arch);
183 create(std::unique_ptr &ObjectBuffer,
184 StringRef Arch);
184185
185186 Error readNextRecord(CoverageMappingRecord &Record) override;
186187 };
235235 Expected>
236236 CoverageMapping::load(StringRef ObjectFilename, StringRef ProfileFilename,
237237 StringRef Arch) {
238 auto CounterMappingBufOrErr = MemoryBuffer::getFileOrSTDIN(ObjectFilename);
239 if (std::error_code EC = CounterMappingBufOrErr.getError())
238 auto CounterMappingBuff = MemoryBuffer::getFileOrSTDIN(ObjectFilename);
239 if (std::error_code EC = CounterMappingBuff.getError())
240240 return errorCodeToError(EC);
241 std::unique_ptr ObjectBuffer =
242 std::move(CounterMappingBufOrErr.get());
243241 auto CoverageReaderOrErr =
244 BinaryCoverageReader::create(*ObjectBuffer.get(), Arch);
242 BinaryCoverageReader::create(CounterMappingBuff.get(), Arch);
245243 if (Error E = CoverageReaderOrErr.takeError())
246244 return std::move(E);
247245 auto CoverageReader = std::move(CoverageReaderOrErr.get());
640640 }
641641
642642 Expected>
643 BinaryCoverageReader::create(MemoryBuffer &ObjectBuffer, StringRef Arch) {
643 BinaryCoverageReader::create(std::unique_ptr &ObjectBuffer,
644 StringRef Arch) {
644645 std::unique_ptr Reader(new BinaryCoverageReader());
645646
646647 StringRef Coverage;
648649 support::endianness Endian;
649650 Error E;
650651 consumeError(std::move(E));
651 if (ObjectBuffer.getBuffer().startswith(TestingFormatMagic))
652 if (ObjectBuffer->getBuffer().startswith(TestingFormatMagic))
652653 // This is a special format used for testing.
653 E = loadTestingFormat(ObjectBuffer.getBuffer(), Reader->ProfileNames,
654 E = loadTestingFormat(ObjectBuffer->getBuffer(), Reader->ProfileNames,
654655 Coverage, BytesInAddress, Endian);
655656 else
656 E = loadBinaryFormat(ObjectBuffer.getMemBufferRef(), Reader->ProfileNames,
657 E = loadBinaryFormat(ObjectBuffer->getMemBufferRef(), Reader->ProfileNames,
657658 Coverage, BytesInAddress, Endian, Arch);
658659 if (E)
659660 return std::move(E);