blob: d39249214dc5ab2923e3aca547d7d757e89c3464 [file] [log] [blame]
Frederich Munch529ce722018-03-14 16:04:45 +00001//===-- examples/clang-interpreter/Test.cxx - Clang C Interpreter Example -===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// Example throwing in and from the JIT (particularly on Win64).
11//
12// ./bin/clang-interpreter <src>/tools/clang/examples/clang-interpreter/Test.cxx
13
14#include <stdexcept>
15#include <stdio.h>
16
17static void ThrowerAnError(const char* Name) {
18 throw std::runtime_error(Name);
19}
20
21int main(int argc, const char** argv) {
22 for (int I = 0; I < argc; ++I)
23 printf("arg[%d]='%s'\n", I, argv[I]);
Michael Platings49af7482018-11-19 12:16:05 +000024
Frederich Munch529ce722018-03-14 16:04:45 +000025 try {
26 ThrowerAnError("In JIT");
27 } catch (const std::exception& E) {
28 printf("Caught: '%s'\n", E.what());
29 } catch (...) {
30 printf("Unknown exception\n");
31 }
32 ThrowerAnError("From JIT");
33 return 0;
34}