xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/debug-info-function-context.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-pc-linux-gnu %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct C {
4*f4a2713aSLionel Sambuc   void member_function();
5*f4a2713aSLionel Sambuc   static int static_member_function();
6*f4a2713aSLionel Sambuc   static int static_member_variable;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc int C::static_member_variable = 0;
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc void C::member_function() { static_member_variable = 0; }
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc int C::static_member_function() { return static_member_variable; }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc C global_variable;
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc int global_function() { return -1; }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc namespace ns {
20*f4a2713aSLionel Sambuc void global_namespace_function() { global_variable.member_function(); }
21*f4a2713aSLionel Sambuc int global_namespace_variable = 1;
22*f4a2713aSLionel Sambuc }
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // Check that the functions that belong to C have C as a context and the
25*f4a2713aSLionel Sambuc // functions that belong to the namespace have it as a context, and the global
26*f4a2713aSLionel Sambuc // function has the file as a context.
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // CHECK: metadata !"_ZTS1C", metadata !"member_function"{{.*}} [ DW_TAG_subprogram ] [line 11] [def] [member_function]
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // CHECK: metadata !"_ZTS1C", metadata !"static_member_function"{{.*}}  [ DW_TAG_subprogram ] [line 13] [def] [static_member_function]
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc // CHECK: metadata !22, metadata !"global_function"{{.*}}  [ DW_TAG_subprogram ] [line 17] [def] [global_function]
33*f4a2713aSLionel Sambuc // CHECK: !22 = {{.*}} [ DW_TAG_file_type ]
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // CHECK: metadata !24, metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function]
36*f4a2713aSLionel Sambuc // CHECK: !24 = {{.*}} [ DW_TAG_namespace ] [ns] [line 19]
37