[PATCH] D18758: [Coverage] Support for making test data for more than one function.

David Li via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 9 15:02:07 PDT 2016


davidxl added inline comments.

================
Comment at: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp:56
@@ -55,14 +55,3 @@
   std::vector<StringRef> Filenames;
-  ArrayRef<CounterMappingRegion> Regions;
-  bool Done;
-
-  OneFunctionCoverageReader(StringRef Name, uint64_t Hash,
-                            ArrayRef<StringRef> Filenames,
-                            ArrayRef<CounterMappingRegion> Regions)
-      : Name(Name), Hash(Hash), Filenames(Filenames), Regions(Regions),
-        Done(false) {}
-
-  std::error_code readNextRecord(CoverageMappingRecord &Record) override {
-    if (Done)
-      return instrprof_error::eof;
-    Done = true;
+  std::vector<CounterExpression> Expressions;
+  std::vector<CounterMappingRegion> Regions;
----------------
Is this field needed? It can be a local variable.

================
Comment at: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp:174
@@ -142,11 +173,3 @@
 
-  void loadCoverageMapping(StringRef FuncName, uint64_t Hash,
-                           bool EmitFilenames = true) {
-    std::string Regions = writeCoverageRegions();
-    readCoverageRegions(Regions);
-
-    SmallVector<StringRef, 8> Filenames;
-    if (EmitFilenames) {
-      Filenames.resize(Files.size());
-      for (const auto &E : Files)
-        Filenames[E.getValue()] = E.getKey();
+  void loadCoverageMapping(bool EmitFilenames = true) {
+    OutputFunctions.resize(InputFunctions.size());
----------------
Split this function into two methods:

1) writeAndReadCoverageRegions
2) loadCoverageMapping

loadCoverageMapping calls 1) followed by  call to CoverageMapping::load

Calls to readProfCount can also be folded into 2).

Function 1) can be called in many other places as well.


http://reviews.llvm.org/D18758





More information about the llvm-commits mailing list