forked from qt-creator/qt-creator
Cleanup Catch clause
This commit is contained in:
@@ -1616,12 +1616,10 @@ unsigned TryBlockStatementAST::firstToken() const
|
||||
|
||||
unsigned TryBlockStatementAST::lastToken() const
|
||||
{
|
||||
for (CatchClauseAST *it = catch_clause_seq; it; it = it->next) {
|
||||
if (! it->next)
|
||||
return it->lastToken();
|
||||
}
|
||||
if (catch_clause_list)
|
||||
return catch_clause_list->lastToken();
|
||||
|
||||
if (statement)
|
||||
else if (statement)
|
||||
return statement->lastToken();
|
||||
|
||||
return try_token + 1;
|
||||
|
||||
@@ -1899,7 +1899,7 @@ class CPLUSPLUS_EXPORT TryBlockStatementAST: public StatementAST
|
||||
public:
|
||||
unsigned try_token;
|
||||
StatementAST *statement;
|
||||
CatchClauseAST *catch_clause_seq;
|
||||
CatchClauseListAST *catch_clause_list;
|
||||
|
||||
public:
|
||||
virtual TryBlockStatementAST *asTryBlockStatement() { return this; }
|
||||
@@ -1919,7 +1919,6 @@ public:
|
||||
ExceptionDeclarationAST *exception_declaration;
|
||||
unsigned rparen_token;
|
||||
StatementAST *statement;
|
||||
CatchClauseAST *next;
|
||||
|
||||
public: // annotations
|
||||
Block *symbol;
|
||||
|
||||
@@ -804,8 +804,7 @@ void TryBlockStatementAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(statement, visitor);
|
||||
for (CatchClauseAST *it = catch_clause_seq; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
accept(catch_clause_list, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ typedef List<PostfixAST *> PostfixListAST;
|
||||
typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
|
||||
typedef List<AttributeAST *> AttributeListAST;
|
||||
typedef List<NestedNameSpecifierAST *> NestedNameSpecifierListAST;
|
||||
typedef List<CatchClauseAST *> CatchClauseListAST;
|
||||
|
||||
typedef List<NameAST *> ObjCIdentifierListAST;
|
||||
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
|
||||
|
||||
@@ -273,8 +273,8 @@ bool CheckStatement::visit(SwitchStatementAST *ast)
|
||||
bool CheckStatement::visit(TryBlockStatementAST *ast)
|
||||
{
|
||||
semantic()->check(ast->statement, _scope);
|
||||
for (CatchClauseAST *c = ast->catch_clause_seq; c; c = c->next) {
|
||||
semantic()->check(c, _scope);
|
||||
for (CatchClauseListAST *it = ast->catch_clause_list; it; it = it->next) {
|
||||
semantic()->check(it->value, _scope);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2949,7 +2949,7 @@ bool Parser::parseTryBlockStatement(StatementAST *&node)
|
||||
TryBlockStatementAST *ast = new (_pool) TryBlockStatementAST;
|
||||
ast->try_token = consumeToken();
|
||||
parseCompoundStatement(ast->statement);
|
||||
CatchClauseAST **catch_clause_ptr = &ast->catch_clause_seq;
|
||||
CatchClauseListAST **catch_clause_ptr = &ast->catch_clause_list;
|
||||
while (parseCatchClause(*catch_clause_ptr))
|
||||
catch_clause_ptr = &(*catch_clause_ptr)->next;
|
||||
node = ast;
|
||||
@@ -2958,7 +2958,7 @@ bool Parser::parseTryBlockStatement(StatementAST *&node)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Parser::parseCatchClause(CatchClauseAST *&node)
|
||||
bool Parser::parseCatchClause(CatchClauseListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() == T_CATCH) {
|
||||
@@ -2968,7 +2968,7 @@ bool Parser::parseCatchClause(CatchClauseAST *&node)
|
||||
parseExceptionDeclaration(ast->exception_declaration);
|
||||
match(T_RPAREN, &ast->rparen_token);
|
||||
parseCompoundStatement(ast->statement);
|
||||
node = ast;
|
||||
node = new (_pool) CatchClauseListAST(ast);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
bool parseTemplateParameterList(DeclarationListAST *&node);
|
||||
bool parseThrowExpression(ExpressionAST *&node);
|
||||
bool parseTryBlockStatement(StatementAST *&node);
|
||||
bool parseCatchClause(CatchClauseAST *&node);
|
||||
bool parseCatchClause(CatchClauseListAST *&node);
|
||||
bool parseTypeId(ExpressionAST *&node);
|
||||
bool parseTypeIdList(ExpressionListAST *&node);
|
||||
bool parseTypenameTypeParameter(DeclarationAST *&node);
|
||||
|
||||
Reference in New Issue
Block a user