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