C++: Fix off-by-one in scopeAt.

The only Scope that set the end offset to *before* the last token
was ObjCClassDeclaration.

Change-Id: Icbdb5bcdd72d96087ac586ad51510fed74a633eb
Reviewed-on: http://codereview.qt.nokia.com/2820
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
Christian Kamm
2011-08-10 12:16:25 +02:00
parent 476338a6d2
commit 01bb7443fd
2 changed files with 2 additions and 2 deletions

View File

@@ -2296,7 +2296,7 @@ bool Bind::visit(ObjCClassDeclarationAST *ast)
_scope->addMember(klass); _scope->addMember(klass);
klass->setStartOffset(calculateScopeStart(ast)); klass->setStartOffset(calculateScopeStart(ast));
klass->setEndOffset(tokenAt(ast->lastToken() - 1).begin()); klass->setEndOffset(tokenAt(ast->lastToken() - 1).end());
if (ast->interface_token) if (ast->interface_token)
klass->setInterface(true); klass->setInterface(true);

View File

@@ -142,7 +142,7 @@ protected:
unsigned endLine, endColumn; unsigned endLine, endColumn;
_unit->getPosition(scope->endOffset(), &endLine, &endColumn); _unit->getPosition(scope->endOffset(), &endLine, &endColumn);
if (_line < endLine || (_line == endLine && _column <= endColumn)) if (_line < endLine || (_line == endLine && _column < endColumn))
_scope = scope; _scope = scope;
} }
} }