summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/conditional-temporaries.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-02-04 17:06:52 +0000
committerAnders Carlsson <andersca@mac.com>2010-02-04 17:06:52 +0000
commit5bb0ddd10b07ecc0df43f0d5f50f0b9f10046426 (patch)
tree4cd47a73dac4e94b834a3c9d05af9f3ef9940779 /test/CodeGenCXX/conditional-temporaries.cpp
parente8a81f7e8e26275d91c073bf908a7d6d246106c5 (diff)
Improve test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/conditional-temporaries.cpp')
-rw-r--r--test/CodeGenCXX/conditional-temporaries.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/test/CodeGenCXX/conditional-temporaries.cpp b/test/CodeGenCXX/conditional-temporaries.cpp
index 0eac10b43c..e9e684ea5a 100644
--- a/test/CodeGenCXX/conditional-temporaries.cpp
+++ b/test/CodeGenCXX/conditional-temporaries.cpp
@@ -1,28 +1,36 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
-struct I {
+namespace {
+
+static int counter;
+
+struct A {
+ A() : i(0) { counter++; }
+ ~A() { counter--; }
int i;
- I();
- ~I();
};
-void g(int);
+void g(int) { }
-volatile int i;
+void f1(bool b) {
+ g(b ? A().i : 0);
+ g(b || A().i);
+ g(b && A().i);
+}
-void f1() {
- // CHECK: call void @_ZN1IC1Ev
- g(i ? I().i : 0);
- // CHECK: call void @_Z1gi
- // CHECK: call void @_ZN1ID1Ev
+struct Checker {
+ Checker() {
+ f1(true);
+ f1(false);
+ }
+};
- // CHECK: call void @_ZN1IC1Ev
- g(i || I().i);
- // CHECK: call void @_Z1gi
- // CHECK: call void @_ZN1ID1Ev
+Checker c;
+
+}
- // CHECK: call void @_ZN1IC1Ev
- g(i && I().i);
- // CHECK: call void @_Z1gi
- // CHECK: call void @_ZN1ID1Ev
+// CHECK: define i32 @_Z10getCounterv()
+int getCounter() {
+ // CHECK: ret i32 0
+ return counter;
}