1// RUN: %clang_cc1 -g -emit-llvm -o - %s | FileCheck %s 2// The DWARF standard says the underlying data type of an enum may be 3// stored in an DW_AT_type entry in the enum DIE. This is useful to have 4// so the debugger knows about the signedness of the underlying type. 5 6typedef long NSInteger; 7#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 8 9// Enum with no specified underlying type 10typedef enum { 11 Enum0One, 12 Enum0Two 13} Enum0; 14 15// Enum declared with the NS_ENUM macro 16typedef NS_ENUM(NSInteger, Enum1) { 17 Enum1One = -1, 18 Enum1Two 19}; 20 21// Enum declared with a fixed underlying type 22typedef enum : NSInteger { 23 Enum2One = -1, 24 Enum2Two 25} Enum2; 26 27// Typedef and declaration separately 28enum : NSInteger 29{ 30 Enum3One = -1, 31 Enum3Two 32}; 33typedef NSInteger Enum3; 34 35int main() { 36 Enum0 e0 = Enum0One; 37 // CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ENUM0:[0-9]+]], metadata !{{.*}}) 38 Enum1 e1 = Enum1One; 39 // CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ENUM1:[0-9]+]], metadata !{{.*}}) 40 Enum2 e2 = Enum2One; 41 // CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ENUM2:[0-9]+]], metadata !{{.*}}) 42 Enum3 e3 = Enum3One; 43 // CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ENUM3:[0-9]+]], metadata !{{.*}}) 44 45 // -Werror and the following line ensures that these enums are not 46 // -treated as C++11 strongly typed enums. 47 return e0 != e1 && e1 == e2 && e2 == e3; 48} 49// CHECK: ![[ENUMERATOR0:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 10 50// CHECK: ![[ENUMERATOR1:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [Enum1] [line 16{{.*}}] [from NSInteger] 51// CHECK: ![[ENUMERATOR3:[0-9]+]] = {{.*}}; [ DW_TAG_typedef ] [NSInteger] [line 6{{.*}}] [from long int] 52// CHECK: ![[ENUMERATOR2:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 22{{.*}}] [from NSInteger] 53 54// CHECK: ![[ENUM0]] = !{!"0x100\00e0\00{{[^,]*}}"{{, [^,]+, [^,]+}}, ![[TYPE0:[0-9]+]]} ; [ DW_TAG_auto_variable ] 55// CHECK: ![[TYPE0]] = !{!"0x16\00Enum0\00{{.*}}", {{.*}}, ![[ENUMERATOR0]]} ; [ DW_TAG_typedef ] [Enum0] 56 57// CHECK: ![[ENUM1]] = !{!"0x100\00e1\00{{[^,]*}}"{{, [^,]+, [^,]+}}, ![[TYPE1:[0-9]+]]} ; [ DW_TAG_auto_variable ] 58// CHECK: ![[TYPE1]] = !{!"0x16\00Enum1\00{{.*}}", {{.*}}, ![[ENUMERATOR1]]} ; [ DW_TAG_typedef ] [Enum1] 59 60// CHECK: ![[ENUM2]] = !{!"0x100\00e2\00{{[^,]*}}"{{, [^,]+, [^,]+}}, ![[TYPE2:[0-9]+]]} ; [ DW_TAG_auto_variable ] 61// CHECK: ![[TYPE2]] = !{!"0x16\00Enum2\00{{.*}}", {{.*}}, ![[ENUMERATOR2]]} ; [ DW_TAG_typedef ] [Enum2] 62 63// CHECK: ![[ENUM3]] = !{!"0x100\00e3\00{{[^,]*}}"{{, [^,]+, [^,]+}}, ![[TYPE3:[0-9]+]]} ; [ DW_TAG_auto_variable ] 64// CHECK: ![[TYPE3]] = !{!"0x16\00Enum3\00{{.*}}", {{.*}}, ![[ENUMERATOR3]]} ; [ DW_TAG_typedef ] [Enum3] 65