From 9b52880c1132c770205d2cb702c67d6477f253fd Mon Sep 17 00:00:00 2001
From: Alex Lorenz <arphaman@gmail.com>
Date: Tue, 19 Aug 2014 12:36:54 -0700
Subject: [PATCH 1/2] Coverage mapping: no mapping for implicit cast expr

---
 lib/CodeGen/CoverageMappingGen.cpp | 4 ++++
 test/CoverageMapping/casts.c       | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp
index 86e2be8..974627a 100644
--- a/lib/CodeGen/CoverageMappingGen.cpp
+++ b/lib/CodeGen/CoverageMappingGen.cpp
@@ -1021,6 +1021,10 @@ struct CounterCoverageMappingBuilder
     Visit(E->getSubExpr());
   }
 
+  void VisitImplicitCastExpr(const ImplicitCastExpr *E) {
+    Visit(E->getSubExpr());
+  }
+
   // Map literals as tokens so that the macros like #define PI 3.14
   // won't generate coverage mapping regions.
 
diff --git a/test/CoverageMapping/casts.c b/test/CoverageMapping/casts.c
index 94c13dc..fcb923f 100644
--- a/test/CoverageMapping/casts.c
+++ b/test/CoverageMapping/casts.c
@@ -2,10 +2,17 @@
 
 int main() {                                                   // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
                                                                // CHECK-NEXT: File 0, [[@LINE+1]]:41 -> [[@LINE+1]]:54 = #1 (HasCodeBefore = 0)
-  int window_size = (sizeof(int) <= 2 ? (unsigned)512 : 1024); // CHECK-NEXT: File 0, [[@LINE]]:57 -> [[@LINE]]:61 = (#0 - #1) (HasCodeBefore = 0)
+  int window_size = (sizeof(int) <= 2 ? (unsigned)512 : 1024);
   return 0;
 }
 
+#define N 32
 
+              // CHECK: foo
+void foo() {  // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+  char c = N;
+  if (0) {    // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+1]]:4 = #1 (HasCodeBefore = 0)
+  }
+}
 
 
-- 
1.9.3 (Apple Git-50)

