[llvm] e698079 - Allow `CoverageMapping::getCoverageForFile()` to show Branches also outside functions (#120416)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 15:41:31 PST 2024


Author: NAKAMURA Takumi
Date: 2024-12-19T08:41:28+09:00
New Revision: e6980796585940bffd8c9e95052761c1a32c1dfe

URL: https://github.com/llvm/llvm-project/commit/e6980796585940bffd8c9e95052761c1a32c1dfe
DIFF: https://github.com/llvm/llvm-project/commit/e6980796585940bffd8c9e95052761c1a32c1dfe.diff

LOG: Allow `CoverageMapping::getCoverageForFile()` to show Branches also outside functions (#120416)

Fixes #119952

Added: 
    

Modified: 
    llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
    llvm/test/tools/llvm-cov/branch-macros.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 119e09187b9080..d51448567539f2 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -1412,7 +1412,7 @@ CoverageData CoverageMapping::getCoverageForFile(StringRef Filename) const {
       }
     // Capture branch regions specific to the function (excluding expansions).
     for (const auto &CR : Function.CountedBranchRegions)
-      if (FileIDs.test(CR.FileID) && (CR.FileID == CR.ExpandedFileID))
+      if (FileIDs.test(CR.FileID))
         FileCoverage.BranchRegions.push_back(CR);
     // Capture MCDC records specific to the function.
     for (const auto &MR : Function.MCDCRecords)

diff  --git a/llvm/test/tools/llvm-cov/branch-macros.cpp b/llvm/test/tools/llvm-cov/branch-macros.cpp
index 73042ac397d406..7f3d1e8bffb82a 100644
--- a/llvm/test/tools/llvm-cov/branch-macros.cpp
+++ b/llvm/test/tools/llvm-cov/branch-macros.cpp
@@ -5,7 +5,7 @@
 #define COND1 (a == b)
 #define COND2 (a != b)
 #define COND3 (COND1 && COND2)
-#define COND4 (COND3 ? COND2 : COND1)
+#define COND4 (COND3 ? COND2 : COND1) // CHECK: | Branch ([[@LINE]]:15): [True: 1, False: 2]
 #define MACRO1 COND3
 #define MACRO2 MACRO1
 #define MACRO3 MACRO2


        


More information about the llvm-commits mailing list