logic: implemented recording references to symbols inside lambda capture lists
This commit is contained in:
@@ -310,7 +310,33 @@ bool CxxAstVisitor::TraverseTemplateArgumentLoc(const clang::TemplateArgumentLoc
|
||||
return base::TraverseTemplateArgumentLoc(loc);
|
||||
}
|
||||
|
||||
void CxxAstVisitor::traverseDeclContextHelper(clang::DeclContext *d)
|
||||
bool CxxAstVisitor::TraverseLambdaCapture(clang::LambdaExpr *lambdaExpr, const clang::LambdaCapture *capture)
|
||||
{
|
||||
clang::VarDecl* d = capture->getCapturedVar();
|
||||
if (lambdaExpr->isInitCapture(capture))
|
||||
{
|
||||
TraverseDecl(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
SymbolKind symbolKind = getSymbolKind(d);
|
||||
if (symbolKind == SYMBOL_LOCAL_VARIABLE || symbolKind == SYMBOL_PARAMETER)
|
||||
{
|
||||
if (!d->getNameAsString().empty()) // don't record anonymous parameters
|
||||
{
|
||||
ParseLocation declLocation = getParseLocation(d->getLocation());
|
||||
std::string name =
|
||||
declLocation.filePath.fileName() + "<" +
|
||||
std::to_string(declLocation.startLineNumber) + ":" +
|
||||
std::to_string(declLocation.startColumnNumber) + ">";
|
||||
m_client->onLocalSymbolParsed(name, getParseLocation(capture->getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CxxAstVisitor::traverseDeclContextHelper(clang::DeclContext* d)
|
||||
{
|
||||
if (!d)
|
||||
return;
|
||||
@@ -444,28 +470,7 @@ bool CxxAstVisitor::VisitVarDecl(clang::VarDecl* d)
|
||||
{
|
||||
if (shouldVisitDecl(d))
|
||||
{
|
||||
SymbolKind symbolKind = SYMBOL_KIND_MAX;
|
||||
|
||||
if (llvm::isa<clang::ParmVarDecl>(d))
|
||||
{
|
||||
symbolKind = SYMBOL_PARAMETER;
|
||||
}
|
||||
else if (d->getParentFunctionOrMethod() == NULL)
|
||||
{
|
||||
if (d->getAccess() == clang::AS_none)
|
||||
{
|
||||
symbolKind = SYMBOL_GLOBAL_VARIABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolKind = SYMBOL_FIELD;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolKind = SYMBOL_LOCAL_VARIABLE;
|
||||
}
|
||||
|
||||
SymbolKind symbolKind = getSymbolKind(d);
|
||||
if (symbolKind == SYMBOL_LOCAL_VARIABLE || symbolKind == SYMBOL_PARAMETER)
|
||||
{
|
||||
if (!d->getNameAsString().empty()) // don't record anonymous parameters
|
||||
@@ -1225,3 +1230,30 @@ ReferenceKind CxxAstVisitor::consumeDeclRefContextKind()
|
||||
}
|
||||
return refKind;
|
||||
}
|
||||
|
||||
SymbolKind CxxAstVisitor::getSymbolKind(clang::VarDecl* d)
|
||||
{
|
||||
SymbolKind symbolKind = SYMBOL_KIND_MAX;
|
||||
|
||||
if (llvm::isa<clang::ParmVarDecl>(d))
|
||||
{
|
||||
symbolKind = SYMBOL_PARAMETER;
|
||||
}
|
||||
else if (d->getParentFunctionOrMethod() == NULL)
|
||||
{
|
||||
if (d->getAccess() == clang::AS_none)
|
||||
{
|
||||
symbolKind = SYMBOL_GLOBAL_VARIABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolKind = SYMBOL_FIELD;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolKind = SYMBOL_LOCAL_VARIABLE;
|
||||
}
|
||||
|
||||
return symbolKind;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ public:
|
||||
virtual bool TraverseTemplateSpecializationTypeLoc(clang::TemplateSpecializationTypeLoc loc);
|
||||
virtual bool TraverseUnresolvedLookupExpr(clang::UnresolvedLookupExpr* s);
|
||||
virtual bool TraverseTemplateArgumentLoc(const clang::TemplateArgumentLoc& loc);
|
||||
void traverseDeclContextHelper(clang::DeclContext *d);
|
||||
virtual bool TraverseLambdaCapture(clang::LambdaExpr* lambdaExpr, const clang::LambdaCapture* capture);
|
||||
void traverseDeclContextHelper(clang::DeclContext* d);
|
||||
bool TraverseCallCommon(clang::CallExpr* s);
|
||||
|
||||
// Visitor methods. These actually record stuff and store it in the database.
|
||||
@@ -129,6 +130,7 @@ protected:
|
||||
|
||||
private:
|
||||
ReferenceKind consumeDeclRefContextKind();
|
||||
SymbolKind getSymbolKind(clang::VarDecl* d);
|
||||
|
||||
typedef clang::RecursiveASTVisitor<CxxAstVisitor> base;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user