Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / debug-info-enum.cpp
blob48162b55ed6417033486ede2e23ab1342afb7dca
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
4 // CHECK: !DICompileUnit(
5 // CHECK-SAME: enums: [[ENUMS:![0-9]*]]
6 // CHECK: [[ENUMS]] = !{[[E1:![0-9]*]], [[E2:![0-9]*]], [[E3:![0-9]*]]}
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]*]]}
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)
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;
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"
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;
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;
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 };