File: goto.cpp

package info (click to toggle)
llvm-toolchain-6.0 1%3A6.0.1-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 598,080 kB
  • sloc: cpp: 3,046,253; ansic: 595,057; asm: 271,965; python: 128,926; objc: 106,554; sh: 21,906; lisp: 10,191; pascal: 6,094; ml: 5,544; perl: 5,265; makefile: 2,227; cs: 2,027; xml: 686; php: 212; csh: 117
file content (46 lines) | stat: -rw-r--r-- 1,873 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fcxx-exceptions -fexceptions -emit-llvm -std=c++98 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fcxx-exceptions -fexceptions -emit-llvm -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s

// Reduced from a crash on boost::interprocess's node_allocator_test.cpp.
namespace test0 {
  struct A { A(); ~A(); };
  struct V { V(const A &a = A()); ~V(); };

  // CHECK-LABEL: define linkonce_odr i32 @_ZN5test04testILi0EEEii
  template<int X> int test(int x) {
    // CHECK:      [[RET:%.*]] = alloca i32
    // CHECK-NEXT: [[X:%.*]] = alloca i32
    // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]],
    // CHECK-NEXT: [[Z:%.*]] = alloca [[A]]
    // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
    // CHECK-NEXT: [[SEL:%.*]] = alloca i32
    // CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*,
    // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]
    // CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
    // CHECK:      call void @_ZN5test01AC1Ev([[A]]* [[Y]])
    // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]])
    // CHECK:      [[NEW:%.*]] = invoke i8* @_Znwm(i64 1)
    // CHECK:      store i1 true, i1* [[CLEANUPACTIVE]]
    // CHECK:      [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
    // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
    // CHECK:      invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* dereferenceable({{[0-9]+}}) [[TMP]])
    // CHECK:      store i1 false, i1* [[CLEANUPACTIVE]]

    // CHECK98-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[TMP]])
    // CHECK11-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[TMP]])
    A y;
    try {
      A z;
      V *v = new V();

      if (x) return 1;
    } catch (int ex) {
      return 1;
    }
    return 0;
  }

  int test() {
    return test<0>(5);
  }
}