2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
|
2009-05-17 05:02:39 +08:00
|
|
|
namespace foo {
|
|
|
|
|
2014-02-18 07:34:47 +08:00
|
|
|
// CHECK-NOT: @a = global
|
2009-05-17 05:02:39 +08:00
|
|
|
extern "C" int a;
|
|
|
|
|
2014-02-18 07:34:47 +08:00
|
|
|
// CHECK-NOT: @_ZN3foo1bE = global
|
2009-05-17 05:02:39 +08:00
|
|
|
extern int b;
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @_ZN3foo1cE = {{(dso_local )?}}global
|
2009-05-17 05:02:39 +08:00
|
|
|
int c = 5;
|
|
|
|
|
2013-03-12 23:06:22 +08:00
|
|
|
// CHECK-NOT: @_ZN3foo1dE
|
2010-02-07 16:38:28 +08:00
|
|
|
extern "C" struct d;
|
|
|
|
|
2014-02-19 02:35:57 +08:00
|
|
|
// CHECK-NOT: should_not_appear
|
|
|
|
extern "C++" int should_not_appear;
|
2014-02-18 07:34:47 +08:00
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @_ZN3foo10extern_cxxE = {{(dso_local )?}}global
|
2016-04-29 09:23:20 +08:00
|
|
|
extern "C++" int extern_cxx = 0;
|
|
|
|
|
2009-05-17 05:02:39 +08:00
|
|
|
}
|
2013-03-12 23:06:22 +08:00
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-NOT: @global_a = {{(dso_local )?}}global
|
2016-04-29 09:23:20 +08:00
|
|
|
extern "C" int global_a;
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @global_b = {{(dso_local )?}}global
|
2016-04-29 09:23:20 +08:00
|
|
|
extern "C" int global_b = 0;
|
|
|
|
|
|
|
|
// CHECK-NOT: should_not_appear
|
|
|
|
extern "C++" int should_not_appear;
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @extern_cxx = {{(dso_local )?}}global
|
2016-04-29 09:23:20 +08:00
|
|
|
extern "C++" int extern_cxx = 0;
|
|
|
|
|
2013-03-12 23:06:22 +08:00
|
|
|
namespace test1 {
|
|
|
|
namespace {
|
|
|
|
struct X {};
|
|
|
|
}
|
|
|
|
extern "C" {
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @test1_b = {{(dso_local )?}}global
|
2013-03-12 23:22:39 +08:00
|
|
|
X test1_b = X();
|
2013-03-12 23:06:22 +08:00
|
|
|
}
|
2013-03-12 23:22:39 +08:00
|
|
|
void *use = &test1_b;
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @_ZN5test13useE = {{(dso_local )?}}global
|
2013-03-12 23:06:22 +08:00
|
|
|
}
|
2013-03-12 23:22:39 +08:00
|
|
|
|
|
|
|
namespace test2 {
|
|
|
|
namespace {
|
|
|
|
struct X {};
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK: @test2_b = {{(dso_local )?}}global
|
2013-03-12 23:22:39 +08:00
|
|
|
extern "C" X test2_b;
|
|
|
|
X test2_b;
|
|
|
|
}
|
2013-04-06 13:00:46 +08:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
static int unused_var;
|
|
|
|
static int unused_fn() { return 0; }
|
|
|
|
|
|
|
|
__attribute__((used)) static int internal_var;
|
|
|
|
__attribute__((used)) static int internal_fn() { return 0; }
|
|
|
|
|
|
|
|
__attribute__((used)) static int duplicate_internal_var;
|
|
|
|
__attribute__((used)) static int duplicate_internal_fn() { return 0; }
|
|
|
|
|
|
|
|
namespace N {
|
|
|
|
__attribute__((used)) static int duplicate_internal_var;
|
|
|
|
__attribute__((used)) static int duplicate_internal_fn() { return 0; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @llvm.used = appending global {{.*}} @internal_var {{.*}} @internal_fn
|
|
|
|
|
|
|
|
// CHECK-NOT: @unused
|
|
|
|
// CHECK-NOT: @duplicate_internal
|
2016-04-29 09:23:20 +08:00
|
|
|
// CHECK: @internal_var = internal alias i32, i32* @_ZL12internal_var
|
2013-04-06 13:00:46 +08:00
|
|
|
// CHECK-NOT: @unused
|
|
|
|
// CHECK-NOT: @duplicate_internal
|
2016-04-29 09:23:20 +08:00
|
|
|
// CHECK: @internal_fn = internal alias i32 (), i32 ()* @_ZL11internal_fnv
|
2013-04-06 13:00:46 +08:00
|
|
|
// CHECK-NOT: @unused
|
|
|
|
// CHECK-NOT: @duplicate_internal
|
|
|
|
}
|
2014-04-15 04:23:58 +08:00
|
|
|
|
|
|
|
namespace PR19411 {
|
|
|
|
struct A { void f(); };
|
|
|
|
extern "C" void A::f() { void g(); g(); }
|
|
|
|
// CHECK-LABEL: @_ZN7PR194111A1fEv(
|
2015-06-30 01:29:50 +08:00
|
|
|
// CHECK: call {{.*}}void @g()
|
2014-04-15 04:23:58 +08:00
|
|
|
}
|