[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / anonymous-namespaces.cpp
blobf40039c2a4f40066a1da307ef59dfb2861943831
1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t
2 // RUN: FileCheck %s -check-prefix=CHECK-1 < %t
3 // RUN: FileCheck %s -check-prefix=CHECK-2 < %t
5 int f();
7 namespace {
8 // CHECK-1: @_ZN12_GLOBAL__N_11bE = internal global i32 0
9 // CHECK-1: @_ZN12_GLOBAL__N_11cE = internal global i32 0
10 // CHECK-1: @_ZN12_GLOBAL__N_12c2E = internal global i32 0
11 // CHECK-1: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0
12 // CHECK-1: @_ZN12_GLOBAL__N_11aE = internal global i32 0
13 int a = 0;
15 int b = f();
17 static int c = f();
19 // Note, we can't use an 'L' mangling for c or c2 (like GCC does) based on
20 // 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();
25 class D {
26 static int d;
29 int D::d = f();
31 // Check for generation of a VTT with internal linkage
32 // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
33 struct X {
34 struct EBase { };
35 struct E : public virtual EBase { virtual ~E() {} };
38 // CHECK-1-LABEL: define internal noundef i32 @_ZN12_GLOBAL__N_13fooEv()
39 int foo() {
40 return 32;
43 // CHECK-1-LABEL: define internal noundef i32 @_ZN12_GLOBAL__N_11A3fooEv()
44 namespace A {
45 int foo() {
46 return 45;
51 int concrete() {
52 return a + foo() + A::foo();
55 void test_XE() { throw X::E(); }
57 // Miscompile on llvmc plugins.
58 namespace test2 {
59 struct A {
60 template <class T> struct B {
61 static void foo() {}
64 namespace {
65 struct C;
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();
74 // CHECK-2-LABEL: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv()
77 namespace {
79 int bar() {
80 extern int a;
81 return a;
84 } // namespace