1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -debug-info-kind=limited -S -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix LINUX %s
2 // RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -S -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix MSVC %s
4 int main(int argc
, char* argv
[], char* arge
[]) {
6 // LINUX: [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
7 // LINUX-SAME: tag: DW_TAG_structure_type
9 // LINUX-NOT: identifier:
12 // MSVC: [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
13 // MSVC-SAME: tag: DW_TAG_structure_type
14 // MSVC-SAME: name: "<unnamed-type-one>"
15 // MSVC-SAME: identifier: ".?AU<unnamed-type-one>@?1??main@@9@"
20 // LINUX: [[TYPE_OF_TWO:![0-9]+]] = distinct !DICompositeType(
21 // LINUX-SAME: tag: DW_TAG_structure_type
23 // LINUX-NOT: identifier:
26 // MSVC: [[TYPE_OF_TWO:![0-9]+]] = distinct !DICompositeType
27 // MSVC-SAME: tag: DW_TAG_structure_type
28 // MSVC-SAME: name: "<unnamed-type-two>"
29 // MSVC-SAME: identifier: ".?AU<unnamed-type-two>@?2??main@@9@"
34 // LINUX: [[TYPE_OF_THREE:![0-9]+]] = distinct !DICompositeType(
35 // LINUX-SAME: tag: DW_TAG_structure_type
36 // LINUX-SAME: name: "named"
37 // LINUX-NOT: identifier:
40 // MSVC: [[TYPE_OF_THREE:![0-9]+]] = distinct !DICompositeType
41 // MSVC-SAME: tag: DW_TAG_structure_type
42 // MSVC-SAME: name: "named"
43 // MSVC-SAME: identifier: ".?AUnamed@?1??main@@9@"
47 // LINUX: [[TYPE_OF_FOUR:![0-9]+]] = distinct !DICompositeType(
48 // LINUX-SAME: tag: DW_TAG_class_type
50 // LINUX-NOT: identifier:
53 // MSVC: [[TYPE_OF_FOUR:![0-9]+]] = distinct !DICompositeType
54 // MSVC-SAME: tag: DW_TAG_class_type
55 // MSVC-SAME: name: "<lambda_0>"
56 // MSVC-SAME: identifier: ".?AV<lambda_0>@?0??main@@9@"
60 // In CodeView, the LF_MFUNCTION entry for "bar()" refers to the forward
61 // reference of the unnamed struct. Visual Studio requires a unique
62 // identifier to match the LF_STRUCTURE forward reference to the definition.
64 struct { void bar() {} } one
;
66 // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "one"
67 // LINUX-SAME: type: [[TYPE_OF_ONE]]
70 // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "one"
71 // MSVC-SAME: type: [[TYPE_OF_ONE]]
75 // In CodeView, the LF_POINTER entry for "ptr2unnamed" refers to the forward
76 // reference of the unnamed struct. Visual Studio requires a unique
77 // identifier to match the LF_STRUCTURE forward reference to the definition.
79 struct { int bar
; } two
= { 42 };
80 int decltype(two
)::*ptr2unnamed
= &decltype(two
)::bar
;
82 // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "two"
83 // LINUX-SAME: type: [[TYPE_OF_TWO]]
86 // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "two"
87 // MSVC-SAME: type: [[TYPE_OF_TWO]]
91 // In DWARF, named structures which are not externally visibile do not
92 // require an identifier. In CodeView, named structures are given an
95 struct named
{ int bar
; int named::* p2mem
; } three
= { 42, &named::bar
};
97 // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "three"
98 // LINUX-SAME: type: [[TYPE_OF_THREE]]
101 // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "three"
102 // MSVC-SAME: type: [[TYPE_OF_THREE]]
106 // In CodeView, the LF_MFUNCTION entry for the lambda "operator()" routine
107 // refers to the forward reference of the unnamed LF_CLASS for the lambda.
108 // Visual Studio requires a unique identifier to match the forward reference
109 // of the LF_CLASS to its definition.
111 auto four
= [argc
](int i
) -> int { return argc
== i
? 1 : 0; };
113 // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "four"
114 // LINUX-SAME: type: [[TYPE_OF_FOUR]]
117 // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "four"
118 // MSVC-SAME: type: [[TYPE_OF_FOUR]]