Clang Project

clang_source_code/test/Modules/ModuleDebugInfo.m
1// Test that debug info is emitted for an Objective-C module and
2// a precompiled header.
3
4// REQUIRES: asserts
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, file: ![[FILE:[0-9]+]],
27// CHECK-SAME:                    isOptimized: false
28
29// CHECK: ![[FILE]] = !DIFile(filename: "{{DebugObjC|.*DebugObjC.h}}"
30
31// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
32// CHECK-SAME:             scope: ![[MODULE:[0-9]+]],
33// CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC
34
35// CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type,
36// CHECK-NOT:              name:
37// CHECK-SAME:             elements:
38
39// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
40// CHECK-SAME:          scope: ![[MODULE]],
41
42// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
43// CHECK-SAME:             scope: ![[MODULE]],
44// CHECK-SAME:             elements
45
46// The forward declaration should not be in the module scope.
47// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
48
49// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
50// CHECK-SAME:             scope: ![[MODULE]],
51
52// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
53// CHECK-SAME:             scope: ![[MODULE]],
54// CHECK-SAME:             elements
55
56// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDeclared"
57// CHECK-SAME:             elements:
58
59// CHECK: ![[TD_UNION:.*]] = distinct !DICompositeType(tag: DW_TAG_union_type,
60// CHECK-NOT:              name:
61// CHECK-SAME:             elements:
62
63// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
64// CHECK-SAME:           baseType: ![[TD_UNION]])
65
66// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefEnum",
67// CHECK-SAME:           baseType: ![[TD_ENUM:.*]])
68
69// CHECK: ![[TD_STRUCT:.*]] = distinct !DICompositeType(tag: DW_TAG_structure_type,
70// CHECK-NOT:              name:
71// CHECK-SAME:             elements:
72// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefStruct",
73// CHECK-SAME:           baseType: ![[TD_STRUCT]])
74
75// CHECK: !DICompositeType(tag: DW_TAG_union_type,
76// CHECK-NOT:              name:
77// CHECK-SAME:             )
78
79// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
80// CHECK-NOT:              name:
81// CHECK-SAME:             )
82
83// CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"
84
85// The output order is sublty different for module vs. pch,
86// so these are checked separately:
87//
88// CHECK2: !DISubprogram(name: "+[ObjCClass classMethod]"
89// CHECK2: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]"
90// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
91// CHECK2: !DIObjCProperty(name: "property",
92// CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar"
93// CHECK2: !DISubprogram(name: "-[Category(Category) categoryMethod]"
94// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
95// CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"
96