1//===-- examples/clang-interpreter/Test.cxx - Clang C Interpreter Example -===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Example throwing in and from the JIT (particularly on Win64).
10//
11// ./bin/clang-interpreter <src>/tools/clang/examples/clang-interpreter/Test.cxx
12
13#include <stdexcept>
14#include <stdio.h>
15
16static void ThrowerAnError(const char* Name) {
17  throw std::runtime_error(Name);
18}
19
20int main(int argc, const char** argv) {
21  for (int I = 0; I < argc; ++I)
22   printf("arg[%d]='%s'\n", I, argv[I]);
23
24  try {
25    ThrowerAnError("In JIT");
26  } catch (const std::exception& E) {
27    printf("Caught: '%s'\n", E.what());
28  } catch (...) {
29    printf("Unknown exception\n");
30  }
31  ThrowerAnError("From JIT");
32  return 0;
33}
34