[llvm] r227900 - InstrProf: Simplify RawCoverageMappingReader's API slightly

Justin Bogner mail at justinbogner.com
Mon Feb 2 16:20:11 PST 2015


Author: bogner
Date: Mon Feb  2 18:20:11 2015
New Revision: 227900

URL: http://llvm.org/viewvc/llvm-project?rev=227900&view=rev
Log:
InstrProf: Simplify RawCoverageMappingReader's API slightly

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.

Modified:
    llvm/trunk/include/llvm/ProfileData/CoverageMappingReader.h
    llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp

Modified: llvm/trunk/include/llvm/ProfileData/CoverageMappingReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/CoverageMappingReader.h?rev=227900&r1=227899&r2=227900&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/CoverageMappingReader.h (original)
+++ llvm/trunk/include/llvm/ProfileData/CoverageMappingReader.h Mon Feb  2 18:20:11 2015
@@ -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
   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);

Modified: llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp?rev=227900&r1=227899&r2=227900&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp Mon Feb  2 18:20:11 2015
@@ -221,7 +221,7 @@ std::error_code RawCoverageMappingReader
   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
     }
   }
 
-  Record.FunctionName = FunctionName;
-  Record.Filenames = Filenames;
-  Record.Expressions = Expressions;
-  Record.MappingRegions = MappingRegions;
   return success();
 }
 
@@ -542,12 +538,18 @@ ObjectFileCoverageMappingReader::readNex
   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();
 }





More information about the llvm-commits mailing list