OSDN Git Service

C++: Fix off-by-one in scopeAt.
authorChristian Kamm <christian.d.kamm@nokia.com>
Wed, 10 Aug 2011 10:16:25 +0000 (12:16 +0200)
committerChristian Kamm <christian.d.kamm@nokia.com>
Wed, 10 Aug 2011 12:37:17 +0000 (14:37 +0200)
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>
src/libs/3rdparty/cplusplus/Bind.cpp
src/libs/cplusplus/CppDocument.cpp

index e018b40..16c2ea6 100644 (file)
@@ -2296,7 +2296,7 @@ bool Bind::visit(ObjCClassDeclarationAST *ast)
     _scope->addMember(klass);
 
     klass->setStartOffset(calculateScopeStart(ast));
-    klass->setEndOffset(tokenAt(ast->lastToken() - 1).begin());
+    klass->setEndOffset(tokenAt(ast->lastToken() - 1).end());
 
     if (ast->interface_token)
         klass->setInterface(true);
index c5a714f..4c5fa48 100644 (file)
@@ -142,7 +142,7 @@ protected:
                 unsigned endLine, endColumn;
                 _unit->getPosition(scope->endOffset(), &endLine, &endColumn);
 
-                if (_line < endLine || (_line == endLine && _column <= endColumn))
+                if (_line < endLine || (_line == endLine && _column < endColumn))
                     _scope = scope;
             }
         }