brintos

brintos / llvm-project-archived public Read only

0
0
Text · 722 B · de81adf Raw
40 lines · cpp
1// Test that we can have a statement that throws in hot cold2// and a landing pad in cold code.3//4// Record performance data with no args. Run test with 2 args.5 6#include <stdint.h>7#include <stdio.h>8 9int foo() { return 0; }10 11void bar(int a) {12  if (a > 2 && a % 2)13    throw new int();14}15 16void filter_only() { foo(); }17 18int main(int argc, char **argv) {19  unsigned r = 0;20 21  uint64_t limit = (argc >= 2 ? 10 : 5000);22  for (uint64_t i = 0; i < limit; ++i) {23    i += foo();24    try {25      bar(argc);26      try {27        if (argc >= 2)28          throw new int();29      } catch (...) {30        printf("catch 2\n");31        throw new int();32      }33    } catch (...) {34      printf("catch 1\n");35    }36  }37 38  return 0;39}40