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 |
3 | |
4 | int main(int argc, char* argv[], char* arge[]) { |
5 | // |
6 | // In CodeView, the LF_MFUNCTION entry for "bar()" refers to the forward |
7 | // reference of the unnamed struct. Visual Studio requires a unique |
8 | // identifier to match the LF_STRUCTURE forward reference to the definition. |
9 | // |
10 | struct { void bar() {} } one; |
11 | // |
12 | // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "one" |
13 | // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]] |
14 | // LINUX-SAME: ) |
15 | // LINUX: [[TYPE_OF_ONE]] = distinct !DICompositeType( |
16 | // LINUX-SAME: tag: DW_TAG_structure_type |
17 | // LINUX-NOT: name: |
18 | // LINUX-NOT: identifier: |
19 | // LINUX-SAME: ) |
20 | // |
21 | // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "one" |
22 | // MSVC-SAME: type: [[TYPE_OF_ONE:![0-9]+]] |
23 | // MSVC-SAME: ) |
24 | // MSVC: [[TYPE_OF_ONE]] = distinct !DICompositeType |
25 | // MSVC-SAME: tag: DW_TAG_structure_type |
26 | // MSVC-SAME: name: "<unnamed-type-one>" |
27 | // MSVC-SAME: identifier: ".?AU<unnamed-type-one>@?1??main@@9@" |
28 | // MSVC-SAME: ) |
29 | |
30 | |
31 | // In CodeView, the LF_POINTER entry for "ptr2unnamed" refers to the forward |
32 | // reference of the unnamed struct. Visual Studio requires a unique |
33 | // identifier to match the LF_STRUCTURE forward reference to the definition. |
34 | // |
35 | struct { int bar; } two = { 42 }; |
36 | int decltype(two)::*ptr2unnamed = &decltype(two)::bar; |
37 | // |
38 | // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "two" |
39 | // LINUX-SAME: type: [[TYPE_OF_TWO:![0-9]+]] |
40 | // LINUX-SAME: ) |
41 | // LINUX: [[TYPE_OF_TWO]] = distinct !DICompositeType( |
42 | // LINUX-SAME: tag: DW_TAG_structure_type |
43 | // LINUX-NOT: name: |
44 | // LINUX-NOT: identifier: |
45 | // LINUX-SAME: ) |
46 | // |
47 | // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "two" |
48 | // MSVC-SAME: type: [[TYPE_OF_TWO:![0-9]+]] |
49 | // MSVC-SAME: ) |
50 | // MSVC: [[TYPE_OF_TWO]] = distinct !DICompositeType |
51 | // MSVC-SAME: tag: DW_TAG_structure_type |
52 | // MSVC-SAME: name: "<unnamed-type-two>" |
53 | // MSVC-SAME: identifier: ".?AU<unnamed-type-two>@?2??main@@9@" |
54 | // MSVC-SAME: ) |
55 | |
56 | |
57 | // In DWARF, named structures which are not externally visibile do not |
58 | // require an identifier. In CodeView, named structures are given an |
59 | // identifier. |
60 | // |
61 | struct named { int bar; int named::* p2mem; } three = { 42, &named::bar }; |
62 | // |
63 | // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "three" |
64 | // LINUX-SAME: type: [[TYPE_OF_THREE:![0-9]+]] |
65 | // LINUX-SAME: ) |
66 | // LINUX: [[TYPE_OF_THREE]] = distinct !DICompositeType( |
67 | // LINUX-SAME: tag: DW_TAG_structure_type |
68 | // LINUX-SAME: name: "named" |
69 | // LINUX-NOT: identifier: |
70 | // LINUX-SAME: ) |
71 | // |
72 | // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "three" |
73 | // MSVC-SAME: type: [[TYPE_OF_THREE:![0-9]+]] |
74 | // MSVC-SAME: ) |
75 | // MSVC: [[TYPE_OF_THREE]] = distinct !DICompositeType |
76 | // MSVC-SAME: tag: DW_TAG_structure_type |
77 | // MSVC-SAME: name: "named" |
78 | // MSVC-SAME: identifier: ".?AUnamed@?1??main@@9@" |
79 | // MSVC-SAME: ) |
80 | |
81 | |
82 | // In CodeView, the LF_MFUNCTION entry for the lambda "operator()" routine |
83 | // refers to the forward reference of the unnamed LF_CLASS for the lambda. |
84 | // Visual Studio requires a unique identifier to match the forward reference |
85 | // of the LF_CLASS to its definition. |
86 | // |
87 | auto four = [argc](int i) -> int { return argc == i ? 1 : 0; }; |
88 | // |
89 | // LINUX: !{{[0-9]+}} = !DILocalVariable(name: "four" |
90 | // LINUX-SAME: type: [[TYPE_OF_FOUR:![0-9]+]] |
91 | // LINUX-SAME: ) |
92 | // LINUX: [[TYPE_OF_FOUR]] = distinct !DICompositeType( |
93 | // LINUX-SAME: tag: DW_TAG_class_type |
94 | // LINUX-NOT: name: |
95 | // LINUX-NOT: identifier: |
96 | // LINUX-SAME: ) |
97 | // |
98 | // MSVC: !{{[0-9]+}} = !DILocalVariable(name: "four" |
99 | // MSVC-SAME: type: [[TYPE_OF_FOUR:![0-9]+]] |
100 | // MSVC-SAME: ) |
101 | // MSVC: [[TYPE_OF_FOUR]] = distinct !DICompositeType |
102 | // MSVC-SAME: tag: DW_TAG_class_type |
103 | // MSVC-NOT: name: |
104 | // MSVC-SAME: identifier: ".?AV<lambda_0>@?0??main@@9@" |
105 | // MSVC-SAME: ) |
106 | |
107 | return 0; |
108 | } |
109 | |