Verifier: Add check for DICompositeType elements being null
Came up recently with some nodebug case on codeview, that caused a null
entry in elements and crashed LLVM.
Original clang fix to avoid generating IR like this: 504dd57767
This commit is contained in:
@@ -1319,6 +1319,8 @@ void Verifier::visitDICompositeType(const DICompositeType &N) {
|
||||
unsigned DIBlockByRefStruct = 1 << 4;
|
||||
CheckDI((N.getFlags() & DIBlockByRefStruct) == 0,
|
||||
"DIBlockByRefStruct on DICompositeType is no longer supported", &N);
|
||||
CheckDI(llvm::all_of(N.getElements(), [](const DINode *N) { return N; }),
|
||||
"DISubprogram contains null entry in `elements` field", &N);
|
||||
|
||||
if (N.isVector()) {
|
||||
const DINodeArray Elements = N.getElements();
|
||||
|
||||
6
llvm/test/Verifier/dicompositetype-elements-null.ll
Normal file
6
llvm/test/Verifier/dicompositetype-elements-null.ll
Normal file
@@ -0,0 +1,6 @@
|
||||
; RUN: not opt -S < %s 2>&1 | FileCheck %s
|
||||
|
||||
!named = !{!0}
|
||||
; CHECK: DISubprogram contains null entry in `elements` field
|
||||
!0 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", elements: !1)
|
||||
!1 = !{null}
|
||||
Reference in New Issue
Block a user