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;
|
|
|
|
|
2014-02-18 07:34:47 +08:00
|
|
|
// CHECK: @_ZN3foo1cE = 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
|
|
|
|
2009-05-17 05:02:39 +08:00
|
|
|
}
|
2013-03-12 23:06:22 +08:00
|
|
|
|
|
|
|
namespace test1 {
|
|
|
|
namespace {
|
|
|
|
struct X {};
|
|
|
|
}
|
|
|
|
extern "C" {
|
2013-03-12 23:22:39 +08:00
|
|
|
// CHECK: @test1_b = global
|
|
|
|
X test1_b = X();
|
2013-03-12 23:06:22 +08:00
|
|
|
}
|
2013-03-12 23:22:39 +08:00
|
|
|
void *use = &test1_b;
|
2013-03-12 23:06:22 +08:00
|
|
|
// CHECK: @_ZN5test13useE = global
|
|
|
|
}
|
2013-03-12 23:22:39 +08:00
|
|
|
|
|
|
|
namespace test2 {
|
|
|
|
namespace {
|
|
|
|
struct X {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @test2_b = global
|
|
|
|
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
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECK: @internal_var = internal alias i32, i32* @_Z12internal_var
|
2013-04-06 13:00:46 +08:00
|
|
|
// CHECK-NOT: @unused
|
|
|
|
// CHECK-NOT: @duplicate_internal
|
2015-09-11 11:22:18 +08:00
|
|
|
// CHECK: @internal_fn = internal alias i32 (), i32 ()* @_Z11internal_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
|
|
|
}
|