[llvm] [llvm-dwarfdump][LineCov 3/3] Add IR analysis for variable coverage (PR #195342)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 1 04:30:46 PDT 2026


================
@@ -132,11 +135,28 @@ computeVariableCoverage(DWARFDie VariableDIE,
   else if (ParentLines)
     set_intersect(*Lines, *ParentLines);
 
-  if (!Lines)
-    return {};
+  auto ResultLines =
+      convertFileIndices(Lines.value_or(DenseSet<SourceLocation>()), LineTable,
+                         FileIndexMap, FileNameMap);
+
+  if (DefinedLines) {
+    // Remove any lines where the variable does not have a defined value.
+    auto &DL = DefinedLines->second;
+    if (DL) {
+      DenseSet<SourceLocation> IndexLines;
+      for (const auto &L : *DL) {
+        auto NameIt = FileNameMap.find(L.first);
+        if (NameIt != FileNameMap.end())
+          IndexLines.insert({NameIt->second, L.second});
+      }
+      if (!Lines)
+        ResultLines = std::move(IndexLines);
----------------
unexpectedlydefined wrote:

I was unable to find any when testing this on a large codebase and have replaced it with an assertion.

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


More information about the llvm-commits mailing list