Anders Carlsson | abea951 | 2011-02-28 00:40:07 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t |
John McCall | 3cdfc4d | 2010-08-13 08:35:10 +0000 | [diff] [blame] | 2 | // RUN: FileCheck %s -check-prefix=1 < %t |
| 3 | // RUN: FileCheck %s -check-prefix=2 < %t |
John McCall | 9aeed32 | 2009-10-01 00:25:31 +0000 | [diff] [blame] | 4 | |
Anders Carlsson | d0c4792 | 2010-01-26 06:15:16 +0000 | [diff] [blame] | 5 | int f(); |
| 6 | |
John McCall | 9aeed32 | 2009-10-01 00:25:31 +0000 | [diff] [blame] | 7 | namespace { |
John McCall | 3cdfc4d | 2010-08-13 08:35:10 +0000 | [diff] [blame] | 8 | // CHECK-1: @_ZN12_GLOBAL__N_11bE = internal global i32 0 |
| 9 | // CHECK-1: @_ZN12_GLOBAL__N_1L1cE = internal global i32 0 |
| 10 | // CHECK-1: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0 |
| 11 | // CHECK-1: @_ZN12_GLOBAL__N_11aE = internal global i32 0 |
John McCall | 9aeed32 | 2009-10-01 00:25:31 +0000 | [diff] [blame] | 12 | int a = 0; |
| 13 | |
Anders Carlsson | d0c4792 | 2010-01-26 06:15:16 +0000 | [diff] [blame] | 14 | int b = f(); |
| 15 | |
| 16 | static int c = f(); |
| 17 | |
| 18 | class D { |
| 19 | static int d; |
| 20 | }; |
| 21 | |
| 22 | int D::d = f(); |
| 23 | |
Douglas Gregor | f4aac11 | 2010-05-06 22:18:21 +0000 | [diff] [blame] | 24 | // Check for generation of a VTT with internal linkage |
John McCall | 3cdfc4d | 2010-08-13 08:35:10 +0000 | [diff] [blame] | 25 | // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant |
Douglas Gregor | f4aac11 | 2010-05-06 22:18:21 +0000 | [diff] [blame] | 26 | struct X { |
| 27 | struct EBase { }; |
| 28 | struct E : public virtual EBase { virtual ~E() {} }; |
| 29 | }; |
| 30 | |
John McCall | 3cdfc4d | 2010-08-13 08:35:10 +0000 | [diff] [blame] | 31 | // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_13fooEv() |
John McCall | 9aeed32 | 2009-10-01 00:25:31 +0000 | [diff] [blame] | 32 | int foo() { |
| 33 | return 32; |
| 34 | } |
| 35 | |
John McCall | 3cdfc4d | 2010-08-13 08:35:10 +0000 | [diff] [blame] | 36 | // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv() |
John McCall | 9aeed32 | 2009-10-01 00:25:31 +0000 | [diff] [blame] | 37 | namespace A { |
| 38 | int foo() { |
| 39 | return 45; |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | int concrete() { |
| 45 | return a + foo() + A::foo(); |
| 46 | } |
Douglas Gregor | f4aac11 | 2010-05-06 22:18:21 +0000 | [diff] [blame] | 47 | |
| 48 | void test_XE() { throw X::E(); } |
John McCall | 3cdfc4d | 2010-08-13 08:35:10 +0000 | [diff] [blame] | 49 | |
| 50 | // Miscompile on llvmc plugins. |
| 51 | namespace test2 { |
| 52 | struct A { |
| 53 | template <class T> struct B { |
| 54 | static void foo() {} |
| 55 | }; |
| 56 | }; |
| 57 | namespace { |
| 58 | struct C; |
| 59 | } |
| 60 | |
| 61 | // CHECK-2: define void @_ZN5test24testEv() |
| 62 | // CHECK-2: call void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() |
| 63 | void test() { |
| 64 | A::B<C>::foo(); |
| 65 | } |
| 66 | |
| 67 | // CHECK-2: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() |
| 68 | } |