Skip to content

Commit 2dc5682

Browse files
committed
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: 504dd57
1 parent 1c3c655 commit 2dc5682

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,8 @@ void Verifier::visitDICompositeType(const DICompositeType &N) {
13191319
unsigned DIBlockByRefStruct = 1 << 4;
13201320
CheckDI((N.getFlags() & DIBlockByRefStruct) == 0,
13211321
"DIBlockByRefStruct on DICompositeType is no longer supported", &N);
1322+
CheckDI(llvm::all_of(N.getElements(), [](const DINode *N) { return N; }),
1323+
"DISubprogram contains null entry in `elements` field", &N);
13221324

13231325
if (N.isVector()) {
13241326
const DINodeArray Elements = N.getElements();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
; RUN: not opt -S < %s 2>&1 | FileCheck %s
2+
3+
!named = !{!0}
4+
; CHECK: DISubprogram contains null entry in `elements` field
5+
!0 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", elements: !1)
6+
!1 = !{null}

0 commit comments

Comments
 (0)