summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2016-07-21 22:31:40 +0000
committerErik Pilkington <erik.pilkington@gmail.com>2016-07-21 22:31:40 +0000
commit1ac8adfcab5e109c408bb01a8f0ed6908c67c1d7 (patch)
tree85c008d3bddbccbeaabafd9f5c5f953271fc37c6 /clang/lib
parent1cf58f89965d1f684843e1c9629836b8c011daa3 (diff)
downloadbcm5719-llvm-1ac8adfcab5e109c408bb01a8f0ed6908c67c1d7.tar.gz
bcm5719-llvm-1ac8adfcab5e109c408bb01a8f0ed6908c67c1d7.zip
[CodeGen] Fix a crash when constant folding switch statement
Differential revision: https://reviews.llvm.org/D22542 llvm-svn: 276350
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index a7fa60f73ad..31f19829d92 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1264,6 +1264,14 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
}
void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
+ // If there is no enclosing switch instance that we're aware of, then this
+ // default statement can be elided. This situation only happens when we've
+ // constant-folded the switch.
+ if (!SwitchInsn) {
+ EmitStmt(S.getSubStmt());
+ return;
+ }
+
llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
assert(DefaultBlock->empty() &&
"EmitDefaultStmt: Default block already defined?");
OpenPOWER on IntegriCloud