This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4ecb2b8ef6be: [DebugInfo][Metadata] Make AllEnumTypes
holding TrackingMDNodeRef (authored by krisb).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137067/new/
https://reviews.llvm.org/D137067
Files:
clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/IR/DIBuilder.cpp
Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -84,7 +84,9 @@
}
if (!AllEnumTypes.empty())
- CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));
+ CUNode->replaceEnumTypes(MDTuple::get(
+ VMContext, SmallVector<Metadata *, 16>(AllEnumTypes.begin(),
+ AllEnumTypes.end())));
SmallVector<Metadata *, 16> RetainValues;
// Declarations and definitions of the same type may be retained. Some
@@ -556,7 +558,7 @@
getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits,
0,
IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0,
nullptr,
nullptr, UniqueIdentifier);
- AllEnumTypes.push_back(CTy);
+ AllEnumTypes.emplace_back(CTy);
trackIfUnresolved(CTy);
return CTy;
}
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -48,7 +48,7 @@
Function *LabelFn; ///< llvm.dbg.label
Function *AddrFn; ///< llvm.dbg.addr
- SmallVector<Metadata *, 4> AllEnumTypes;
+ SmallVector<TrackingMDNodeRef, 4> AllEnumTypes;
/// Track the RetainTypes, since they can be updated later on.
SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
SmallVector<Metadata *, 4> AllSubprograms;
Index: clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm
-debug-info-kind=constructor %s -o - | FileCheck %s
+
+// Test that clang doesn't crash while resolving temporary debug metadata of
+// a record with collisions in the record's enum users.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME: scope: [[SCOPE:![0-9]+]]
+// CHECK-SAME: elements: [[ELEMENTS:![0-9]+]]
+// CHECK: [[SCOPE]] = !DICompositeType(tag: DW_TAG_structure_type
+// CHECK-SAME: name: "Struct1<Struct3>"
+// CHECK: [[ELEMENTS]] = !{[[ELEMENT:![0-9]+]]}
+// CHECK: [[ELEMENT]] = !DIEnumerator(name: "enumValue1"
+
+template <typename> struct Struct1 {
+ enum { enumValue1 };
+ Struct1();
+};
+void function2() {
+ struct Struct3 {};
+ int i = Struct1<Struct3>::enumValue1;
+}
+void function3() {
+ struct Struct3 {};
+ int i = Struct1<Struct3>::enumValue1;
+}
Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -84,7 +84,9 @@
}
if (!AllEnumTypes.empty())
- CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));
+ CUNode->replaceEnumTypes(MDTuple::get(
+ VMContext, SmallVector<Metadata *, 16>(AllEnumTypes.begin(),
+ AllEnumTypes.end())));
SmallVector<Metadata *, 16> RetainValues;
// Declarations and definitions of the same type may be retained. Some
@@ -556,7 +558,7 @@
getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0, nullptr,
nullptr, UniqueIdentifier);
- AllEnumTypes.push_back(CTy);
+ AllEnumTypes.emplace_back(CTy);
trackIfUnresolved(CTy);
return CTy;
}
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -48,7 +48,7 @@
Function *LabelFn; ///< llvm.dbg.label
Function *AddrFn; ///< llvm.dbg.addr
- SmallVector<Metadata *, 4> AllEnumTypes;
+ SmallVector<TrackingMDNodeRef, 4> AllEnumTypes;
/// Track the RetainTypes, since they can be updated later on.
SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
SmallVector<Metadata *, 4> AllSubprograms;
Index: clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s
+
+// Test that clang doesn't crash while resolving temporary debug metadata of
+// a record with collisions in the record's enum users.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME: scope: [[SCOPE:![0-9]+]]
+// CHECK-SAME: elements: [[ELEMENTS:![0-9]+]]
+// CHECK: [[SCOPE]] = !DICompositeType(tag: DW_TAG_structure_type
+// CHECK-SAME: name: "Struct1<Struct3>"
+// CHECK: [[ELEMENTS]] = !{[[ELEMENT:![0-9]+]]}
+// CHECK: [[ELEMENT]] = !DIEnumerator(name: "enumValue1"
+
+template <typename> struct Struct1 {
+ enum { enumValue1 };
+ Struct1();
+};
+void function2() {
+ struct Struct3 {};
+ int i = Struct1<Struct3>::enumValue1;
+}
+void function3() {
+ struct Struct3 {};
+ int i = Struct1<Struct3>::enumValue1;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits