[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / extern-c.cpp
blob829c661ca4c80d9b1af0b336bf757d141a068cac
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
2 namespace foo {
4 // CHECK-NOT: @a = global
5 extern "C" int a;
7 // CHECK-NOT: @_ZN3foo1bE = global
8 extern int b;
10 // CHECK: @_ZN3foo1cE = {{(dso_local )?}}global
11 int c = 5;
13 // CHECK-NOT: @_ZN3foo1dE
14 extern "C" struct d;
16 // CHECK-NOT: should_not_appear
17 extern "C++" int should_not_appear;
19 // CHECK: @_ZN3foo10extern_cxxE = {{(dso_local )?}}global
20 extern "C++" int extern_cxx = 0;
24 // CHECK-NOT: @global_a = {{(dso_local )?}}global
25 extern "C" int global_a;
27 // CHECK: @global_b = {{(dso_local )?}}global
28 extern "C" int global_b = 0;
30 // CHECK-NOT: should_not_appear
31 extern "C++" int should_not_appear;
33 // CHECK: @extern_cxx = {{(dso_local )?}}global
34 extern "C++" int extern_cxx = 0;
36 namespace test1 {
37 namespace {
38 struct X {};
40 extern "C" {
41 // CHECK: @test1_b = {{(dso_local )?}}global
42 X test1_b = X();
44 void *use = &test1_b;
45 // CHECK: @_ZN5test13useE = {{(dso_local )?}}global
48 namespace test2 {
49 namespace {
50 struct X {};
53 // CHECK: @test2_b = {{(dso_local )?}}global
54 extern "C" X test2_b;
55 X test2_b;
58 extern "C" {
59 static int unused_var;
60 static int unused_fn() { return 0; }
62 __attribute__((used)) static int internal_var;
63 __attribute__((used)) static int internal_fn() { return 0; }
65 __attribute__((used)) static int duplicate_internal_var;
66 __attribute__((used)) static int duplicate_internal_fn() { return 0; }
68 namespace N {
69 __attribute__((used)) static int duplicate_internal_var;
70 __attribute__((used)) static int duplicate_internal_fn() { return 0; }
73 // CHECK: @llvm.compiler.used = appending global {{.*}} @internal_var, {{.*}} @internal_fn
75 // CHECK-NOT: @unused
76 // CHECK-NOT: @duplicate_internal
77 // CHECK: @internal_var = internal alias i32, ptr @_ZL12internal_var
78 // CHECK-NOT: @unused
79 // CHECK-NOT: @duplicate_internal
80 // CHECK: @internal_fn = internal alias i32 (), ptr @_ZL11internal_fnv
81 // CHECK-NOT: @unused
82 // CHECK-NOT: @duplicate_internal
85 namespace PR19411 {
86 struct A { void f(); };
87 extern "C" void A::f() { void g(); g(); }
88 // CHECK-LABEL: @_ZN7PR194111A1fEv(
89 // CHECK: call {{.*}}void @g()