85 lines · cpp
1// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t2// RUN: FileCheck %s -check-prefix=CHECK-1 < %t3// RUN: FileCheck %s -check-prefix=CHECK-2 < %t4 5int f();6 7namespace {8 // CHECK-1: @_ZN12_GLOBAL__N_11bE = internal global i32 09 // CHECK-1: @_ZN12_GLOBAL__N_11cE = internal global i32 010 // CHECK-1: @_ZN12_GLOBAL__N_12c2E = internal global i32 011 // CHECK-1: @_ZN12_GLOBAL__N_11D1dE = internal global i32 012 // CHECK-1: @_ZN12_GLOBAL__N_11aE = internal global i32 013 int a = 0;14 15 int b = f();16 17 static int c = f();18 19 // Note, we can't use an 'L' mangling for c or c2 (like GCC does) based on20 // the 'static' specifier, because the variable can be redeclared without it.21 extern int c2;22 int g() { return c2; }23 static int c2 = f();24 25 class D {26 static int d;27 };28 29 int D::d = f();30 31 // Check for generation of a VTT with internal linkage32 // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant33 struct X { 34 struct EBase { };35 struct E : public virtual EBase { virtual ~E() {} };36 };37 38 // CHECK-1-LABEL: define internal noundef i32 @_ZN12_GLOBAL__N_13fooEv()39 int foo() {40 return 32;41 }42 43 // CHECK-1-LABEL: define internal noundef i32 @_ZN12_GLOBAL__N_11A3fooEv()44 namespace A {45 int foo() {46 return 45;47 }48 }49}50 51int concrete() {52 return a + foo() + A::foo();53}54 55void test_XE() { throw X::E(); }56 57// Miscompile on llvmc plugins.58namespace test2 {59 struct A {60 template <class T> struct B {61 static void foo() {}62 };63 };64 namespace {65 struct C;66 }67 68 // CHECK-2-LABEL: define{{.*}} void @_ZN5test24testEv()69 // CHECK-2: call void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv()70 void test() {71 A::B<C>::foo();72 }73 74 // CHECK-2-LABEL: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv()75}76 77namespace {78 79int bar() {80 extern int a;81 return a;82}83 84} // namespace85