xref: /llvm-project/clang/test/CodeGenCXX/debug-info-template-parameter.cpp (revision 1cb0e01e42ca5e9de44d9b7cb03d23552a9a9ae1)
1 // Test for DebugInfo for Defaulted parameters for C++ templates
2 // Supported: -O0, standalone DI
3 
4 // RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple x86_64-linux-gnu %s -o - \
5 // RUN:   -O0 -disable-llvm-passes \
6 // RUN:   -debug-info-kind=standalone \
7 // RUN: | FileCheck %s
8 
9 // CHECK: DILocalVariable(name: "f1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]]
10 // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F1_TYPE:[0-9]+]]
11 // CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]}
12 // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}})
13 // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, value: i32 6)
14 
15 // CHECK: DILocalVariable(name: "f2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]]
16 // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F2_TYPE:[0-9]+]]
17 // CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]}
18 // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}, defaulted: true)
19 // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, defaulted: true, value: i32 3)
20 
21 template <typename T = char, int i = 3>
22 class foo {
23 };
24 
25 int main() {
26   foo<int, 6> f1;
27   foo<> f2;
28   return 0;
29 }
30