blob: c4c6a298234e26a393b337ab85b69515b5325f87 [file] [log] [blame]
Adrian Prantl5c8bd882015-09-11 17:23:08 +00001// RUN: rm -rf %t
2// Test that only forward declarations are emitted for types dfined in modules.
3
4// Modules:
Douglas Katzman3459ce22015-10-08 04:24:12 +00005// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=limited -dwarf-ext-refs -fmodules \
Adrian Prantl5c8bd882015-09-11 17:23:08 +00006// RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
Reid Kleckner854a2b72015-09-11 17:50:14 +00007// RUN: -triple %itanium_abi_triple \
Adrian Prantl5c8bd882015-09-11 17:23:08 +00008// RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t-mod.ll
9// RUN: cat %t-mod.ll | FileCheck %s
10
11// PCH:
12// RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs \
Reid Kleckner854a2b72015-09-11 17:50:14 +000013// RUN: -triple %itanium_abi_triple \
Adrian Prantl5c8bd882015-09-11 17:23:08 +000014// RUN: -o %t.pch %S/Inputs/DebugCXX.h
Douglas Katzman3459ce22015-10-08 04:24:12 +000015// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited -dwarf-ext-refs -fmodule-format=obj \
Reid Kleckner854a2b72015-09-11 17:50:14 +000016// RUN: -triple %itanium_abi_triple \
Adrian Prantl5c8bd882015-09-11 17:23:08 +000017// RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
18// RUN: cat %t-pch.ll | FileCheck %s
19
20#ifdef MODULES
21@import DebugCXX;
22#endif
23
24using DebugCXX::Struct;
25
26Struct s;
27DebugCXX::Enum e;
28DebugCXX::Template<long> implicitTemplate;
29DebugCXX::Template<int> explicitTemplate;
30DebugCXX::FloatInstatiation typedefTemplate;
31int Struct::static_member = -1;
32enum {
33 e3 = -1
34} conflicting_uid = e3;
35auto anon_enum = DebugCXX::e2;
36char _anchor = anon_enum + conflicting_uid;
37
Adrian Prantle5238d22016-01-19 18:02:47 +000038TypedefUnion tdu;
39TypedefEnum tde;
40TypedefStruct tds;
41
Adrian Prantl8f55b662016-01-20 01:29:34 +000042InAnonymousNamespace anon;
43
Adrian Prantlcd975012016-01-19 23:42:44 +000044void foo() {
Adrian Prantl8f55b662016-01-20 01:29:34 +000045 anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
Adrian Prantlcd975012016-01-19 23:42:44 +000046}
47
Adrian Prantl5c8bd882015-09-11 17:23:08 +000048// CHECK: ![[NS:.*]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]],
49// CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
50
51// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct",
52// CHECK-SAME: scope: ![[NS]],
53// CHECK-SAME: flags: DIFlagFwdDecl,
54// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
55
56// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
57// CHECK-SAME: scope: ![[NS]],
58// CHECK-SAME: flags: DIFlagFwdDecl,
59// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
60
61// CHECK: !DICompositeType(tag: DW_TAG_class_type,
62
63// CHECK: !DICompositeType(tag: DW_TAG_class_type,
64// CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >",
65// CHECK-SAME: scope: ![[NS]],
66// CHECK-SAME: flags: DIFlagFwdDecl,
67// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
68
69// CHECK: !DICompositeType(tag: DW_TAG_class_type,
70// CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >",
71// CHECK-SAME: scope: ![[NS]],
72// CHECK-SAME: flags: DIFlagFwdDecl,
73// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
74
Adrian Prantle5238d22016-01-19 18:02:47 +000075// CHECK: !DICompositeType(tag: DW_TAG_union_type,
76// CHECK-SAME: flags: DIFlagFwdDecl, identifier: "_ZTS12TypedefUnion")
77// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
78// CHECK-SAME: flags: DIFlagFwdDecl, identifier: "_ZTS11TypedefEnum")
79// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
80// CHECK-SAME: flags: DIFlagFwdDecl, identifier: "_ZTS13TypedefStruct")
81
Adrian Prantl5c8bd882015-09-11 17:23:08 +000082// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
83// CHECK-SAME: scope: !"_ZTSN8DebugCXX6StructE"
84
85// CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]]
86// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
87// CHECK-SAME: line: 16
88
Adrian Prantl43e00812016-01-19 23:42:53 +000089// CHECK: !DIGlobalVariable(name: "GlobalUnion",
90// CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]]
91// CHECK: ![[GLOBAL_UNION]] = !DICompositeType(tag: DW_TAG_union_type,
92// CHECK-SAME: elements: !{{[0-9]+}})
93// CHECK: !DIGlobalVariable(name: "GlobalStruct",
94// CHECK-SAME: type: ![[GLOBAL_STRUCT:[0-9]+]]
95// CHECK: ![[GLOBAL_STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type,
96// CHECK-SAME: elements: !{{[0-9]+}})
97
Adrian Prantl8f55b662016-01-20 01:29:34 +000098// CHECK: !DIGlobalVariable(name: "anon",
99// CHECK-SAME: type: ![[GLOBAL_ANON:[0-9]+]]
100// CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type,
101// CHECK-SAME: name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
102
103
Reid Kleckner854a2b72015-09-11 17:50:14 +0000104// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !"_ZTSN8DebugCXX6StructE", line: 24)
Adrian Prantlc96da8f2016-01-22 17:43:43 +0000105
106// CHECK: !DICompileUnit(
107// CHECK-SAME: splitDebugFilename:
108// CHECK-SAME: dwoId: