| 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 |
// CHECK: [[E2]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" |
| 33 |
// CHECK-SAME: scope: [[TEST2:![0-9]+]] |
| 34 |
// CHECK-SAME: elements: [[TEST1_ENUMS]] |
| 35 |
// CHECK-SAME: identifier: "_ZTSN5test21eE" |
| 36 |
// CHECK: [[TEST2]] = !DINamespace(name: "test2" |
| 37 |
|
| 38 |
// MSVC: [[G2]] = !DIGlobalVariableExpression(var: [[VAR2:![0-9]*]], |
| 39 |
// MSVC-SAME: expr: !DIExpression(DW_OP_constu, 0 |
| 40 |
// MSVC: [[VAR2]] = distinct !DIGlobalVariable(name: "E" |
| 41 |
enum e { E }; |
| 42 |
bool func(int i) { |
| 43 |
return i == E; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
namespace test3 { |
| 48 |
// CHECK: [[E3]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" |
| 49 |
// CHECK-SAME: scope: [[TEST3:![0-9]*]] |
| 50 |
// CHECK-SAME: elements: [[TEST3_ENUMS:![0-9]*]] |
| 51 |
// CHECK-SAME: identifier: "_ZTSN5test31eE" |
| 52 |
// CHECK: [[TEST3]] = !DINamespace(name: "test3" |
| 53 |
// CHECK: [[TEST3_ENUMS]] = !{[[TEST3_E:![0-9]*]]} |
| 54 |
// CHECK: [[TEST3_E]] = !DIEnumerator(name: "E", value: -1) |
| 55 |
enum e { E = -1 }; |
| 56 |
void func() { |
| 57 |
e x; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
namespace test4 { |
| 62 |
// Don't try to build debug info for a dependent enum. |
| 63 |
// CHECK-NOT: test4 |
| 64 |
template <typename T> |
| 65 |
struct S { |
| 66 |
enum e { E = T::v }; |
| 67 |
}; |
| 68 |
} |