[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / unique-internal-linkage-names-dwarf.cpp
blobcdd7062a3a00943b52eb8981f4a98820625e14ec
1 // This test checks if C++ functions with internal linkage names are mangled
2 // and the module hash suffixes attached including emitting DW_AT_linkage_name.
3 //
4 // RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=4 -emit-llvm -o - %s | FileCheck %s --check-prefix=PLAIN
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=4 -funique-internal-linkage-names -emit-llvm -o - %s | FileCheck %s --check-prefix=UNIQUE
6 // RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=5 -emit-llvm -o - %s | FileCheck %s --check-prefix=PLAIN
7 // RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=5 -funique-internal-linkage-names -emit-llvm -o - %s | FileCheck %s --check-prefix=UNIQUE
9 static int glob_foo = 5;
10 static int foo(void) {
11 __builtin_printf("%p", &glob_foo);
12 return glob_foo;
15 // Anonymous namespaces generate internal linkage symbols.
16 namespace {
17 int glob_bar;
18 int bar() {
19 return glob_bar;
23 extern "C" {
24 static int glob_zip;
25 static int zip(void) {
26 return glob_zip;
30 void baz() {
31 foo();
32 bar();
33 zip();
36 // PLAIN-DAG: @_ZL8glob_foo = internal global i32
37 // PLAIN-DAG: define internal noundef i32 @_ZL3foov()
38 // PLAIN-DAG: distinct !DIGlobalVariable(name: "glob_foo", linkageName: "_ZL8glob_foo"{{.*}})
39 // PLAIN-DAG: distinct !DISubprogram(name: "foo", linkageName: "_ZL3foov"{{.*}})
40 // PLAIN-DAG: @_ZN12_GLOBAL__N_18glob_barE = internal global i32
41 // PLAIN-DAG: define internal noundef i32 @_ZN12_GLOBAL__N_13barEv()
42 // PLAIN-DAG: distinct !DIGlobalVariable(name: "glob_bar", linkageName: "_ZN12_GLOBAL__N_18glob_barE"{{.*}})
43 // PLAIN-DAG: distinct !DISubprogram(name: "bar", linkageName: "_ZN12_GLOBAL__N_13barEv"{{.*}})
44 // PLAIN-DAG: @_ZL8glob_zip = internal global i32
45 // PLAIN-DAG: define internal noundef i32 @_ZL3zipv()
46 // PLAIN-DAG: distinct !DIGlobalVariable(name: "glob_zip", linkageName: "_ZL8glob_zip"{{.*}})
47 // PLAIN-DAG: distinct !DISubprogram(name: "zip", linkageName: "_ZL3zipv"{{.*}})
49 // UNIQUE-DAG: @_ZL8glob_foo = internal global i32
50 // UNIQUE-DAG: define internal noundef i32 @_ZL3foov.[[MODHASH:__uniq\.[0-9]+]]()
51 // UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_foo", linkageName: "_ZL8glob_foo"{{.*}})
52 // UNIQUE-DAG: distinct !DISubprogram(name: "foo", linkageName: "_ZL3foov.[[MODHASH]]"{{.*}})
53 // UNIQUE-DAG: @_ZN12_GLOBAL__N_18glob_barE = internal global i32
54 // UNIQUE-DAG: define internal noundef i32 @_ZN12_GLOBAL__N_13barEv.[[MODHASH]]()
55 // UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_bar", linkageName: "_ZN12_GLOBAL__N_18glob_barE"{{.*}})
56 // UNIQUE-DAG: distinct !DISubprogram(name: "bar", linkageName: "_ZN12_GLOBAL__N_13barEv.[[MODHASH]]"{{.*}})
57 // UNIQUE-DAG: @_ZL8glob_zip = internal global i32
58 // UNIQUE-DAG: define internal noundef i32 @_ZL3zipv.[[MODHASH]]()
59 // UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_zip", linkageName: "_ZL8glob_zip"{{.*}})
60 // UNIQUE-DAG: distinct !DISubprogram(name: "zip", linkageName: "_ZL3zipv.[[MODHASH]]"{{.*}})