<commit_before>// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend %S/swift-functions-errors.swift -typecheck -module-name Functions -clang-header-expose-public-decls -emit-clang-header-path %t/functions.h

// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-functions-errors-execution.o
// RUN: %target-interop-build-swift %S/swift-functions-errors.swift -o %t/swift-functions-errors-execution -Xlinker %t/swift-functions-errors-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain

// RUN: %target-codesign %t/swift-functions-errors-execution
// RUN: %target-run %t/swift-functions-errors-execution | %FileCheck %s

// REQUIRES: executable_test

#include <cassert>
#include <iostream>
#include "functions.h"

int main() {
  static_assert(!noexcept(Functions::emptyThrowFunction()), "noexcept function");
  static_assert(!noexcept(Functions::throwFunction()), "noexcept function");
  static_assert(!noexcept(Functions::throwFunctionWithReturn()), "noexcept function");

  try {
    Functions::emptyThrowFunction();
  } catch (swift::_impl::NaiveException& e) {
    std::cout << e.getMessage() << "\n";
  }
  try {
    Functions::throwFunction();
  } catch (swift::_impl::NaiveException& e) {
    std::cout << e.getMessage() << "\n";
  }
  try {
    Functions::throwFunctionWithReturn();
  } catch (swift::_impl::NaiveException& e) {
    std::cout << e.getMessage() << "\n";
  }

  return 0;
}

// CHECK: passEmptyThrowFunction
// CHECK-NEXT: passThrowFunction
// CHECK-NEXT: Exception
// CHECK-NEXT: passThrowFunctionWithReturn
// CHECK-NEXT: Exception<commit_msg>Replacing `iostream` by `cstdio` and `cout` by `printf`<commit_after>// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend %S/swift-functions-errors.swift -typecheck -module-name Functions -clang-header-expose-public-decls -emit-clang-header-path %t/functions.h

// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-functions-errors-execution.o
// RUN: %target-interop-build-swift %S/swift-functions-errors.swift -o %t/swift-functions-errors-execution -Xlinker %t/swift-functions-errors-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain

// RUN: %target-codesign %t/swift-functions-errors-execution
// RUN: %target-run %t/swift-functions-errors-execution | %FileCheck %s

// REQUIRES: executable_test

#include <cassert>
#include <cstdio>
#include "functions.h"

int main() {
  static_assert(!noexcept(Functions::emptyThrowFunction()), "noexcept function");
  static_assert(!noexcept(Functions::throwFunction()), "noexcept function");
  static_assert(!noexcept(Functions::throwFunctionWithReturn()), "noexcept function");

  try {
    Functions::emptyThrowFunction();
  } catch (swift::_impl::NaiveException& e) {
    printf("%s\n", e.getMessage());
  }
  try {
    Functions::throwFunction();
  } catch (swift::_impl::NaiveException& e) {
    printf("%s\n", e.getMessage());
  }
  try {
    Functions::throwFunctionWithReturn();
  } catch (swift::_impl::NaiveException& e) {
    printf("%s\n", e.getMessage());
  }

  return 0;
}

// CHECK: passEmptyThrowFunction
// CHECK-NEXT: passThrowFunction
// CHECK-NEXT: Exception
// CHECK-NEXT: passThrowFunctionWithReturn
// CHECK-NEXT: Exception
{'fraction_non_alphanumeric': 0.16793893129770993, 'fraction_numerical': 0.0006106870229007634, 'mean_word_length': 4.677642980935875, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3752101', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1058, 'n_words': 195}