Mercurial > projects > ldc
comparison gen/statements.cpp @ 395:71a40b62b408
Start a new basic block after a continue statement.
Fixes bug_d_irstate_244_A/b.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 26 Jul 2008 15:00:57 +0200 |
parents | bfb9d28f045a |
children | 0e6b4d65d3f8 |
comparison
equal
deleted
inserted
replaced
391:1d351cd26a5a | 395:71a40b62b408 |
---|---|
444 ScopeStatement* tmp; | 444 ScopeStatement* tmp; |
445 while(tmp = targetLoopStatement->isScopeStatement()) | 445 while(tmp = targetLoopStatement->isScopeStatement()) |
446 targetLoopStatement = tmp->statement; | 446 targetLoopStatement = tmp->statement; |
447 | 447 |
448 // find the right continue block and jump there | 448 // find the right continue block and jump there |
449 bool found = false; | |
449 IRState::LoopScopeVec::reverse_iterator it; | 450 IRState::LoopScopeVec::reverse_iterator it; |
450 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { | 451 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { |
451 if(it->s == targetLoopStatement) { | 452 if(it->s == targetLoopStatement) { |
452 llvm::BranchInst::Create(it->begin, gIR->scopebb()); | 453 llvm::BranchInst::Create(it->begin, gIR->scopebb()); |
453 return; | 454 found = true; |
455 break; | |
454 } | 456 } |
455 } | 457 } |
456 assert(0); | 458 assert(found); |
457 } | 459 } |
458 else { | 460 else { |
459 // can't 'continue' within switch, so omit them | 461 // can't 'continue' within switch, so omit them |
460 IRState::LoopScopeVec::reverse_iterator it; | 462 IRState::LoopScopeVec::reverse_iterator it; |
461 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { | 463 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { |
464 } | 466 } |
465 } | 467 } |
466 DtoEnclosingHandlers(enclosinghandler, it->enclosinghandler); | 468 DtoEnclosingHandlers(enclosinghandler, it->enclosinghandler); |
467 llvm::BranchInst::Create(it->begin, gIR->scopebb()); | 469 llvm::BranchInst::Create(it->begin, gIR->scopebb()); |
468 } | 470 } |
471 | |
472 // the continue terminated this basicblock, start a new one | |
473 llvm::BasicBlock* oldend = gIR->scopeend(); | |
474 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftercontinue", p->topfunc(), oldend); | |
475 p->scope() = IRScope(bb,oldend); | |
469 } | 476 } |
470 | 477 |
471 ////////////////////////////////////////////////////////////////////////////// | 478 ////////////////////////////////////////////////////////////////////////////// |
472 | 479 |
473 void OnScopeStatement::toIR(IRState* p) | 480 void OnScopeStatement::toIR(IRState* p) |