Add 'throw' to the flow control statements list for simplification of dead code.

This commit is contained in:
Edoardo Prezioso 2011-12-03 01:58:26 +01:00
parent 42a557432d
commit 00bae586e9
3 changed files with 4 additions and 5 deletions

View File

@ -4504,8 +4504,8 @@ void Tokenizer::simplifyFlowControl()
}
eraseDeadCode(tok, beginindent->link());
} else if (tok->str() == "return") {
//catch the first ';' after the return
} else if (tok->str() == "return" || tok->str() == "throw") {
//catch the first ';' after the return|trow statement
for (Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
if (tok2->str() == "(" || tok2->str() == "[") {
tok2 = tok2->link();

View File

@ -372,7 +372,7 @@ public:
void simplifyGoto();
/** Simplify redundant code placed after control flow statements :
* 'return', 'goto', 'break' and 'continue'
* 'return', 'throw', 'goto', 'break' and 'continue'
*/
void simplifyFlowControl();

View File

@ -3085,8 +3085,7 @@ private:
void flowControl() {
std::list<std::string> beforedead;
beforedead.push_back("return");
beforedead.push_back("return 0");
beforedead.push_back("return -1");
beforedead.push_back("throw ( 10 )");
beforedead.push_back("goto labels");
beforedead.push_back("break");
beforedead.push_back("continue");