Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -emit-llvm -o - %s | FileCheck %s
      2 
      3 __attribute__((internal_linkage)) void f() {}
      4 // CHECK-DAG: define internal void @_ZL1fv
      5 
      6 class A {
      7 public:
      8   static int y __attribute__((internal_linkage));
      9   static int y2 [[clang::internal_linkage]];
     10 // CHECK-DAG: @_ZN1A1yE = internal global
     11 // CHECK-DAG: @_ZN1A2y2E = internal global
     12   void f1() __attribute__((internal_linkage));
     13 // CHECK-DAG: define internal void @_ZN1A2f1Ev
     14   void f2() __attribute__((internal_linkage)) {}
     15 // CHECK-DAG: define internal void @_ZN1A2f2Ev
     16   static void f4() __attribute__((internal_linkage)) {}
     17 // CHECK-DAG: define internal void @_ZN1A2f4Ev
     18   A() __attribute__((internal_linkage)) {}
     19 // CHECK-DAG: define internal void @_ZN1AC1Ev
     20 // CHECK-DAG: define internal void @_ZN1AC2Ev
     21   ~A() __attribute__((internal_linkage)) {}
     22 // CHECK-DAG: define internal void @_ZN1AD1Ev
     23 // CHECK-DAG: define internal void @_ZN1AD2Ev
     24 };
     25 
     26 int A::y;
     27 int A::y2;
     28 
     29 void A::f1() {
     30 }
     31 
     32 // Forward declaration w/o an attribute.
     33 class B;
     34 
     35 // Internal_linkage on a class affects all its members.
     36 class __attribute__((internal_linkage)) B {
     37 public:
     38   B() {}
     39   // CHECK-DAG: define internal void @_ZNL1BC1Ev
     40   // CHECK-DAG: define internal void @_ZNL1BC2Ev
     41   ~B() {}
     42   // CHECK-DAG: define internal void @_ZNL1BD1Ev
     43   // CHECK-DAG: define internal void @_ZNL1BD2Ev
     44   void f() {};
     45   // CHECK-DAG: define internal void @_ZNL1B1fEv
     46   static int x;
     47   // CHECK-DAG: @_ZNL1B1xE = internal global
     48 };
     49 
     50 int B::x;
     51 
     52 // Forward declaration with the attribute.
     53 class __attribute__((internal_linkage)) C;
     54 class C {
     55 public:
     56   static int x;
     57   // CHECK-DAG: @_ZNL1C1xE = internal global
     58 };
     59 
     60 int C::x;
     61 
     62 __attribute__((internal_linkage)) void g();
     63 void g() {}
     64 // CHECK-DAG: define internal void @_ZL1gv()
     65 
     66 void use() {
     67   A a;
     68   a.f1();
     69   a.f2();
     70   A::f4();
     71   f();
     72   int &Y = A::y;
     73   int &Y2 = A::y2;
     74   B b;
     75   b.f();
     76   int &XX2 = B::x;
     77   g();
     78   int &XX3 = C::x;
     79 }
     80