-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] Emit DW_TAG_template_alias for template aliases #87623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
806bbc1
395ab3e
2ed6e15
9a00dd3
ed665d2
1852f25
3fd0706
5b41774
11417af
8e77fb7
558f73d
6d51016
eb5064e
0bf200d
0c8a669
3586713
4afd353
7795894
0952cf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s -gsimple-template-names=simple \ | ||
// RUN: | FileCheck %s | ||
|
||
//// Check that -gtemplate-alias causes DW_TAG_template_alias emission for | ||
//// template aliases with default parameter values. See template-alias.cpp for | ||
//// more template alias tests. | ||
//// FIXME: We currently do not emit defaulted arguments. | ||
|
||
template<typename T> | ||
struct X { | ||
char m; | ||
}; | ||
|
||
template<typename T> | ||
struct Y { | ||
char n; | ||
}; | ||
|
||
template <typename NonDefault, template <typename C> class T = Y, int I = 5, typename... Ts> | ||
using A = X<NonDefault>; | ||
|
||
//// We should be able to emit type alias metadata which describes all the | ||
//// values, including the defaulted parameters and empty parameter pack. | ||
A<int> a; | ||
|
||
// CHECK: !DIDerivedType(tag: DW_TAG_template_alias, name: "A", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]], extraData: ![[extraData:[0-9]+]]) | ||
// CHECK: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", | ||
// CHECK: ![[int:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
// CHECK: ![[extraData]] = !{![[NonDefault:[0-9]+]]} | ||
// CHECK: ![[NonDefault]] = !DITemplateTypeParameter(name: "NonDefault", type: ![[int]]) | ||
|
||
//// FIXME: Ideally, we would describe the deafulted args, like this: | ||
// : ![[extraData]] = !{![[NonDefault:[0-9]+]], ![[T:[0-9]+]], ![[I:[0-9]+]], ![[Ts:[0-9]+]]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Is it worth turning these into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the test will already start failing if this gets fixed because the current There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right, that makes sense, happy keeping it as is |
||
// : ![[NonDefault]] = !DITemplateTypeParameter(name: "NonDefault", type: ![[int]]) | ||
// : ![[T]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "T", defaulted: true, value: !"Y") | ||
// : ![[I]] = !DITemplateValueParameter(name: "I", type: ![[int]], defaulted: true, value: i32 5) | ||
// : ![[Ts]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Ts", value: ![[types:[0-9]+]]) | ||
// : ![[types]] = !{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s -gsimple-template-names=simple \ | ||
// RUN: | FileCheck %s --check-prefixes=ALIAS-SIMPLE,ALIAS-ALL | ||
|
||
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s -gsimple-template-names=mangled \ | ||
// RUN: | FileCheck %s --check-prefixes=ALIAS-MANGLED,ALIAS-ALL | ||
|
||
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s \ | ||
// RUN: | FileCheck %s --check-prefixes=ALIAS-FULL,ALIAS-ALL | ||
|
||
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone %s \ | ||
// RUN: | FileCheck %s --check-prefixes=TYPEDEF | ||
|
||
|
||
//// Check that -gtemplate-alias causes DW_TAG_template_alias emission for | ||
//// template aliases, and that respects gsimple-template-names. | ||
//// | ||
//// Test type and value template parameters. | ||
|
||
template<typename Y, int Z> | ||
struct X { | ||
Y m1 = Z; | ||
}; | ||
|
||
template<typename B, int C> | ||
using A = X<B, C>; | ||
|
||
A<int, 5> a; | ||
|
||
|
||
// ALIAS-SIMPLE: !DIDerivedType(tag: DW_TAG_template_alias, name: "A", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]], extraData: ![[extraData:[0-9]+]]) | ||
// ALIAS-SIMPLE: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", | ||
|
||
// FIXME: Mangled name is wrong (not a regression). | ||
// ALIAS-MANGLED: !DIDerivedType(tag: DW_TAG_template_alias, name: "A<int, 5>", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]], extraData: ![[extraData:[0-9]+]]) | ||
// ALIAS-MANGLED: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STN|X|<int, 5>", | ||
|
||
// ALIAS-FULL: !DIDerivedType(tag: DW_TAG_template_alias, name: "A<int, 5>", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]], extraData: ![[extraData:[0-9]+]]) | ||
// ALIAS-FULL: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X<int, 5>", | ||
|
||
// ALIAS-ALL: ![[int:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
// ALIAS-ALL: ![[extraData]] = !{![[B:[0-9]+]], ![[C:[0-9]+]]} | ||
// ALIAS-ALL: ![[B]] = !DITemplateTypeParameter(name: "B", type: ![[int]]) | ||
// ALIAS-ALL: ![[C]] = !DITemplateValueParameter(name: "C", type: ![[int]], value: i32 5) | ||
|
||
// TYPEDEF: !DIDerivedType(tag: DW_TAG_typedef, name: "A<int, 5>", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]]) | ||
// TYPEDEF: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X<int, 5>", | ||
// TYPEDEF: ![[int:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s -gsimple-template-names=simple \ | ||
// RUN: | FileCheck %s | ||
|
||
//// Check that -gtemplate-alias causes DW_TAG_template_alias emission for | ||
//// variadic template aliases. See template-alias.cpp for more template alias | ||
//// tests. | ||
|
||
template<typename Y, int Z> | ||
struct X { | ||
Y m1 = Z; | ||
}; | ||
|
||
template<int I, typename... Ts> | ||
using A = X<Ts..., I>; | ||
|
||
A<5, int> a; | ||
|
||
// CHECK: !DIDerivedType(tag: DW_TAG_template_alias, name: "A", file: ![[#]], line: [[#]], baseType: ![[baseType:[0-9]+]], extraData: ![[extraData:[0-9]+]]) | ||
// CHECK: ![[baseType]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", | ||
// CHECK: ![[int:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
// CHECK: ![[extraData]] = !{![[I:[0-9]+]], ![[Ts:[0-9]+]]} | ||
// CHECK: ![[I]] = !DITemplateValueParameter(name: "I", type: ![[int]], value: i32 5) | ||
// CHECK: ![[Ts]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "Ts", value: ![[types:[0-9]+]]) | ||
// CHECK: ![[types]] = !{![[int_template_param:[0-9]+]]} | ||
// CHECK: ![[int_template_param]] = !DITemplateTypeParameter(type: ![[int]]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -465,3 +465,13 @@ | |
// MANGLED_TEMP_NAMES: error: unknown argument '-gsimple-template-names=mangled'; did you mean '-Xclang -gsimple-template-names=mangled' | ||
// RUN: %clang -### -target x86_64 -c -g %s 2>&1 | FileCheck --check-prefix=FULL_TEMP_NAMES --implicit-check-not=debug-forward-template-params %s | ||
// FULL_TEMP_NAMES-NOT: -gsimple-template-names | ||
|
||
//// Test -g[no-]template-alias (enabled by default with SCE debugger tuning and DWARFv5). | ||
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce %s 2>&1 | FileCheck %s --check-prefixes=TEMPLATE-ALIAS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh Coulda sworn that was changed... okay. |
||
// RUN: %clang -### -target x86_64 -c -gdwarf-4 -gsce %s 2>&1 | FileCheck %s --check-prefixes=NO-TEMPLATE-ALIAS | ||
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce -gtemplate-alias %s 2>&1 | FileCheck %s --check-prefixes=TEMPLATE-ALIAS | ||
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce -gno-template-alias %s 2>&1 | FileCheck %s --check-prefixes=NO-TEMPLATE-ALIAS | ||
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gtemplate-alias %s 2>&1 | FileCheck %s --check-prefixes=TEMPLATE-ALIAS | ||
// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gtemplate-alias -gno-template-alias %s 2>&1 | FileCheck %s --check-prefixes=NO-TEMPLATE-ALIAS | ||
// TEMPLATE-ALIAS: "-gtemplate-alias" | ||
// NO-TEMPLATE-ALIAS-NOT: "-gtemplate-alias" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take out the diags here, if someone explicitly asks for something in debug info we do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done