data: don't parse lambda calls to avoid subnodes within functions

This commit is contained in:
Eberhard Graether
2015-11-06 14:50:25 +01:00
parent 50bc970c30
commit 372f262204
6 changed files with 73 additions and 327 deletions
@@ -19,7 +19,7 @@ public:
template <template<class, class> class ContainerType>
static ContainerType<Range, std::allocator<Range>> mergeAdjacent(ContainerType<Range, std::allocator<Range>> ranges, int rowDifference = 1)
{
for (size_t i = 0; i < ranges.size() - 1; i++)
for (size_t i = 0; i + 1 < ranges.size(); i++)
{
const Range first = ranges[i];
const Range second = ranges[i + 1];
+23 -4
View File
@@ -1,5 +1,7 @@
#include "data/parser/cxx/ASTBodyVisitor.h"
#include "clang/AST/DeclCXX.h"
ASTBodyVisitor::ASTBodyVisitor(ASTBodyVisitorClient* client, clang::FunctionDecl* functionDecl)
: m_client(client)
, m_functionDecl(functionDecl)
@@ -36,13 +38,30 @@ void ASTBodyVisitor::VisitChildren(clang::Stmt* stmt)
void ASTBodyVisitor::VisitCallExpr(clang::CallExpr* expr)
{
if (m_functionDecl)
bool ignore = false;
// check if lambda call
if (clang::isa<clang::CXXOperatorCallExpr>(expr))
{
m_client->VisitCallExprInDeclBody(m_functionDecl, expr);
clang::Decl* calleeDecl = expr->getCalleeDecl();
if (clang::isa<clang::CXXMethodDecl>(calleeDecl))
{
clang::CXXRecordDecl* recordDecl = clang::dyn_cast<clang::CXXMethodDecl>(calleeDecl)->getParent();
ignore = recordDecl->isLambda();
}
}
else
if (!ignore)
{
m_client->VisitCallExprInDeclBody(m_varDecl, expr);
if (m_functionDecl)
{
m_client->VisitCallExprInDeclBody(m_functionDecl, expr);
}
else
{
m_client->VisitCallExprInDeclBody(m_varDecl, expr);
}
}
VisitStmt(expr);
-14
View File
@@ -543,20 +543,6 @@ bool ASTVisitor::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl *declarat
void ASTVisitor::VisitCallExprInDeclBody(clang::FunctionDecl* decl, clang::CallExpr* expr)
{
// if (clang::FunctionDecl *CalleeDecl = CE->getDirectCallee())
// {
// return CalleeDecl;
// }
// clang::Expr *CEE = CE->getCallee()->IgnoreParenImpCasts();
// if (clang::BlockExpr *Block = clang::dyn_cast<clang::BlockExpr>(CEE))
// {
// NumBlockCallEdges++;
// return Block->getBlockDecl();
// }
// return nullptr;
if (!expr->getDirectCallee())
{
// TODO: Save error at location.