xref: /llvm-project/clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp (revision 4ecb2b8ef6be69b55d46ac274f3b7a7103219f98)
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s
2 
3 // Test that clang doesn't crash while resolving temporary debug metadata of
4 // a record with collisions in the record's enum users.
5 
6 // CHECK:      !DICompositeType(tag: DW_TAG_enumeration_type,
7 // CHECK-SAME:                  scope: [[SCOPE:![0-9]+]]
8 // CHECK-SAME:                  elements: [[ELEMENTS:![0-9]+]]
9 // CHECK:      [[SCOPE]] = !DICompositeType(tag: DW_TAG_structure_type
10 // CHECK-SAME:                              name: "Struct1<Struct3>"
11 // CHECK:      [[ELEMENTS]] = !{[[ELEMENT:![0-9]+]]}
12 // CHECK:      [[ELEMENT]] = !DIEnumerator(name: "enumValue1"
13 
14 template <typename> struct Struct1 {
15   enum { enumValue1 };
16   Struct1();
17 };
function2()18 void function2() {
19   struct Struct3 {};
20   int i = Struct1<Struct3>::enumValue1;
21 }
function3()22 void function3() {
23   struct Struct3 {};
24   int i = Struct1<Struct3>::enumValue1;
25 }
26