logic: fixed locations in macro

* fixed a bug where the end of source locations contained in a macro was not calculated correctly.
This commit is contained in:
malte_langkabel
2015-12-17 14:14:03 +01:00
parent 32cc49b0fd
commit b6beab8283
5 changed files with 22 additions and 374 deletions
-1
View File
@@ -78,7 +78,6 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
return QObject::eventFilter(obj, event);
}
QtMainWindow::QtMainWindow()
{
setObjectName("QtMainWindow");
+16 -8
View File
@@ -515,7 +515,6 @@ void ASTVisitor::VisitCallExprInDeclBody(clang::DeclaratorDecl* decl, clang::Cal
);
}
void ASTVisitor::VisitDeclRefExprInDeclBody(clang::FunctionDecl* decl, clang::DeclRefExpr* expr)
{
processTemplateArguments(expr);
@@ -529,8 +528,7 @@ void ASTVisitor::VisitDeclRefExprInDeclBody(clang::DeclaratorDecl* decl, clang::
void ASTVisitor::VisitCXXConstructExprInDeclBody(clang::FunctionDecl* decl, clang::CXXConstructExpr* expr)
{
m_client->onCallParsed(
// getParseLocationForTokensInRange(expr->getSourceRange()),
getParseLocation(expr->getSourceRange()),
getParseLocationForTokensInRange(expr->getSourceRange()),
getParseFunction(decl),
getParseFunction(expr->getConstructor())
);
@@ -539,8 +537,7 @@ void ASTVisitor::VisitCXXConstructExprInDeclBody(clang::FunctionDecl* decl, clan
void ASTVisitor::VisitCXXConstructExprInDeclBody(clang::DeclaratorDecl* decl, clang::CXXConstructExpr* expr)
{
m_client->onCallParsed(
// getParseLocationForTokensInRange(expr->getSourceRange()),
getParseLocation(expr->getSourceRange()),
getParseLocationForTokensInRange(expr->getSourceRange()),
getParseVariable(decl),
getParseFunction(expr->getConstructor())
);
@@ -959,14 +956,25 @@ ParseLocation ASTVisitor::getParseLocationForTokensInRange(const clang::SourceRa
clang::SourceLocation endLoc = clang::Lexer::getLocForEndOfToken(range.getEnd(), 1, sourceManager, clang::LangOptions());
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(startLoc);
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(endLoc);
if (endLoc.isValid())
{
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(endLoc);
return ParseLocation(
presumedBegin.getFilename(),
presumedBegin.getLine(),
presumedBegin.getColumn(),
presumedEnd.getLine(),
presumedEnd.getColumn()
);
}
uint tokenLength = clang::Lexer::MeasureTokenLength(range.getEnd(), sourceManager, clang::LangOptions());
return ParseLocation(
presumedBegin.getFilename(),
presumedBegin.getLine(),
presumedBegin.getColumn(),
presumedEnd.getLine(),
presumedEnd.getColumn()
presumedBegin.getLine(),
presumedBegin.getColumn() + tokenLength - 1
);
}
+6 -6
View File
@@ -817,7 +817,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 1);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <8:6 8:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <8:6 8:8>");
}
void test_cxx_parser_finds_constructor_without_definition_call()
@@ -833,7 +833,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 1);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <6:6 6:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <6:6 6:8>");
}
void test_cxx_parser_finds_constructor_call_of_field()
@@ -851,7 +851,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 1);
TS_ASSERT_EQUALS(client->calls[0], "void App::App() -> void Item::Item() <7:2 7:2>");
TS_ASSERT_EQUALS(client->calls[0], "void App::App() -> void Item::Item() <7:2 7:4>");
}
void test_cxx_parser_finds_constructor_call_of_field_in_initialization_list()
@@ -915,7 +915,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 2);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <9:6 9:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <9:6 9:8>");
TS_ASSERT_EQUALS(client->calls[1], "int main() -> void App::App(App const &) <10:6 10:14>");
}
@@ -931,7 +931,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 1);
TS_ASSERT_EQUALS(client->calls[0], "app -> void App::App() <6:5 6:5>");
TS_ASSERT_EQUALS(client->calls[0], "app -> void App::App() <6:5 6:7>");
}
void test_cxx_parser_finds_global_function_call()
@@ -963,7 +963,7 @@ public:
);
TS_ASSERT_EQUALS(client->calls.size(), 2);
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <10:6 10:6>");
TS_ASSERT_EQUALS(client->calls[0], "int main() -> void App::App() <10:6 10:8>");
TS_ASSERT_EQUALS(client->calls[1], "int main() -> void App::operator+(int) <11:2 11:8>");
}