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

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 02:35:16 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());
----------------
stma247 wrote:

Yes, it's required to avoid unifying different expanded branches of the same root line.

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


More information about the llvm-commits mailing list