forked from OSchip/llvm-project
36 lines
1.5 KiB
C++
36 lines
1.5 KiB
C++
// 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
|
|
|
|
class Error {
|
|
};
|
|
|
|
class ImportantError {
|
|
};
|
|
|
|
class Warning {
|
|
};
|
|
|
|
// CHECK: func
|
|
void func(int i) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+6]]:2 = #0
|
|
if(i % 2) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:11 = #0
|
|
throw Error(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:18 = #1
|
|
// CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+2]]:27 = (#0 - #1)
|
|
else if(i == 8) // CHECK-NEXT: File 0, [[@LINE]]:11 -> [[@LINE]]:17 = (#0 - #1)
|
|
throw ImportantError(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:27 = #2
|
|
}
|
|
|
|
// CHECK-NEXT: main
|
|
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+13]]:2 = #0
|
|
int j = 0;
|
|
try {
|
|
func(j);
|
|
} catch(const Error &e) { // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:4 = #2
|
|
j = 1;
|
|
} catch(const ImportantError &e) { // CHECK-NEXT: File 0, [[@LINE]]:36 -> [[@LINE+2]]:4 = #3
|
|
j = 11;
|
|
}
|
|
catch(const Warning &w) { // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:4 = #4
|
|
j = 0;
|
|
}
|
|
return 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = #1
|
|
}
|