1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s 2 // RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -gcodeview -debug-info-kind=limited %s -o - | FileCheck --check-prefix MSVC %s 3 4 // CHECK: !DICompileUnit( 5 // CHECK-SAME: enums: [[ENUMS:![0-9]*]] 6 // CHECK: [[ENUMS]] = !{[[E1:![0-9]*]], [[E2:![0-9]*]], [[E3:![0-9]*]]} 7 8 // In MSVC check that used enum values are emitted as globals. 9 // MSVC: !DICompileUnit( 10 // MSVC-SAME: globals: [[GLOBALS:![0-9]*]] 11 // MSVC: [[GLOBALS]] = !{[[G1:![0-9]*]], [[G2:![0-9]*]]} 12 13 namespace test1 { 14 // CHECK: [[E1]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" 15 // CHECK-SAME: scope: [[TEST1:![0-9]*]] 16 // CHECK-SAME: elements: [[TEST1_ENUMS:![0-9]*]] 17 // CHECK-SAME: identifier: "_ZTSN5test11eE" 18 // CHECK: [[TEST1]] = !DINamespace(name: "test1" 19 // CHECK: [[TEST1_ENUMS]] = !{[[TEST1_E:![0-9]*]]} 20 // CHECK: [[TEST1_E]] = !DIEnumerator(name: "E", value: 0, isUnsigned: true) 21 22 // MSVC: [[G1]] = !DIGlobalVariableExpression(var: [[VAR1:![0-9]*]], 23 // MSVC-SAME: expr: !DIExpression(DW_OP_constu, 0 24 // MSVC: [[VAR1]] = distinct !DIGlobalVariable(name: "E" 25 enum e { E }; 26 void foo() { 27 int v = E; 28 } 29 } 30 31 namespace test2 { 32 // rdar://8195980 33 // CHECK: [[E2]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" 34 // CHECK-SAME: scope: [[TEST2:![0-9]+]] 35 // CHECK-SAME: elements: [[TEST1_ENUMS]] 36 // CHECK-SAME: identifier: "_ZTSN5test21eE" 37 // CHECK: [[TEST2]] = !DINamespace(name: "test2" 38 39 // MSVC: [[G2]] = !DIGlobalVariableExpression(var: [[VAR2:![0-9]*]], 40 // MSVC-SAME: expr: !DIExpression(DW_OP_constu, 0 41 // MSVC: [[VAR2]] = distinct !DIGlobalVariable(name: "E" 42 enum e { E }; 43 bool func(int i) { 44 return i == E; 45 } 46 } 47 48 namespace test3 { 49 // CHECK: [[E3]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" 50 // CHECK-SAME: scope: [[TEST3:![0-9]*]] 51 // CHECK-SAME: elements: [[TEST3_ENUMS:![0-9]*]] 52 // CHECK-SAME: identifier: "_ZTSN5test31eE" 53 // CHECK: [[TEST3]] = !DINamespace(name: "test3" 54 // CHECK: [[TEST3_ENUMS]] = !{[[TEST3_E:![0-9]*]]} 55 // CHECK: [[TEST3_E]] = !DIEnumerator(name: "E", value: -1) 56 enum e { E = -1 }; 57 void func() { 58 e x; 59 } 60 } 61 62 namespace test4 { 63 // Don't try to build debug info for a dependent enum. 64 // CHECK-NOT: test4 65 template <typename T> 66 struct S { 67 enum e { E = T::v }; 68 }; 69 } 70