[ARM] Handle +t2dsp feature as an ArchExtKind in ARMTargetParser.def
[oota-llvm.git] / tools / llvm-cov / CoverageSummaryInfo.h
index 710108d1a5d32d97c933c7170115d7390a06176a..c393b00d32a43ee157b5d6e2bb7f296931a6de2f 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef LLVM_COV_COVERAGESUMMARYINFO_H
 #define LLVM_COV_COVERAGESUMMARYINFO_H
 
-#include "FunctionCoverageMapping.h"
+#include "llvm/ProfileData/CoverageMapping.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace llvm {
@@ -31,10 +31,19 @@ struct RegionCoverageInfo {
   /// \brief The total number of regions in a function/file.
   size_t NumRegions;
 
+  RegionCoverageInfo() : Covered(0), NotCovered(0), NumRegions(0) {}
+
   RegionCoverageInfo(size_t Covered, size_t NumRegions)
       : Covered(Covered), NotCovered(NumRegions - Covered),
         NumRegions(NumRegions) {}
 
+  RegionCoverageInfo &operator+=(const RegionCoverageInfo &RHS) {
+    Covered += RHS.Covered;
+    NotCovered += RHS.NotCovered;
+    NumRegions += RHS.NumRegions;
+    return *this;
+  }
+
   bool isFullyCovered() const { return Covered == NumRegions; }
 
   double getPercentCovered() const {
@@ -56,10 +65,21 @@ struct LineCoverageInfo {
   /// \brief The total number of lines in a function/file.
   size_t NumLines;
 
+  LineCoverageInfo()
+      : Covered(0), NotCovered(0), NonCodeLines(0), NumLines(0) {}
+
   LineCoverageInfo(size_t Covered, size_t NumNonCodeLines, size_t NumLines)
       : Covered(Covered), NotCovered(NumLines - NumNonCodeLines - Covered),
         NonCodeLines(NumNonCodeLines), NumLines(NumLines) {}
 
+  LineCoverageInfo &operator+=(const LineCoverageInfo &RHS) {
+    Covered += RHS.Covered;
+    NotCovered += RHS.NotCovered;
+    NonCodeLines += RHS.NonCodeLines;
+    NumLines += RHS.NumLines;
+    return *this;
+  }
+
   bool isFullyCovered() const { return Covered == (NumLines - NonCodeLines); }
 
   double getPercentCovered() const {
@@ -69,38 +89,50 @@ struct LineCoverageInfo {
 
 /// \brief Provides information about function coverage for a file.
 struct FunctionCoverageInfo {
-  /// \brief The number of functions that have full
-  /// region coverage.
-  size_t FullyCovered;
+  /// \brief The number of functions that were executed.
+  size_t Executed;
 
   /// \brief The total number of functions in this file.
   size_t NumFunctions;
 
-  FunctionCoverageInfo(size_t FullyCovered, size_t NumFunctions)
-      : FullyCovered(FullyCovered), NumFunctions(NumFunctions) {}
+  FunctionCoverageInfo() : Executed(0), NumFunctions(0) {}
 
-  bool isFullyCovered() const { return FullyCovered == NumFunctions; }
+  FunctionCoverageInfo(size_t Executed, size_t NumFunctions)
+      : Executed(Executed), NumFunctions(NumFunctions) {}
+
+  void addFunction(bool Covered) {
+    if (Covered)
+      ++Executed;
+    ++NumFunctions;
+  }
+
+  bool isFullyCovered() const { return Executed == NumFunctions; }
 
   double getPercentCovered() const {
-    return double(FullyCovered) / double(NumFunctions) * 100.0;
+    return double(Executed) / double(NumFunctions) * 100.0;
   }
 };
 
 /// \brief A summary of function's code coverage.
 struct FunctionCoverageSummary {
   StringRef Name;
+  uint64_t ExecutionCount;
   RegionCoverageInfo RegionCoverage;
   LineCoverageInfo LineCoverage;
 
-  FunctionCoverageSummary(StringRef Name,
+  FunctionCoverageSummary(StringRef Name) : Name(Name), ExecutionCount(0) {}
+
+  FunctionCoverageSummary(StringRef Name, uint64_t ExecutionCount,
                           const RegionCoverageInfo &RegionCoverage,
                           const LineCoverageInfo &LineCoverage)
-      : Name(Name), RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) {
+      : Name(Name), ExecutionCount(ExecutionCount),
+        RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) {
   }
 
   /// \brief Compute the code coverage summary for the given function coverage
   /// mapping record.
-  static FunctionCoverageSummary get(const FunctionCoverageMapping &Function);
+  static FunctionCoverageSummary
+  get(const coverage::FunctionRecord &Function);
 };
 
 /// \brief A summary of file's code coverage.
@@ -109,21 +141,14 @@ struct FileCoverageSummary {
   RegionCoverageInfo RegionCoverage;
   LineCoverageInfo LineCoverage;
   FunctionCoverageInfo FunctionCoverage;
-  /// \brief The summary of every function
-  /// in this file.
-  ArrayRef<FunctionCoverageSummary> FunctionSummaries;
-
-  FileCoverageSummary(StringRef Name, const RegionCoverageInfo &RegionCoverage,
-                      const LineCoverageInfo &LineCoverage,
-                      const FunctionCoverageInfo &FunctionCoverage,
-                      ArrayRef<FunctionCoverageSummary> FunctionSummaries)
-      : Name(Name), RegionCoverage(RegionCoverage), LineCoverage(LineCoverage),
-        FunctionCoverage(FunctionCoverage),
-        FunctionSummaries(FunctionSummaries) {}
-
-  /// \brief Compute the code coverage summary for a file.
-  static FileCoverageSummary
-  get(StringRef Name, ArrayRef<FunctionCoverageSummary> FunctionSummaries);
+
+  FileCoverageSummary(StringRef Name) : Name(Name) {}
+
+  void addFunction(const FunctionCoverageSummary &Function) {
+    RegionCoverage += Function.RegionCoverage;
+    LineCoverage += Function.LineCoverage;
+    FunctionCoverage.addFunction(/*Covered=*/Function.ExecutionCount > 0);
+  }
 };
 
 } // namespace llvm