r275121 - [Coverage] Do not map regions from system headers

Vedant Kumar via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 11 15:57:47 PDT 2016


Author: vedantk
Date: Mon Jul 11 17:57:46 2016
New Revision: 275121

URL: http://llvm.org/viewvc/llvm-project?rev=275121&view=rev
Log:
[Coverage] Do not map regions from system headers

Do not assign source regions located within system headers file ID's,
and do not construct counter mapping regions out of them.

This makes coverage reports less cluttered and less mysterious. E.g
using the "assert" macro doesn't cause assert.h to appear in reports,
and it no longer shows the "assertion failed" branch as an uncovered
region.

It also makes coverage mapping sections a bit smaller (e.g a 1%
reduction in a stage2 build of bin/llvm-as).

Modified:
    cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
    cfe/trunk/test/CoverageMapping/system_macro.c

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=275121&r1=275120&r2=275121&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Jul 11 17:57:46 2016
@@ -172,6 +172,10 @@ public:
       if (!Visited.insert(File).second)
         continue;
 
+      // Do not map FileID's associated with system headers.
+      if (SM.isInSystemHeader(SM.getSpellingLoc(Loc)))
+        continue;
+
       unsigned Depth = 0;
       for (SourceLocation Parent = getIncludeOrExpansionLoc(Loc);
            Parent.isValid(); Parent = getIncludeOrExpansionLoc(Parent))
@@ -251,6 +255,10 @@ public:
       SourceLocation LocStart = Region.getStartLoc();
       assert(SM.getFileID(LocStart).isValid() && "region in invalid file");
 
+      // Ignore regions from system headers.
+      if (SM.isInSystemHeader(SM.getSpellingLoc(LocStart)))
+        continue;
+
       auto CovFileID = getCoverageFileID(LocStart);
       // Ignore regions that don't have a file, such as builtin macros.
       if (!CovFileID)

Modified: cfe/trunk/test/CoverageMapping/system_macro.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/system_macro.c?rev=275121&r1=275120&r2=275121&view=diff
==============================================================================
--- cfe/trunk/test/CoverageMapping/system_macro.c (original)
+++ cfe/trunk/test/CoverageMapping/system_macro.c Mon Jul 11 17:57:46 2016
@@ -13,9 +13,8 @@
 
 // CHECK-LABEL: doSomething:
 void doSomething(int x) { // CHECK: File 0, [[@LINE]]:25 -> {{[0-9:]+}} = #0
-  Func(x); // CHECK: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:7
+  Func(x);
   return;
-  // CHECK: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:11
   SomeType *f; // CHECK: File 0, [[@LINE]]:11 -> {{[0-9:]+}} = 0
 }
 




More information about the cfe-commits mailing list