InstrProf: Simplify RawCoverageMappingReader's API slightly
authorJustin Bogner <mail@justinbogner.com>
Tue, 3 Feb 2015 00:20:11 +0000 (00:20 +0000)
committerJustin Bogner <mail@justinbogner.com>
Tue, 3 Feb 2015 00:20:11 +0000 (00:20 +0000)
This is still kind of a weird API, but dropping the (partial) update
of the passed in CoverageMappingRecord makes it a little easier to
understand and use.

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

include/llvm/ProfileData/CoverageMappingReader.h
lib/ProfileData/CoverageMappingReader.cpp

index 5a6b44b8d9ef88c9a0329b538af434d0ae320e19..b4a57cc3864630b60e110e19164bb686445f9c46 100644 (file)
@@ -104,7 +104,6 @@ public:
 
 /// \brief Reader for the raw coverage mapping data.
 class RawCoverageMappingReader : public RawCoverageReader {
-  StringRef FunctionName;
   ArrayRef<StringRef> TranslationUnitFilenames;
   std::vector<StringRef> &Filenames;
   std::vector<CounterExpression> &Expressions;
@@ -116,17 +115,17 @@ class RawCoverageMappingReader : public RawCoverageReader {
   operator=(const RawCoverageMappingReader &) LLVM_DELETED_FUNCTION;
 
 public:
-  RawCoverageMappingReader(StringRef FunctionName, StringRef MappingData,
+  RawCoverageMappingReader(StringRef MappingData,
                            ArrayRef<StringRef> TranslationUnitFilenames,
                            std::vector<StringRef> &Filenames,
                            std::vector<CounterExpression> &Expressions,
                            std::vector<CounterMappingRegion> &MappingRegions)
-      : RawCoverageReader(MappingData), FunctionName(FunctionName),
+      : RawCoverageReader(MappingData),
         TranslationUnitFilenames(TranslationUnitFilenames),
         Filenames(Filenames), Expressions(Expressions),
         MappingRegions(MappingRegions) {}
 
-  std::error_code read(CoverageMappingRecord &Record);
+  std::error_code read();
 
 private:
   std::error_code decodeCounter(unsigned Value, Counter &C);
index 1ab2acb2f93612366fc60d5a482d08a4d995b5ea..71ce22aec9e579e29a1aef2b2a933fa9c84f452f 100644 (file)
@@ -221,7 +221,7 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray(
   return success();
 }
 
-std::error_code RawCoverageMappingReader::read(CoverageMappingRecord &Record) {
+std::error_code RawCoverageMappingReader::read() {
 
   // Read the virtual file mapping.
   llvm::SmallVector<unsigned, 8> VirtualFileMapping;
@@ -287,10 +287,6 @@ std::error_code RawCoverageMappingReader::read(CoverageMappingRecord &Record) {
     }
   }
 
-  Record.FunctionName = FunctionName;
-  Record.Filenames = Filenames;
-  Record.Expressions = Expressions;
-  Record.MappingRegions = MappingRegions;
   return success();
 }
 
@@ -542,12 +538,18 @@ ObjectFileCoverageMappingReader::readNextRecord(CoverageMappingRecord &Record) {
   MappingRegions.clear();
   auto &R = MappingRecords[CurrentRecord];
   RawCoverageMappingReader Reader(
-      R.FunctionName, R.CoverageMapping,
+      R.CoverageMapping,
       makeArrayRef(Filenames).slice(R.FilenamesBegin, R.FilenamesSize),
       FunctionsFilenames, Expressions, MappingRegions);
-  if (auto Err = Reader.read(Record))
+  if (auto Err = Reader.read())
     return Err;
+
+  Record.FunctionName = R.FunctionName;
   Record.FunctionHash = R.FunctionHash;
+  Record.Filenames = FunctionsFilenames;
+  Record.Expressions = Expressions;
+  Record.MappingRegions = MappingRegions;
+
   ++CurrentRecord;
   return success();
 }