logic: guessing type of callee node to be function.
This commit is contained in:
@@ -10,7 +10,7 @@ ParseLocation::ParseLocation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParseLocation::ParseLocation(
|
ParseLocation::ParseLocation(
|
||||||
const std::string& filePath,
|
const FilePath& filePath,
|
||||||
uint lineNumber,
|
uint lineNumber,
|
||||||
uint columnNumber
|
uint columnNumber
|
||||||
)
|
)
|
||||||
@@ -27,7 +27,7 @@ ParseLocation::ParseLocation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParseLocation::ParseLocation(
|
ParseLocation::ParseLocation(
|
||||||
const std::string& filePath,
|
const FilePath& filePath,
|
||||||
uint startLineNumber, uint startColumnNumber,
|
uint startLineNumber, uint startColumnNumber,
|
||||||
uint endLineNumber, uint endColumnNumber
|
uint endLineNumber, uint endColumnNumber
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ struct ParseLocation
|
|||||||
{
|
{
|
||||||
ParseLocation();
|
ParseLocation();
|
||||||
ParseLocation(
|
ParseLocation(
|
||||||
const std::string& filePath,
|
const FilePath& filePath,
|
||||||
uint lineNumber,
|
uint lineNumber,
|
||||||
uint columnNumber
|
uint columnNumber
|
||||||
);
|
);
|
||||||
ParseLocation(
|
ParseLocation(
|
||||||
const std::string& filePath,
|
const FilePath& filePath,
|
||||||
uint startLineNumber, uint startColumnNumber,
|
uint startLineNumber, uint startColumnNumber,
|
||||||
uint endLineNumber, uint endColumnNumber
|
uint endLineNumber, uint endColumnNumber
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -169,9 +169,13 @@ void CxxAstVisitorComponentIndexer::visitFunctionDecl(clang::FunctionDecl* d)
|
|||||||
|
|
||||||
if (d->isFunctionTemplateSpecialization())
|
if (d->isFunctionTemplateSpecialization())
|
||||||
{
|
{
|
||||||
|
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(d->getPrimaryTemplate()->getTemplatedDecl()); // todo: use context and childcontext!!
|
||||||
|
|
||||||
|
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
|
||||||
|
|
||||||
m_client->recordReference(
|
m_client->recordReference(
|
||||||
REFERENCE_TEMPLATE_SPECIALIZATION_OF, // TODO: call this REFERENCE_TEMPLATE_SPECIALIZATION and reverse the following arguments
|
REFERENCE_TEMPLATE_SPECIALIZATION_OF, // TODO: call this REFERENCE_TEMPLATE_SPECIALIZATION and reverse the following arguments
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(d->getPrimaryTemplate()->getTemplatedDecl()), // todo: use context and childcontext!!
|
referencedName,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(d),
|
getAstVisitor()->getDeclNameCache()->getValue(d),
|
||||||
getParseLocation(d->getLocation())
|
getParseLocation(d->getLocation())
|
||||||
);
|
);
|
||||||
@@ -184,12 +188,16 @@ void CxxAstVisitorComponentIndexer::visitCXXMethodDecl(clang::CXXMethodDecl* d)
|
|||||||
// Decl has been recorded in VisitFunctionDecl
|
// Decl has been recorded in VisitFunctionDecl
|
||||||
if (shouldVisitDecl(d))
|
if (shouldVisitDecl(d))
|
||||||
{
|
{
|
||||||
for (clang::CXXMethodDecl::method_iterator it = d->begin_overridden_methods(); // TODO: iterate in traversal and use RT_Overridden or so..
|
for (clang::CXXMethodDecl::method_iterator it = d->begin_overridden_methods(); // TODO: iterate in traversal and use REFERENCE_OVERRIDE or so..
|
||||||
it != d->end_overridden_methods(); it++)
|
it != d->end_overridden_methods(); it++)
|
||||||
{
|
{
|
||||||
|
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(*it);
|
||||||
|
|
||||||
|
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
|
||||||
|
|
||||||
m_client->recordReference(
|
m_client->recordReference(
|
||||||
REFERENCE_OVERRIDE,
|
REFERENCE_OVERRIDE,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(*it),
|
referencedName,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(d),
|
getAstVisitor()->getDeclNameCache()->getValue(d),
|
||||||
getParseLocation(d->getLocation())
|
getParseLocation(d->getLocation())
|
||||||
);
|
);
|
||||||
@@ -201,9 +209,13 @@ void CxxAstVisitorComponentIndexer::visitCXXMethodDecl(clang::CXXMethodDecl* d)
|
|||||||
clang::NamedDecl* specializedNamedDecl = memberSpecializationInfo->getInstantiatedFrom();
|
clang::NamedDecl* specializedNamedDecl = memberSpecializationInfo->getInstantiatedFrom();
|
||||||
if (clang::isa<clang::FunctionDecl>(specializedNamedDecl))
|
if (clang::isa<clang::FunctionDecl>(specializedNamedDecl))
|
||||||
{
|
{
|
||||||
|
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(specializedNamedDecl);
|
||||||
|
|
||||||
|
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
|
||||||
|
|
||||||
m_client->recordReference(
|
m_client->recordReference(
|
||||||
REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF,
|
REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(specializedNamedDecl),
|
referencedName,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(d),
|
getAstVisitor()->getDeclNameCache()->getValue(d),
|
||||||
getParseLocation(d->getLocation())
|
getParseLocation(d->getLocation())
|
||||||
);
|
);
|
||||||
@@ -402,9 +414,17 @@ void CxxAstVisitorComponentIndexer::visitDeclRefExpr(clang::DeclRefExpr* s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const ReferenceKind refKind = consumeDeclRefContextKind();
|
||||||
|
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(s->getDecl());
|
||||||
|
|
||||||
|
if (refKind == REFERENCE_CALL)
|
||||||
|
{
|
||||||
|
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
m_client->recordReference(
|
m_client->recordReference(
|
||||||
consumeDeclRefContextKind(),
|
refKind,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(s->getDecl()),
|
referencedName,
|
||||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
|
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
|
||||||
getParseLocation(s->getLocation())
|
getParseLocation(s->getLocation())
|
||||||
);
|
);
|
||||||
@@ -416,9 +436,17 @@ void CxxAstVisitorComponentIndexer::visitMemberExpr(clang::MemberExpr* s)
|
|||||||
{
|
{
|
||||||
if (shouldVisitReference(s->getMemberLoc(), getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl()))
|
if (shouldVisitReference(s->getMemberLoc(), getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl()))
|
||||||
{
|
{
|
||||||
|
const ReferenceKind refKind = consumeDeclRefContextKind();
|
||||||
|
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(s->getMemberDecl());
|
||||||
|
|
||||||
|
if (refKind == REFERENCE_CALL)
|
||||||
|
{
|
||||||
|
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
m_client->recordReference(
|
m_client->recordReference(
|
||||||
consumeDeclRefContextKind(),
|
refKind,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(s->getMemberDecl()),
|
referencedName,
|
||||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
|
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
|
||||||
getParseLocation(s->getMemberLoc())
|
getParseLocation(s->getMemberLoc())
|
||||||
);
|
);
|
||||||
@@ -472,9 +500,17 @@ void CxxAstVisitorComponentIndexer::visitCXXConstructExpr(clang::CXXConstructExp
|
|||||||
}
|
}
|
||||||
loc = clang::Lexer::GetBeginningOfToken(loc, m_astContext->getSourceManager(), m_astContext->getLangOpts());
|
loc = clang::Lexer::GetBeginningOfToken(loc, m_astContext->getSourceManager(), m_astContext->getLangOpts());
|
||||||
|
|
||||||
|
const ReferenceKind refKind = consumeDeclRefContextKind();
|
||||||
|
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(s->getConstructor());
|
||||||
|
|
||||||
|
if (refKind == REFERENCE_CALL)
|
||||||
|
{
|
||||||
|
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
m_client->recordReference(
|
m_client->recordReference(
|
||||||
consumeDeclRefContextKind(),
|
refKind,
|
||||||
getAstVisitor()->getDeclNameCache()->getValue(s->getConstructor()),
|
referencedName,
|
||||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
|
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
|
||||||
getParseLocation(loc)
|
getParseLocation(loc)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token& macroN
|
|||||||
const clang::SourceLocation& endLocation = m_sourceManager.getSpellingLoc(macroNameTok.getEndLoc());
|
const clang::SourceLocation& endLocation = m_sourceManager.getSpellingLoc(macroNameTok.getEndLoc());
|
||||||
|
|
||||||
return ParseLocation(
|
return ParseLocation(
|
||||||
m_sourceManager.getFilename(location),
|
m_sourceManager.getFilename(location).str(),
|
||||||
m_sourceManager.getSpellingLineNumber(location),
|
m_sourceManager.getSpellingLineNumber(location),
|
||||||
m_sourceManager.getSpellingColumnNumber(location),
|
m_sourceManager.getSpellingColumnNumber(location),
|
||||||
m_sourceManager.getSpellingLineNumber(endLocation),
|
m_sourceManager.getSpellingLineNumber(endLocation),
|
||||||
@@ -171,7 +171,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::MacroInfo* ma
|
|||||||
clang::SourceLocation endLocation = macroInfo->getDefinitionEndLoc();
|
clang::SourceLocation endLocation = macroInfo->getDefinitionEndLoc();
|
||||||
|
|
||||||
return ParseLocation(
|
return ParseLocation(
|
||||||
m_sourceManager.getFilename(location),
|
m_sourceManager.getFilename(location).str(),
|
||||||
m_sourceManager.getSpellingLineNumber(location),
|
m_sourceManager.getSpellingLineNumber(location),
|
||||||
m_sourceManager.getSpellingColumnNumber(location),
|
m_sourceManager.getSpellingColumnNumber(location),
|
||||||
m_sourceManager.getSpellingLineNumber(endLocation),
|
m_sourceManager.getSpellingLineNumber(endLocation),
|
||||||
|
|||||||
@@ -3308,7 +3308,7 @@ public:
|
|||||||
TS_ASSERT_EQUALS(client.classes.size(), 4);
|
TS_ASSERT_EQUALS(client.classes.size(), 4);
|
||||||
TS_ASSERT_EQUALS(client.enums.size(), 1);
|
TS_ASSERT_EQUALS(client.enums.size(), 1);
|
||||||
TS_ASSERT_EQUALS(client.enumConstants.size(), 2);
|
TS_ASSERT_EQUALS(client.enumConstants.size(), 2);
|
||||||
TS_ASSERT_EQUALS(client.functions.size(), 2);
|
TS_ASSERT_EQUALS(client.functions.size(), 5); // used methods are also recorded as functions (these get overridden in the intermediate storage)
|
||||||
TS_ASSERT_EQUALS(client.fields.size(), 4);
|
TS_ASSERT_EQUALS(client.fields.size(), 4);
|
||||||
TS_ASSERT_EQUALS(client.globalVariables.size(), 2);
|
TS_ASSERT_EQUALS(client.globalVariables.size(), 2);
|
||||||
TS_ASSERT_EQUALS(client.methods.size(), 15);
|
TS_ASSERT_EQUALS(client.methods.size(), 15);
|
||||||
|
|||||||
Reference in New Issue
Block a user