xref: /llvm-project/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp (revision b6f922fbf5e983122271aa12acb33f6172046d4d)
1 // RUN: %clang_cc1 %s -triple x86_64-windows-msvc -gcodeview \
2 // RUN:   -debug-info-kind=line-tables-only -emit-llvm -o - | FileCheck %s
3 // Checks that clang with "-gline-tables-only" with CodeView emits some debug
4 // info for variables and types when they appear in function scopes.
5 
6 namespace NS {
7 struct C {
mNS::C8   void m() {}
9   // Test externally visible lambda.
__anonbb95ea230102() 10   void lambda2() { []() {}(); }
11 
12   // Test naming for function parameters.
lambda_paramsNS::C13   void lambda_params(int x = [](){ return 0; }(), int y = [](){ return 1; }()) {}
14 };
f()15 void f() {}
16 }
17 
18 // Test non- externally visible lambda.
__anonbb95ea230402() 19 auto lambda1 = []() { return 1; };
20 
21 NS::C c;
22 
23 
test()24 void test() {
25   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
26   // CHECK-SAME:          type: ![[F:[0-9]+]]
27   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
28   // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
29   // CHECK: ![[FTYPE]] = !{null}
30   NS::f();
31 
32   // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
33   // CHECK-SAME:                                   type: ![[MTYPE:[0-9]+]],
34   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
35   // CHECK-SAME:                      flags: DIFlagFwdDecl
36   // CHECK-NOT: identifier
37   // CHECK: ![[MTYPE]] = !DISubroutineType({{.*}}types: !{{.*}})
38   c.m();
39 
40   // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA0:[0-9]+]],
41   // CHECK: ![[LAMBDA0]] = !DICompositeType(tag: DW_TAG_class_type,
42   // CHECK-SAME:                            name: "<lambda_0>",
43   // CHECK-SAME:                            flags: DIFlagFwdDecl
44   lambda1();
45 
46   // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1_1:[0-9]+]],
47   // CHECK: ![[LAMBDA1_1]] = !DICompositeType(tag: DW_TAG_class_type,
48   // CHECK-SAME:                              name: "<lambda_1_1>",
49   // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA2_1:[0-9]+]],
50   // CHECK: ![[LAMBDA2_1]] = !DICompositeType(tag: DW_TAG_class_type,
51   // CHECK-SAME:                              name: "<lambda_2_1>",
52   c.lambda_params();
53 
54   // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1:[0-9]+]],
55   // CHECK: ![[LAMBDA1]] = !DICompositeType(tag: DW_TAG_class_type,
56   // CHECK-SAME:                            name: "<lambda_1>",
57   // CHECK-SAME:                            flags: DIFlagFwdDecl
58   c.lambda2();
59 }
60