diff options
| author | Joseph Tremoulet <jotrem@microsoft.com> | 2016-01-02 15:25:25 +0000 |
|---|---|---|
| committer | Joseph Tremoulet <jotrem@microsoft.com> | 2016-01-02 15:25:25 +0000 |
| commit | 131a462690f0cfcd8c01858ab9647128ccab9111 (patch) | |
| tree | a61c33c431d1e7dc3563196d18f56a5555dd2971 /llvm | |
| parent | 06125e52a7de61fcac60f2900aa4c58652dfa552 (diff) | |
| download | bcm5719-llvm-131a462690f0cfcd8c01858ab9647128ccab9111.tar.gz bcm5719-llvm-131a462690f0cfcd8c01858ab9647128ccab9111.zip | |
[WinEH] Verify catchswitch handlers
Summary:
The handler list must be nonempty and consist solely of CatchPads.
Reviewers: rnk, andrew.w.kaylor, majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15842
llvm-svn: 256691
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/Verifier/invalid-eh.ll | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index a7a291dbf9d..20ae82905a8 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3079,6 +3079,13 @@ void Verifier::visitCatchSwitchInst(CatchSwitchInst &CatchSwitch) { Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad), "CatchSwitchInst has an invalid parent.", ParentPad); + Assert(CatchSwitch.getNumHandlers() != 0, + "CatchSwitchInst cannot have empty handler list", &CatchSwitch); + + for (BasicBlock *Handler : CatchSwitch.handlers()) + Assert(isa<CatchPadInst>(Handler->getFirstNonPHI()), + "CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler); + visitTerminatorInst(CatchSwitch); } diff --git a/llvm/test/Verifier/invalid-eh.ll b/llvm/test/Verifier/invalid-eh.ll index aae9b1ae2fd..21e88d4dcb3 100644 --- a/llvm/test/Verifier/invalid-eh.ll +++ b/llvm/test/Verifier/invalid-eh.ll @@ -5,6 +5,7 @@ ; RUN: sed -e s/.T5:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s ; RUN: sed -e s/.T6:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK6 %s ; RUN: sed -e s/.T7:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK7 %s +; RUN: sed -e s/.T8:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK8 %s declare void @g() @@ -87,3 +88,11 @@ declare void @g() ;T7: catchpad within %cs2 [] ;T7: unreachable ;T7: } + +;T8: define void @f() personality void ()* @g { +;T8: entry: +;T8: ret void +;T8: switch1: +;T8: %cs1 = catchswitch within none [ label %switch1 ] unwind to caller +;T8: ; CHECK8: CatchSwitchInst handlers must be catchpads +;T8: } |

