diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-02 23:06:43 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-02 23:06:43 +0000 |
commit | a8afb2a623b8644f9460be66d99c073579e23df0 (patch) | |
tree | b34dcf631e9bd50e823b7ee02fe7de03bfca1922 | |
parent | 5b164b5a5cab577fdfc21b22b78b3207dbcfbcf1 (diff) | |
download | external_llvm-a8afb2a623b8644f9460be66d99c073579e23df0.zip external_llvm-a8afb2a623b8644f9460be66d99c073579e23df0.tar.gz external_llvm-a8afb2a623b8644f9460be66d99c073579e23df0.tar.bz2 |
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
-rw-r--r-- | lib/Analysis/Lint.cpp | 3 | ||||
-rw-r--r-- | test/Other/lint.ll | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp index 949bbbd..5624430 100644 --- a/lib/Analysis/Lint.cpp +++ b/lib/Analysis/Lint.cpp @@ -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) { diff --git a/test/Other/lint.ll b/test/Other/lint.ll index dee3d11..fcef7ee 100644 --- a/test/Other/lint.ll +++ b/test/Other/lint.ll @@ -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, [] } |