Add a lint check for indirectbr with no successors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110074 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-08-02 23:06:43 +00:00
parent 5b164b5a5c
commit a8afb2a623
2 changed files with 6 additions and 1 deletions

View File

@ -519,6 +519,9 @@ void Lint::visitVAArgInst(VAArgInst &I) {
void Lint::visitIndirectBrInst(IndirectBrInst &I) {
visitMemoryReference(I, I.getAddress(), ~0u, 0, 0, MemRef::Branchee);
Assert1(I.getNumDestinations() != 0,
"Undefined behavior: indirectbr with no destinations", &I);
}
void Lint::visitExtractElementInst(ExtractElementInst &I) {

View File

@ -161,5 +161,7 @@ declare i32 @nonstruct_callee() nounwind
define void @struct_caller() nounwind {
entry:
call %struct bitcast (i32 ()* @foo to %struct ()*)()
ret void
; CHECK: Undefined behavior: indirectbr with no destinations
indirectbr i8* null, []
}