[llvm-commits] [llvm] r110074 - in /llvm/trunk: lib/Analysis/Lint.cpp test/Other/lint.ll

Dan Gohman gohman at apple.com
Mon Aug 2 16:06:43 PDT 2010


Author: djg
Date: Mon Aug  2 18:06:43 2010
New Revision: 110074

URL: http://llvm.org/viewvc/llvm-project?rev=110074&view=rev
Log:
Add a lint check for indirectbr with no successors.

Modified:
    llvm/trunk/lib/Analysis/Lint.cpp
    llvm/trunk/test/Other/lint.ll

Modified: llvm/trunk/lib/Analysis/Lint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=110074&r1=110073&r2=110074&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Lint.cpp (original)
+++ llvm/trunk/lib/Analysis/Lint.cpp Mon Aug  2 18:06:43 2010
@@ -519,6 +519,9 @@
 
 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) {

Modified: llvm/trunk/test/Other/lint.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/lint.ll?rev=110074&r1=110073&r2=110074&view=diff
==============================================================================
--- llvm/trunk/test/Other/lint.ll (original)
+++ llvm/trunk/test/Other/lint.ll Mon Aug  2 18:06:43 2010
@@ -161,5 +161,7 @@
 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, []
 }





More information about the llvm-commits mailing list