Fix crash when printing instructions that have a metadata attached but no parent.
authorMehdi Amini <mehdi.amini@apple.com>
Thu, 7 Jan 2016 20:14:30 +0000 (20:14 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Thu, 7 Jan 2016 20:14:30 +0000 (20:14 +0000)
commitf45267526ead95cb8aba903f97c03e031e069bd0
treecc3347b08b4148aaaa1be206e9fa0a0dea00260a
parent3acdbad84f77f69b90e2f4da07289469cff178bd
Fix crash when printing instructions that have a metadata attached but no parent.

Fix PR24852 (crash with -debug -instcombine)

Patch by Than McIntosh <thanm@google.com>

Summary:
Add guards to the asm writer to prevent crashing
when dumping an instruction that has no basic
block.

Differential Revision: http://reviews.llvm.org/D15798

From: Than McIntosh <thanm@google.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257094 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/AsmWriter.cpp
unittests/IR/AsmWriterTest.cpp [new file with mode: 0644]
unittests/IR/CMakeLists.txt