1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s 2 3 namespace { 4 5 static int ctorcalls; 6 static int dtorcalls; 7 8 struct A { A__anon589531880111::A9 A() : i(0) { ctorcalls++; } ~A__anon589531880111::A10 ~A() { dtorcalls++; } 11 int i; 12 operator <<(const A & a,int n)13 friend const A& operator<<(const A& a, int n) { 14 return a; 15 } 16 }; 17 g(int)18void g(int) { } g(const A &)19void g(const A&) { } 20 f1(bool b)21void f1(bool b) { 22 g(b ? A().i : 0); 23 g(b || A().i); 24 g(b && A().i); 25 g(b ? A() << 1 : A() << 2); 26 } 27 28 struct Checker { Checker__anon589531880111::Checker29 Checker() { 30 f1(true); 31 f1(false); 32 } 33 }; 34 35 Checker c; 36 37 } 38 39 // CHECK-LABEL: define i32 @_Z12getCtorCallsv() getCtorCalls()40int getCtorCalls() { 41 // CHECK: ret i32 5 42 return ctorcalls; 43 } 44 45 // CHECK-LABEL: define i32 @_Z12getDtorCallsv() getDtorCalls()46int getDtorCalls() { 47 // CHECK: ret i32 5 48 return dtorcalls; 49 } 50 51 // CHECK-LABEL: define zeroext i1 @_Z7successv() success()52bool success() { 53 // CHECK: ret i1 true 54 return ctorcalls == dtorcalls; 55 } 56