xref: /llvm-project/clang/test/CodeGenCXX/debug-info-function-context.cpp (revision e76bda544bbf52d9ff3b55e6018b494a1e6bbc00)
1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-pc-linux-gnu %s -o - | FileCheck %s
2 
3 struct C {
4   void member_function();
5   static int static_member_function();
6   static int static_member_variable;
7 };
8 
9 int C::static_member_variable = 0;
10 
11 void C::member_function() { static_member_variable = 0; }
12 
13 int C::static_member_function() { return static_member_variable; }
14 
15 C global_variable;
16 
17 int global_function() { return -1; }
18 
19 namespace ns {
20 void global_namespace_function() { global_variable.member_function(); }
21 int global_namespace_variable = 1;
22 }
23 
24 // Check that the functions that belong to C have C as a context and the
25 // functions that belong to the namespace have it as a context, and the global
26 // function has the file as a context.
27 
28 // CHECK: ![[FILE:[0-9]+]] = !DIFile(filename: "{{.*}}context.cpp",
29 // CHECK: ![[NS:.*]] = !DINamespace(name: "ns"
30 // CHECK: !DISubprogram(name: "member_function",{{.*}} scope: !"_ZTS1C",{{.*}} isDefinition: true
31 
32 // CHECK: !DISubprogram(name: "static_member_function",{{.*}} scope: !"_ZTS1C",{{.*}} isDefinition: true
33 
34 // CHECK: !DISubprogram(name: "global_function",{{.*}} scope: ![[FILE]],{{.*}} isDefinition: true
35 
36 // CHECK: !DISubprogram(name: "global_namespace_function",{{.*}} scope: ![[NS]],{{.*}} isDefinition: true
37