Commit 71b2cbef authored by Christian Kamm's avatar Christian Kamm
Browse files

CDB breakpoints: Fix line adjustment in case statements.

Task-number: QTCREATORBUG-6207
Change-Id: I4df50a412dd960a0d53a824a6c4a93712bd743e8
Reviewed-on: http://codereview.qt-project.org/5964


Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@nokia.com>
parent 3c61cbb5
......@@ -107,12 +107,6 @@ bool FindCdbBreakpoint::visit(QtMemberDeclarationAST *ast)
return false;
}
bool FindCdbBreakpoint::visit(CaseStatementAST *ast)
{
foundLine(ast->lastToken() - 1);
return false;
}
bool FindCdbBreakpoint::visit(CompoundStatementAST *ast)
{
accept(ast->statement_list);
......
......@@ -73,7 +73,6 @@ protected:
// Statements:
bool visit(QtMemberDeclarationAST *ast);
bool visit(CaseStatementAST *ast);
bool visit(CompoundStatementAST *ast);
bool visit(DeclarationStatementAST *ast);
bool visit(DoStatementAST *ast);
......
......@@ -49,6 +49,7 @@ private slots:
void diagnosticClient_warning();
void findBreakpoints();
void findBreakpoints2();
};
void tst_Misc::diagnosticClient_error()
......@@ -101,8 +102,8 @@ void tst_Misc::findBreakpoints()
" {\n" // line 5
" }\n"
" void empty()\n" // line 7
" {\n"
" }\n" // line 9
" {\n" // line 8
" }\n"
" void misc() \n"
" { \n" // line 11
" if ( \n" // line 12
......@@ -138,11 +139,43 @@ void tst_Misc::findBreakpoints()
FindCdbBreakpoint findBreakpoint(doc->translationUnit());
QCOMPARE(findBreakpoint(0), 5U);
QCOMPARE(findBreakpoint(7), 9U);
QCOMPARE(findBreakpoint(7), 8U);
QCOMPARE(findBreakpoint(11), 16U);
QCOMPARE(findBreakpoint(17), 23U);
QCOMPARE(findBreakpoint(18), 23U);
}
void tst_Misc::findBreakpoints2()
{
const QByteArray src("\n" // line 0
"void foo() {\n"
" int a = 2;\n" // line 2
" switch (x) {\n" // line 3
" case 1: {\n" // line 4
" int y = 2;\n" // line 5
" y++;\n"
" break;\n" // line 7
" }\n"
" }\n"
"}\n"
);
Document::Ptr doc = Document::create("findContstructorBreakpoint");
QVERIFY(!doc.isNull());
doc->setSource(src);
bool success = doc->parse();
QVERIFY(success);
QCOMPARE(doc->diagnosticMessages().size(), 0);
FindCdbBreakpoint findBreakpoint(doc->translationUnit());
QCOMPARE(findBreakpoint(0), 2U);
QCOMPARE(findBreakpoint(1), 2U);
QCOMPARE(findBreakpoint(2), 2U);
QCOMPARE(findBreakpoint(3), 3U);
QCOMPARE(findBreakpoint(4), 5U);
QCOMPARE(findBreakpoint(5), 5U);
QCOMPARE(findBreakpoint(6), 6U);
QCOMPARE(findBreakpoint(7), 7U);
}
QTEST_MAIN(tst_Misc)
#include "tst_misc.moc"
Supports Markdown
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