[Coverage] Discard deferred region in closing if-else
A trailing deferred region isn't necessary in a function that ends with
this pattern:
...
else {
...
return;
}
Special-case this pattern so that the closing curly brace of the
function isn't marked as uncovered. This issue came up in PR34962.
llvm-svn: 315982
diff --git a/clang/test/CoverageMapping/deferred-region.cpp b/clang/test/CoverageMapping/deferred-region.cpp
index 743b635..3504588 100644
--- a/clang/test/CoverageMapping/deferred-region.cpp
+++ b/clang/test/CoverageMapping/deferred-region.cpp
@@ -31,11 +31,28 @@
// CHECK-LABEL: _Z3mazv:
void maz() {
if (true)
- return; // CHECK: Gap,File 0, [[@LINE]]:11 -> 36:3 = (#0 - #1)
+ return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+2]]:3 = (#0 - #1)
return; // CHECK-NOT: Gap
}
+// CHECK-LABEL: _Z4maazv:
+void maaz() {
+ if (true)
+ return; // CHECK: Gap,File 0, [[@LINE]]:11
+ else
+ return; // CHECK-NOT: Gap,File 0, [[@LINE]]
+}
+
+// CHECK-LABEL: _Z5maaazv:
+void maaaz() {
+ if (true) {
+ return;
+ } else { // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE]]:10
+ return; // CHECK-NOT: Gap,File 0, [[@LINE]]
+ }
+}
+
// CHECK-LABEL: _Z3bari:
void bar(int x) {
IF (x)
@@ -158,6 +175,9 @@
foo(1);
fooo(0);
fooo(1);
+ maz();
+ maaz();
+ maaaz();
baz();
bar(0);
bar(1);