diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CodeGenCXX/cxx0x-initializer-references.cpp | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CodeGenCXX/cxx0x-initializer-references.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/cxx0x-initializer-references.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-references.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-references.cpp new file mode 100644 index 0000000..4c847b8 --- /dev/null +++ b/clang/test/CodeGenCXX/cxx0x-initializer-references.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s + +namespace reference { + struct A { + int i1, i2; + }; + + void single_init() { + // No superfluous instructions allowed here, they could be + // hiding extra temporaries. + + // CHECK: store i32 1, i32* + // CHECK-NEXT: store i32* %{{.*}}, i32** + const int &cri2a = 1; + + // CHECK-NEXT: store i32 1, i32* + // CHECK-NEXT: store i32* %{{.*}}, i32** + const int &cri1a = {1}; + + // CHECK-NEXT: store i32 1, i32* + int i = 1; + // CHECK-NEXT: store i32* %{{.*}}, i32** + int &ri1a = {i}; + + // CHECK-NEXT: bitcast + // CHECK-NEXT: memcpy + A a{1, 2}; + // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % + A &ra1a = {a}; + + // CHECK-NEXT: ret + } + + void reference_to_aggregate() { + // CHECK: getelementptr {{.*}}, i32 0, i32 0 + // CHECK-NEXT: store i32 1 + // CHECK-NEXT: getelementptr {{.*}}, i32 0, i32 1 + // CHECK-NEXT: store i32 2 + // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %{{.*}}, align + const A &ra1{1, 2}; + + // CHECK-NEXT: getelementptr inbounds [3 x i32]* %{{.*}}, i{{32|64}} 0, i{{32|64}} 0 + // CHECK-NEXT: store i32 1 + // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1 + // CHECK-NEXT: store i32 2 + // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1 + // CHECK-NEXT: store i32 3 + // CHECK-NEXT: store [3 x i32]* %{{.*}}, [3 x i32]** %{{.*}}, align + const int (&arrayRef)[] = {1, 2, 3}; + + // CHECK-NEXT: ret + } + + struct B { + B(); + ~B(); + }; + + void single_init_temp_cleanup() + { + // Ensure lifetime extension. + + // CHECK: call void @_ZN9reference1BC1Ev + // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % + const B &rb{ B() }; + // CHECK: call void @_ZN9reference1BD1Ev + } + +} |