1 // 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 -debug-info-kind=limited \
6 // RUN:     -dwarf-ext-refs -fmodules                                   \
7 // RUN:     -fmodule-format=obj -fimplicit-module-maps -DMODULES \
8 // RUN:     -triple %itanium_abi_triple \
9 // RUN:     -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t-mod.ll
10 // RUN: cat %t-mod.ll |  FileCheck %s
11 
12 // PCH:
13 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs \
14 // RUN:     -triple %itanium_abi_triple \
15 // RUN:     -o %t.pch %S/Inputs/DebugCXX.h
16 // RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited \
17 // RUN:     -dwarf-ext-refs -fmodule-format=obj \
18 // RUN:     -triple %itanium_abi_triple \
19 // RUN:     -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
20 // RUN: cat %t-pch.ll |  FileCheck %s
21 // RUN: cat %t-pch.ll |  FileCheck %s --check-prefix=CHECK-PCH
22 
23 #ifdef MODULES
24 @import DebugCXX;
25 #endif
26 
27 using DebugCXX::Struct;
28 
29 Struct s;
30 DebugCXX::Enum e;
31 DebugCXX::Template<long> implicitTemplate;
32 DebugCXX::Template<int> explicitTemplate;
33 DebugCXX::FloatInstatiation typedefTemplate;
34 int Struct::static_member = -1;
35 enum {
36   e3 = -1
37 } conflicting_uid = e3;
38 auto anon_enum = DebugCXX::e2;
39 char _anchor = anon_enum + conflicting_uid;
40 
41 TypedefUnion tdu;
42 TypedefEnum tde;
43 TypedefStruct tds;
44 
45 InAnonymousNamespace anon;
46 
47 void foo() {
48   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
49 }
50 
51 // CHECK: ![[NS:.*]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]],
52 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
53 
54 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct",
55 // CHECK-SAME:             scope: ![[NS]],
56 // CHECK-SAME:             flags: DIFlagFwdDecl,
57 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX6StructE")
58 
59 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
60 // CHECK-SAME:             scope: ![[NS]],
61 // CHECK-SAME:             flags: DIFlagFwdDecl,
62 // CHECK-SAME:             identifier:  "_ZTSN8DebugCXX4EnumE")
63 
64 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
65 
66 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
67 // CHECK-SAME:             name: "Template<int, DebugCXX::traits<int> >",
68 // CHECK-SAME:             scope: ![[NS]],
69 // CHECK-SAME:             flags: DIFlagFwdDecl,
70 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
71 
72 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
73 // CHECK-SAME:             name: "Template<float, DebugCXX::traits<float> >",
74 // CHECK-SAME:             scope: ![[NS]],
75 // CHECK-SAME:             flags: DIFlagFwdDecl,
76 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
77 
78 // CHECK: !DICompositeType(tag: DW_TAG_union_type,
79 // CHECK-SAME:             flags: DIFlagFwdDecl, identifier: "_ZTS12TypedefUnion")
80 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
81 // CHECK-SAME:             flags: DIFlagFwdDecl, identifier: "_ZTS11TypedefEnum")
82 // CHECK: !DICompositeType(tag: DW_TAG_structure_type,
83 // CHECK-SAME:             flags: DIFlagFwdDecl, identifier: "_ZTS13TypedefStruct")
84 
85 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
86 // CHECK-SAME:           scope: !"_ZTSN8DebugCXX6StructE"
87 
88 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]]
89 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
90 // CHECK-SAME:             line: 16
91 
92 // CHECK: !DIGlobalVariable(name: "GlobalUnion",
93 // CHECK-SAME:              type: ![[GLOBAL_UNION:[0-9]+]]
94 // CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,
95 // CHECK-SAME:                elements: !{{[0-9]+}})
96 // CHECK: !DIGlobalVariable(name: "GlobalStruct",
97 // CHECK-SAME:              type: ![[GLOBAL_STRUCT:[0-9]+]]
98 // CHECK: ![[GLOBAL_STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type,
99 // CHECK-SAME:                elements: !{{[0-9]+}})
100 
101 // CHECK: !DIGlobalVariable(name: "anon",
102 // CHECK-SAME:              type: ![[GLOBAL_ANON:[0-9]+]]
103 // CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type,
104 // CHECK-SAME:              name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
105 
106 
107 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !"_ZTSN8DebugCXX6StructE", line: 27)
108 
109 // CHECK: !DICompileUnit(
110 // CHECK-SAME:           splitDebugFilename:
111 // CHECK-SAME:           dwoId:
112 // CHECK-PCH: !DICompileUnit({{.*}}splitDebugFilename:
113 // CHECK-PCH:                dwoId: 18446744073709551614
114