1// Test that debug info is emitted for an Objective-C module and
2// a precompiled header.
3
4// REQUIRES: asserts, shell
5
6// Modules:
7// RUN: rm -rf %t
8// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
9// RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
10// RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
11// RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
12// RUN: cat %t-mod.ll | FileCheck %s
13// RUN: cat %t-mod.ll | FileCheck %s --check-prefix=CHECK2
14
15// PCH:
16// RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
17// RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
18// RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
19// RUN: cat %t-pch.ll | FileCheck %s
20// RUN: cat %t-pch.ll | FileCheck %s --check-prefix=CHECK2
21
22#ifdef MODULES
23@import DebugObjC;
24#endif
25
26// CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC
27// CHECK-SAME:                    isOptimized: false,
28
29// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
30// CHECK-SAME:             scope: ![[MODULE:[0-9]+]],
31// CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC
32
33// CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type,
34// CHECK-SAME-NOT:         name:
35// CHECK-SAME:             elements:
36
37// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
38// CHECK-SAME:             name: "FwdDecl",
39// CHECK-SAME:             scope: ![[MODULE]],
40// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
41// CHECK-SAME:             name: "ObjCClass",
42// CHECK-SAME:             scope: ![[MODULE]],
43
44// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDeclared"
45// CHECK-SAME:             elements:
46
47// CHECK: ![[TD_UNION:.*]] = !DICompositeType(tag: DW_TAG_union_type,
48// CHECK-SAME-NOT:         name:
49// CHECK-SAME:             elements:
50
51// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
52// CHECK-SAME:           baseType: ![[TD_UNION]])
53
54// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefEnum",
55// CHECK-SAME:           baseType: ![[TD_ENUM:.*]])
56
57// CHECK: ![[TD_STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type,
58// CHECK-SAME-NOT:         name:
59// CHECK-SAME:             elements:
60// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefStruct",
61// CHECK-SAME:           baseType: ![[TD_STRUCT]])
62
63// CHECK: !DICompositeType(tag: DW_TAG_union_type,
64// CHECK-SAME-NOT:         name:
65
66// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
67// CHECK-SAME-NOT:         name:
68
69// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
70// CHECK-SAME:          scope: ![[MODULE]],
71
72// The forward declaration should not be in the module scope.
73// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
74
75// CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"
76
77// The output order is sublty different for module vs. pch,
78// so these are checked separately:
79//
80// CHECK2: !DICompositeType(tag: DW_TAG_structure_type,
81// CHECK2-SAME:             name: "FwdDecl",
82// CHECK2: !DICompositeType(tag: DW_TAG_structure_type,
83// CHECK2-SAME:             name: "ObjCClass",
84// CHECK2: !DIObjCProperty(name: "property",
85// CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar"
86// CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"
87// CHECK2: !DISubprogram(name: "+[ObjCClass classMethod]"
88// CHECK2: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]"
89// CHECK2: !DISubprogram(name: "-[Category(Category) categoryMethod]"
90