Files
swift-mirror/test/Profiler/coverage_exceptions.swift
Vedant Kumar c3f4d99e57 Group the the code coverage, profiling, and pgo tests together (#16070)
* Group tests for profiling instrumentation together, NFC

This will make it easier to test changes to the code coverage logic.

There are a handful of tests which relate to profiling which I have not
moved. These include tests for the driver and for the SIL optimizer. It
makes more sense to keep those tests where they are.

* Rename a test file, NFC

This file tests code coverage of primary files, so I've changed the name
of the file to reflect that.

* Simplify the check lines in a test, NFC

This file tests code coverage of closures. It had several check lines
which obscured the meaning of the test, and its check lines were in a
strange order.

Remove the extra checks and disable -emit-sorted-sil.
2018-04-20 15:15:52 -07:00

65 lines
1.5 KiB
Swift

// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_catch %s | %FileCheck %s
enum SomeErr : Error {
case Err1
case Err2
}
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.bar
func bar() throws {
// CHECK-NEXT: [[@LINE-1]]:19 -> [[@LINE+2]]:2 : 0
throw SomeErr.Err2
} // CHECK-NEXT: }
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.baz
func baz(_ fn: () throws -> ()) rethrows {
do {
try fn()
} catch SomeErr.Err1 { // CHECK: [[@LINE]]:24 -> {{[0-9]+}}:4 : 2
return
} // CHECK-NEXT: [[@LINE]]:4 -> {{[0-9]+}}:2 : 1
try fn()
} // CHECK-NEXT: }
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.foo
func foo() -> Int32 {
var x : Int32 = 0
do {
throw SomeErr.Err1
x += 2 // [[@LINE]]:5 -> [[@LINE+1]]:4 : zero
} catch SomeErr.Err1 {
// CHECK: [[@LINE-1]]:24 -> [[@LINE+1]]:4 : 2
} catch _ {
// CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 3
} // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 1
do {
try baz(bar)
} catch _ {
// CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 5
} // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 4
do {
try baz { () throws -> () in throw SomeErr.Err1 }
} catch _ {}
try! baz { () throws -> () in return }
return x
}
foo()
struct S {
// CHECK: sil_coverage_map {{.*}}// __ntd_S_line:[[@LINE-1]]
init() {
do {
throw SomeErr.Err1
} catch {
// CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:6 : 2
} // CHECK: [[@LINE]]:6 -> [[@LINE+1]]:4 : 1
}
}