Commit e306254f authored by Roberto Raggi's avatar Roberto Raggi

Fixed the ranges for the scope regions and process ConditionAST nodes

parent b3764bed
...@@ -1178,7 +1178,7 @@ bool Bind::visit(ExpressionStatementAST *ast) ...@@ -1178,7 +1178,7 @@ bool Bind::visit(ExpressionStatementAST *ast)
bool Bind::visit(ForeachStatementAST *ast) bool Bind::visit(ForeachStatementAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1210,7 +1210,7 @@ bool Bind::visit(ForeachStatementAST *ast) ...@@ -1210,7 +1210,7 @@ bool Bind::visit(ForeachStatementAST *ast)
bool Bind::visit(ForStatementAST *ast) bool Bind::visit(ForStatementAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1230,7 +1230,7 @@ bool Bind::visit(ForStatementAST *ast) ...@@ -1230,7 +1230,7 @@ bool Bind::visit(ForStatementAST *ast)
bool Bind::visit(IfStatementAST *ast) bool Bind::visit(IfStatementAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1286,7 +1286,7 @@ bool Bind::visit(ReturnStatementAST *ast) ...@@ -1286,7 +1286,7 @@ bool Bind::visit(ReturnStatementAST *ast)
bool Bind::visit(SwitchStatementAST *ast) bool Bind::visit(SwitchStatementAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1312,7 +1312,7 @@ bool Bind::visit(TryBlockStatementAST *ast) ...@@ -1312,7 +1312,7 @@ bool Bind::visit(TryBlockStatementAST *ast)
bool Bind::visit(CatchClauseAST *ast) bool Bind::visit(CatchClauseAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1329,7 +1329,7 @@ bool Bind::visit(CatchClauseAST *ast) ...@@ -1329,7 +1329,7 @@ bool Bind::visit(CatchClauseAST *ast)
bool Bind::visit(WhileStatementAST *ast) bool Bind::visit(WhileStatementAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1345,7 +1345,7 @@ bool Bind::visit(WhileStatementAST *ast) ...@@ -1345,7 +1345,7 @@ bool Bind::visit(WhileStatementAST *ast)
bool Bind::visit(ObjCFastEnumerationAST *ast) bool Bind::visit(ObjCFastEnumerationAST *ast)
{ {
Block *block = control()->newBlock(ast->firstToken()); Block *block = control()->newBlock(ast->firstToken());
const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); const unsigned startScopeToken = ast->lparen_token ? ast->lparen_token : ast->firstToken();
block->setStartOffset(tokenAt(startScopeToken).end()); block->setStartOffset(tokenAt(startScopeToken).end());
block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
_scope->addMember(block); _scope->addMember(block);
...@@ -1444,6 +1444,14 @@ bool Bind::visit(ConditionAST *ast) ...@@ -1444,6 +1444,14 @@ bool Bind::visit(ConditionAST *ast)
} }
DeclaratorIdAST *declaratorId = 0; DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId); type = this->declarator(ast->declarator, type, &declaratorId);
if (declaratorId && declaratorId->name) {
unsigned sourceLocation = declaratorId->name->firstToken();
Declaration *decl = control()->newDeclaration(sourceLocation, declaratorId->name->name);
decl->setType(type);
_scope->addMember(decl);
}
return false; return false;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment