r236547 - InstrProf: Don't start or end coverage regions inside of system macros

Justin Bogner mail at justinbogner.com
Tue May 5 14:46:15 PDT 2015


Author: bogner
Date: Tue May  5 16:46:14 2015
New Revision: 236547

URL: http://llvm.org/viewvc/llvm-project?rev=236547&view=rev
Log:
InstrProf: Don't start or end coverage regions inside of system macros

It doesn't make much sense to try to show coverage inside system
macros, and source locations in builtins confuses the coverage
mapping. Just avoid doing this.

Fixes an assert that fired when a __block storage specifier starts a
region.

Added:
    cfe/trunk/test/CoverageMapping/block-storage-starts-region.m
Modified:
    cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=236547&r1=236546&r2=236547&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Tue May  5 16:46:14 2015
@@ -134,18 +134,18 @@ public:
                            : SM.getIncludeLoc(SM.getFileID(Loc));
   }
 
-  /// \brief Get the start of \c S ignoring macro argument locations.
+  /// \brief Get the start of \c S ignoring macro arguments and system macros.
   SourceLocation getStart(const Stmt *S) {
     SourceLocation Loc = S->getLocStart();
-    while (SM.isMacroArgExpansion(Loc))
+    while (SM.isMacroArgExpansion(Loc) || SM.isInSystemMacro(Loc))
       Loc = SM.getImmediateExpansionRange(Loc).first;
     return Loc;
   }
 
-  /// \brief Get the end of \c S ignoring macro argument locations.
+  /// \brief Get the end of \c S ignoring macro arguments and system macros.
   SourceLocation getEnd(const Stmt *S) {
     SourceLocation Loc = S->getLocEnd();
-    while (SM.isMacroArgExpansion(Loc))
+    while (SM.isMacroArgExpansion(Loc) || SM.isInSystemMacro(Loc))
       Loc = SM.getImmediateExpansionRange(Loc).first;
     return getPreciseTokenLocEnd(Loc);
   }

Added: cfe/trunk/test/CoverageMapping/block-storage-starts-region.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/block-storage-starts-region.m?rev=236547&view=auto
==============================================================================
--- cfe/trunk/test/CoverageMapping/block-storage-starts-region.m (added)
+++ cfe/trunk/test/CoverageMapping/block-storage-starts-region.m Tue May  5 16:46:14 2015
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
+
+ at interface Foo
+ at end
+
+// CHECK-LABEL: doSomething:
+void doSomething() { // CHECK: File 0, [[@LINE]]:20 -> {{[0-9:]+}} = #0
+  return;
+  __block Foo *f; // CHECK: File 0, [[@LINE]]:3 -> {{[0-9:]+}} = 0
+}
+
+int main() {}





More information about the cfe-commits mailing list