xref: /minix3/external/bsd/llvm/dist/clang/test/CoverageMapping/trycatch.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trycatch.cpp %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc class Error {
4*0a6a1f1dSLionel Sambuc };
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc class ImportantError {
7*0a6a1f1dSLionel Sambuc };
8*0a6a1f1dSLionel Sambuc 
9*0a6a1f1dSLionel Sambuc class Warning {
10*0a6a1f1dSLionel Sambuc };
11*0a6a1f1dSLionel Sambuc 
12*0a6a1f1dSLionel Sambuc                                       // CHECK: func
func(int i)13*0a6a1f1dSLionel Sambuc void func(int i) {                    // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+5]]:2 = #0 (HasCodeBefore = 0)
14*0a6a1f1dSLionel Sambuc   if(i % 2)
15*0a6a1f1dSLionel Sambuc     throw Error();                    // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:16 = #1 (HasCodeBefore = 0)
16*0a6a1f1dSLionel Sambuc   else if(i == 8)                     // CHECK-NEXT: File 0, [[@LINE]]:8 -> [[@LINE]]:17 = (#0 - #1) (HasCodeBefore = 0)
17*0a6a1f1dSLionel Sambuc     throw ImportantError();           // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:25 = #2 (HasCodeBefore = 0)
18*0a6a1f1dSLionel Sambuc }
19*0a6a1f1dSLionel Sambuc 
20*0a6a1f1dSLionel Sambuc                                       // CHECK-NEXT: main
main()21*0a6a1f1dSLionel Sambuc int main() {                          // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+13]]:2 = #0 (HasCodeBefore = 0)
22*0a6a1f1dSLionel Sambuc   int j = 0;
23*0a6a1f1dSLionel Sambuc   try {
24*0a6a1f1dSLionel Sambuc     func(j);
25*0a6a1f1dSLionel Sambuc   } catch(const Error &e) {           // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:10 = #2 (HasCodeBefore = 0)
26*0a6a1f1dSLionel Sambuc     j = 1;
27*0a6a1f1dSLionel Sambuc   } catch(const ImportantError &e) {  // CHECK-NEXT: File 0, [[@LINE]]:36 -> [[@LINE+3]]:8 = #3 (HasCodeBefore = 0)
28*0a6a1f1dSLionel Sambuc     j = 11;
29*0a6a1f1dSLionel Sambuc   }
30*0a6a1f1dSLionel Sambuc   catch(const Warning &w) {           // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:4 = #4 (HasCodeBefore = 0)
31*0a6a1f1dSLionel Sambuc     j = 0;
32*0a6a1f1dSLionel Sambuc   }
33*0a6a1f1dSLionel Sambuc   return 0;                           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = #1 (HasCodeBefore = 0)
34*0a6a1f1dSLionel Sambuc }
35