[llvm] [llvm-cov] Fix branch counts of template functions (#111743) (PR #113925)

Alan Phipps via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 15:45:17 PST 2024


================
@@ -75,70 +90,120 @@ void renderLineExecutionCounts(raw_ostream &OS,
   }
 }
 
-std::vector<llvm::coverage::CountedRegion>
+std::vector<NestedCountedRegion>
 collectNestedBranches(const coverage::CoverageMapping &Coverage,
                       ArrayRef<llvm::coverage::ExpansionRecord> Expansions,
-                      int ViewDepth = 0, int SrcLine = 0) {
-  std::vector<llvm::coverage::CountedRegion> Branches;
+                      std::vector<LineColPair> &NestedPath) {
+  std::vector<NestedCountedRegion> Branches;
   for (const auto &Expansion : Expansions) {
     auto ExpansionCoverage = Coverage.getCoverageForExpansion(Expansion);
 
-    // If we're at the top level, set the corresponding source line.
-    if (ViewDepth == 0)
-      SrcLine = Expansion.Region.LineStart;
+    // Track the path to the nested expansions
+    NestedPath.push_back(Expansion.Region.startLoc());
----------------
evodius96 wrote:

Much better than tracking LineStart. Thanks!

https://github.com/llvm/llvm-project/pull/113925


More information about the llvm-commits mailing list