Add a lint check for indirectbr with no successors.
authorDan Gohman <gohman@apple.com>
Mon, 2 Aug 2010 23:06:43 +0000 (23:06 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 2 Aug 2010 23:06:43 +0000 (23:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110074 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/Lint.cpp
test/Other/lint.ll

index 949bbbd8b6c2765b8b20f1b9c136ce31faf47e19..5624430332a37f972b89e316931b920cc88ddeef 100644 (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) {
index dee3d11d2fb5e0543313d493af385d0cd3eb54ba..fcef7ee2d57133779ee1f2134fc8265ed5bf6f2e 100644 (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, []
 }