Commit 5ceea60c authored by Roberto Raggi's avatar Roberto Raggi

SimpleDeclarationAST::lastToken().

parent 43bdddec
...@@ -2184,7 +2184,6 @@ unsigned ReferenceAST::firstToken() const ...@@ -2184,7 +2184,6 @@ unsigned ReferenceAST::firstToken() const
unsigned ReferenceAST::lastToken() const unsigned ReferenceAST::lastToken() const
{ {
assert(0 && "review me");
return amp_token + 1; return amp_token + 1;
} }
...@@ -2202,8 +2201,11 @@ unsigned ReturnStatementAST::firstToken() const ...@@ -2202,8 +2201,11 @@ unsigned ReturnStatementAST::firstToken() const
unsigned ReturnStatementAST::lastToken() const unsigned ReturnStatementAST::lastToken() const
{ {
assert(0 && "review me"); if (semicolon_token)
return semicolon_token + 1; return semicolon_token + 1;
else if (expression)
return expression->lastToken();
return return_token + 1;
} }
void SimpleDeclarationAST::accept0(ASTVisitor *visitor) void SimpleDeclarationAST::accept0(ASTVisitor *visitor)
...@@ -2222,23 +2224,24 @@ unsigned SimpleDeclarationAST::firstToken() const ...@@ -2222,23 +2224,24 @@ unsigned SimpleDeclarationAST::firstToken() const
return decl_specifier_seq->firstToken(); return decl_specifier_seq->firstToken();
else if (declarators) else if (declarators)
return declarators->firstToken(); return declarators->firstToken();
else return semicolon_token;
return semicolon_token;
} }
unsigned SimpleDeclarationAST::lastToken() const unsigned SimpleDeclarationAST::lastToken() const
{ {
assert(0 && "review me");
if (semicolon_token) if (semicolon_token)
return semicolon_token + 1; return semicolon_token + 1;
for (DeclaratorListAST *it = declarators; it; it = it->next) { for (DeclaratorListAST *it = declarators; it; it = it->next) {
if (! it->next) if (! it->next)
return it->lastToken(); return it->lastToken();
} }
for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) { for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) {
if (! it->next) if (! it->next)
return it->lastToken(); return it->lastToken();
} }
return 0; return 0;
} }
......
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