blob: 32e17a35ff2ddb21570219ae2052d1955c55ef4b [file] [log] [blame]
Anders Carlssonabea9512011-02-28 00:40:07 +00001// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t
John McCall3cdfc4d2010-08-13 08:35:10 +00002// RUN: FileCheck %s -check-prefix=1 < %t
3// RUN: FileCheck %s -check-prefix=2 < %t
John McCall9aeed322009-10-01 00:25:31 +00004
Anders Carlssond0c47922010-01-26 06:15:16 +00005int f();
6
John McCall9aeed322009-10-01 00:25:31 +00007namespace {
John McCall3cdfc4d2010-08-13 08:35:10 +00008 // 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 McCall9aeed322009-10-01 00:25:31 +000012 int a = 0;
13
Anders Carlssond0c47922010-01-26 06:15:16 +000014 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 Gregorf4aac112010-05-06 22:18:21 +000024 // Check for generation of a VTT with internal linkage
John McCall3cdfc4d2010-08-13 08:35:10 +000025 // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
Douglas Gregorf4aac112010-05-06 22:18:21 +000026 struct X {
27 struct EBase { };
28 struct E : public virtual EBase { virtual ~E() {} };
29 };
30
John McCall3cdfc4d2010-08-13 08:35:10 +000031 // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_13fooEv()
John McCall9aeed322009-10-01 00:25:31 +000032 int foo() {
33 return 32;
34 }
35
John McCall3cdfc4d2010-08-13 08:35:10 +000036 // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv()
John McCall9aeed322009-10-01 00:25:31 +000037 namespace A {
38 int foo() {
39 return 45;
40 }
41 }
42}
43
44int concrete() {
45 return a + foo() + A::foo();
46}
Douglas Gregorf4aac112010-05-06 22:18:21 +000047
48void test_XE() { throw X::E(); }
John McCall3cdfc4d2010-08-13 08:35:10 +000049
50// Miscompile on llvmc plugins.
51namespace 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}