1 // RUN: %clang_cc1 -debug-info-kind=unused-types -emit-llvm -o - %s | FileCheck %s 2 // RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck --check-prefix=NODBG %s 3 typedef int my_int; 4 struct foo {}; 5 enum bar { BAR }; 6 union baz {}; 7 8 void quux(void) { 9 typedef int x; 10 struct y {}; 11 enum z { Z }; 12 union w {}; 13 } 14 15 // Check that debug info is emitted for the typedef, struct, enum, and union 16 // when -fno-eliminate-unused-debug-types and -g are set. 17 18 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]] 19 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar" 20 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR" 21 // CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z" 22 // CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z" 23 // CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], [[TYPE6:![0-9]+]], {{![0-9]+}}, [[TYPE7:![0-9]+]], [[TYPE2]], [[TYPE8:![0-9]+]]} 24 // CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int" 25 // CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo" 26 // CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "baz" 27 // CHECK: [[TYPE7]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "y" 28 // CHECK: [[TYPE8]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "w" 29 30 // Check that debug info is not emitted for the typedef, struct, enum, and 31 // union when -fno-eliminate-unused-debug-types and -g are not set. These are 32 // the same checks as above with `NODBG-NOT` rather than `CHECK`. 33 34 // NODBG-NOT: !DI{{CompositeType|Enumerator|DerivedType}} 35 36 // Check that debug info is not emitted for declarations. Obnoxious 37 // indentifiers are to avoid collisions with the SHA emittied as debug info. 38 struct unused_struct; 39 enum unused_enum; 40 union unused_union; 41 void b0(void) { 42 struct unused_local_struct; 43 enum unused_local_enum; 44 union unused_local_union; 45 } 46 47 // NODBG-NOT: name: "unused_ 48