summaryrefslogtreecommitdiff
path: root/clang/test/CodeGenCXX/builtins-eh-wasm.cpp
blob: b3a6ffc92e11b9353bc91e6463e376518316468c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// REQUIRES: webassembly-registered-target
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fexceptions -fcxx-exceptions -target-feature +reference-types -target-feature +exception-handling -target-feature +multivalue -mllvm -wasm-enable-eh -exception-model=wasm -emit-llvm -o - %s | FileCheck %s

// Check if __builtin_wasm_throw and __builtin_wasm_rethrow are correctly
// invoked when placed in try-catch.

void throw_in_try(void *obj) {
  try {
    __builtin_wasm_throw(0, obj);
  } catch (...) {
  }
  // CHECK: invoke void @llvm.wasm.throw(i32 0, ptr %{{.*}})
}

void rethrow_in_try() {
  try {
  __builtin_wasm_rethrow();
  } catch (...) {
  }
  // CHECK: invoke void @llvm.wasm.rethrow()
}