annotate clang/test/CodeGenCXX/debug-info-function-context.cpp @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-pc-linux-gnu %s \
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
2 // RUN: -dwarf-version=5 -main-file-name %s -o - | FileCheck %s
150
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 struct C {
anatofuz
parents:
diff changeset
5 void member_function();
anatofuz
parents:
diff changeset
6 static int static_member_function();
anatofuz
parents:
diff changeset
7 static int static_member_variable;
anatofuz
parents:
diff changeset
8 };
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 int C::static_member_variable = 0;
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 void C::member_function() { static_member_variable = 0; }
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 int C::static_member_function() { return static_member_variable; }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 C global_variable;
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 int global_function() { return -1; }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 namespace ns {
anatofuz
parents:
diff changeset
21 void global_namespace_function() { global_variable.member_function(); }
anatofuz
parents:
diff changeset
22 int global_namespace_variable = 1;
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
25 // Generate the artificial global functions to initialize a global.
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
26 int global_initialized_variable = C::static_member_function();
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
27
150
anatofuz
parents:
diff changeset
28 // Check that the functions that belong to C have C as a context and the
anatofuz
parents:
diff changeset
29 // functions that belong to the namespace have it as a context, and the global
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
30 // functions (user-defined and artificial) have the file as a context.
150
anatofuz
parents:
diff changeset
31
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
32 // The first DIFile is for the CU, the second is what everything else uses.
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
33 // We're using DWARF v5 so both should have MD5 checksums.
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
34 // CHECK: !DIFile(filename: "{{.*}}context.cpp",{{.*}} checksumkind: CSK_MD5
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 // CHECK: ![[FILE:[0-9]+]] = !DIFile(filename: "{{.*}}context.cpp",{{.*}} checksumkind: CSK_MD5
150
anatofuz
parents:
diff changeset
36 // CHECK: ![[C:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C",
anatofuz
parents:
diff changeset
37 // CHECK: ![[NS:.*]] = !DINamespace(name: "ns"
anatofuz
parents:
diff changeset
38 // CHECK: !DISubprogram(name: "member_function",{{.*}} scope: ![[C]],{{.*}} DISPFlagDefinition
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 // CHECK: !DISubprogram(name: "static_member_function",{{.*}} scope: ![[C]],{{.*}} DISPFlagDefinition
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 // CHECK: !DISubprogram(name: "global_function",{{.*}} scope: ![[FILE]],{{.*}} DISPFlagDefinition
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 // CHECK: !DISubprogram(name: "global_namespace_function",{{.*}} scope: ![[NS]],{{.*}} DISPFlagDefinition
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
45
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
46 // CHECK: !DISubprogram(name: "__cxx_global_var_init",{{.*}} scope: ![[FILE]],{{.*}} DISPFlagDefinition
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
47 // CHECK: !DISubprogram(linkageName: "_GLOBAL__sub_I_{{.*}}",{{.*}} scope: ![[FILE]],{{.*}} DISPFlagDefinition