blob: 3b879ef2bbfa61bdd1d3b04d5c219d5ab1c15c50 [file] [log] [blame]
Adrian Prantl49553dd2015-09-11 01:03:26 +00001// RUN: rm -rf %t
2// Test that only forward declarations are emitted for types dfined in modules.
3
4// Modules:
5// RUN: %clang_cc1 -x objective-c++ -std=c++11 -g -dwarf-ext-refs -fmodules \
NAKAMURA Takumi6d14f6a2015-09-11 08:56:12 +00006// RUN: -triple %itanium_abi_triple \
Adrian Prantl49553dd2015-09-11 01:03:26 +00007// RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
8// 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 \
NAKAMURA Takumi6d14f6a2015-09-11 08:56:12 +000013// RUN: -triple %itanium_abi_triple \
Adrian Prantl49553dd2015-09-11 01:03:26 +000014// RUN: -o %t.pch %S/Inputs/DebugCXX.h
15// RUN: %clang_cc1 -std=c++11 -g -dwarf-ext-refs -fmodule-format=obj \
NAKAMURA Takumi6d14f6a2015-09-11 08:56:12 +000016// RUN: -triple %itanium_abi_triple \
Adrian Prantl49553dd2015-09-11 01:03:26 +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
38// CHECK: ![[ANON_ENUM:[0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type
39// CHECK-SAME: scope: ![[MOD:[0-9]+]],
40// CHECK-SAME: {{.*}}line: 16, {{.*}}, elements: ![[EE:[0-9]+]])
41
42// CHECK: ![[NS:.*]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]],
43// CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
44
45// CHECK: ![[EE]] = !{![[E2:[0-9]+]]}
46// CHECK: ![[E2]] = !DIEnumerator(name: "e2", value: 50)
47
48// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct",
49// CHECK-SAME: scope: ![[NS]],
50// CHECK-SAME: flags: DIFlagFwdDecl,
51// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
52
53// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
54// CHECK-SAME: scope: ![[NS]],
55// CHECK-SAME: flags: DIFlagFwdDecl,
56// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
57
58// CHECK: !DICompositeType(tag: DW_TAG_class_type,
59
60// CHECK: !DICompositeType(tag: DW_TAG_class_type,
61// CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >",
62// CHECK-SAME: scope: ![[NS]],
63// CHECK-SAME: flags: DIFlagFwdDecl,
64// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
65
66// CHECK: !DICompositeType(tag: DW_TAG_class_type,
67// CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >",
68// CHECK-SAME: scope: ![[NS]],
69// CHECK-SAME: flags: DIFlagFwdDecl,
70// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
71
72// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
73// CHECK-SAME: scope: !"_ZTSN8DebugCXX6StructE"
74
75// CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM]]
76
NAKAMURA Takumi5f901422015-09-11 08:53:29 +000077// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !"_ZTSN8DebugCXX6StructE", line: [[@LINE-53]])