[PATCH] D18787: [Coverage] Prevent false instantiations detection in case of macro expansions.

David Li via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 9 12:53:52 PDT 2016


davidxl added a comment.

Can you also add the motivation case as one of the test case under tests/tools/llvm-cov ?

Otherwise looks good.


================
Comment at: llvm/trunk/lib/ProfileData/CoverageMapping.cpp:369
@@ -368,18 +368,3 @@
 
-static Optional<unsigned> findMainViewFileID(StringRef SourceFile,
-                                             const FunctionRecord &Function) {
-  SmallBitVector IsNotExpandedFile(Function.Filenames.size(), true);
-  SmallBitVector FilenameEquivalence = gatherFileIDs(SourceFile, Function);
-  for (const auto &CR : Function.CountedRegions)
-    if (CR.Kind == CounterMappingRegion::ExpansionRegion &&
-        FilenameEquivalence[CR.FileID])
-      IsNotExpandedFile[CR.ExpandedFileID] = false;
-  IsNotExpandedFile &= FilenameEquivalence;
-  int I = IsNotExpandedFile.find_first();
-  if (I == -1)
-    return None;
-  return I;
-}
-
 static Optional<unsigned> findMainViewFileID(const FunctionRecord &Function) {
   SmallBitVector IsNotExpandedFile(Function.Filenames.size(), true);
----------------
while you are at it, please add a brief comment for this method.

================
Comment at: llvm/trunk/lib/ProfileData/CoverageMapping.cpp:375
@@ -374,3 @@
-    if (CR.Kind == CounterMappingRegion::ExpansionRegion &&
-        FilenameEquivalence[CR.FileID])
-      IsNotExpandedFile[CR.ExpandedFileID] = false;
----------------
Another fix is to check

&& FilenameEquivalence[CR.ExpandedFileID])
    ...


but I think your refactored code looks better.

================
Comment at: llvm/trunk/lib/ProfileData/CoverageMapping.cpp:380
@@ -394,1 +379,3 @@
 
+static Optional<unsigned> findMainViewFileID(StringRef SourceFile,
+                                             const FunctionRecord &Function) {
----------------
Add a comment for the function.


http://reviews.llvm.org/D18787





More information about the llvm-commits mailing list