[llvm] r268428 - [ProfileData] Propagate an error from InstrProfSymtab

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 13:01:02 PDT 2016


Author: vedantk
Date: Tue May  3 15:01:01 2016
New Revision: 268428

URL: http://llvm.org/viewvc/llvm-project?rev=268428&view=rev
Log:
[ProfileData] Propagate an error from InstrProfSymtab

CovMapFuncReader::get should propagate up errors from InstrProfSymtab.

This is part of a series of patches to transition ProfileData over to
the stricter Error/Expected interface.

Modified:
    llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp

Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp?rev=268428&r1=268427&r2=268428&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp Tue May  3 15:01:01 2016
@@ -316,7 +316,7 @@ struct CovMapFuncRecordReader {
                                               const char *End) = 0;
   virtual ~CovMapFuncRecordReader() {}
   template <class IntPtrT, support::endianness Endian>
-  static std::unique_ptr<CovMapFuncRecordReader>
+  static ErrorOr<std::unique_ptr<CovMapFuncRecordReader>>
   get(coverage::CovMapVersion Version, InstrProfSymtab &P,
       std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
       std::vector<StringRef> &F);
@@ -417,7 +417,7 @@ public:
 } // end anonymous namespace
 
 template <class IntPtrT, support::endianness Endian>
-std::unique_ptr<CovMapFuncRecordReader> CovMapFuncRecordReader::get(
+ErrorOr<std::unique_ptr<CovMapFuncRecordReader>> CovMapFuncRecordReader::get(
     coverage::CovMapVersion Version, InstrProfSymtab &P,
     std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
     std::vector<StringRef> &F) {
@@ -428,7 +428,8 @@ std::unique_ptr<CovMapFuncRecordReader>
         CovMapVersion::Version1, IntPtrT, Endian>>(P, R, F);
   case CovMapVersion::Version2:
     // Decompress the name data.
-    P.create(P.getNameData());
+    if (auto EC = P.create(P.getNameData()))
+      return EC;
     return llvm::make_unique<VersionedCovMapFuncRecordReader<
         CovMapVersion::Version2, IntPtrT, Endian>>(P, R, F);
   }
@@ -447,9 +448,12 @@ static std::error_code readCoverageMappi
   CovMapVersion Version = (CovMapVersion)CovHeader->getVersion<Endian>();
   if (Version > coverage::CovMapVersion::CurrentVersion)
     return coveragemap_error::unsupported_version;
-  std::unique_ptr<CovMapFuncRecordReader> Reader =
+  ErrorOr<std::unique_ptr<CovMapFuncRecordReader>> ReaderErrorOr =
       CovMapFuncRecordReader::get<T, Endian>(Version, ProfileNames, Records,
                                              Filenames);
+  if (auto EC = ReaderErrorOr.getError())
+    return EC;
+  auto Reader = std::move(ReaderErrorOr.get());
   for (const char *Buf = Data.data(), *End = Buf + Data.size(); Buf < End;) {
     if (std::error_code EC = Reader->readFunctionRecords(Buf, End))
       return EC;




More information about the llvm-commits mailing list