logic: guessing type of callee node to be function.

This commit is contained in:
malte_langkabel
2016-12-15 16:20:39 +01:00
parent 157e78a84b
commit 4194381d5f
5 changed files with 53 additions and 17 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ ParseLocation::ParseLocation()
}
ParseLocation::ParseLocation(
const std::string& filePath,
const FilePath& filePath,
uint lineNumber,
uint columnNumber
)
@@ -27,7 +27,7 @@ ParseLocation::ParseLocation(
}
ParseLocation::ParseLocation(
const std::string& filePath,
const FilePath& filePath,
uint startLineNumber, uint startColumnNumber,
uint endLineNumber, uint endColumnNumber
)
+2 -2
View File
@@ -10,12 +10,12 @@ struct ParseLocation
{
ParseLocation();
ParseLocation(
const std::string& filePath,
const FilePath& filePath,
uint lineNumber,
uint columnNumber
);
ParseLocation(
const std::string& filePath,
const FilePath& filePath,
uint startLineNumber, uint startColumnNumber,
uint endLineNumber, uint endColumnNumber
);
@@ -169,9 +169,13 @@ void CxxAstVisitorComponentIndexer::visitFunctionDecl(clang::FunctionDecl* d)
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(
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),
getParseLocation(d->getLocation())
);
@@ -184,12 +188,16 @@ void CxxAstVisitorComponentIndexer::visitCXXMethodDecl(clang::CXXMethodDecl* d)
// Decl has been recorded in VisitFunctionDecl
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++)
{
const NameHierarchy referencedName = getAstVisitor()->getDeclNameCache()->getValue(*it);
m_client->recordSymbol(referencedName, SYMBOL_FUNCTION, ACCESS_NONE, DEFINITION_NONE);
m_client->recordReference(
REFERENCE_OVERRIDE,
getAstVisitor()->getDeclNameCache()->getValue(*it),
referencedName,
getAstVisitor()->getDeclNameCache()->getValue(d),
getParseLocation(d->getLocation())
);
@@ -201,9 +209,13 @@ void CxxAstVisitorComponentIndexer::visitCXXMethodDecl(clang::CXXMethodDecl* d)
clang::NamedDecl* specializedNamedDecl = memberSpecializationInfo->getInstantiatedFrom();
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(
REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF,
getAstVisitor()->getDeclNameCache()->getValue(specializedNamedDecl),
referencedName,
getAstVisitor()->getDeclNameCache()->getValue(d),
getParseLocation(d->getLocation())
);
@@ -402,9 +414,17 @@ void CxxAstVisitorComponentIndexer::visitDeclRefExpr(clang::DeclRefExpr* s)
}
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(
consumeDeclRefContextKind(),
getAstVisitor()->getDeclNameCache()->getValue(s->getDecl()),
refKind,
referencedName,
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
getParseLocation(s->getLocation())
);
@@ -416,9 +436,17 @@ void CxxAstVisitorComponentIndexer::visitMemberExpr(clang::MemberExpr* s)
{
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(
consumeDeclRefContextKind(),
getAstVisitor()->getDeclNameCache()->getValue(s->getMemberDecl()),
refKind,
referencedName,
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
getParseLocation(s->getMemberLoc())
);
@@ -472,9 +500,17 @@ void CxxAstVisitorComponentIndexer::visitCXXConstructExpr(clang::CXXConstructExp
}
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(
consumeDeclRefContextKind(),
getAstVisitor()->getDeclNameCache()->getValue(s->getConstructor()),
refKind,
referencedName,
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(),
getParseLocation(loc)
);
@@ -157,7 +157,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token& macroN
const clang::SourceLocation& endLocation = m_sourceManager.getSpellingLoc(macroNameTok.getEndLoc());
return ParseLocation(
m_sourceManager.getFilename(location),
m_sourceManager.getFilename(location).str(),
m_sourceManager.getSpellingLineNumber(location),
m_sourceManager.getSpellingColumnNumber(location),
m_sourceManager.getSpellingLineNumber(endLocation),
@@ -171,7 +171,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::MacroInfo* ma
clang::SourceLocation endLocation = macroInfo->getDefinitionEndLoc();
return ParseLocation(
m_sourceManager.getFilename(location),
m_sourceManager.getFilename(location).str(),
m_sourceManager.getSpellingLineNumber(location),
m_sourceManager.getSpellingColumnNumber(location),
m_sourceManager.getSpellingLineNumber(endLocation),
+1 -1
View File
@@ -3308,7 +3308,7 @@ public:
TS_ASSERT_EQUALS(client.classes.size(), 4);
TS_ASSERT_EQUALS(client.enums.size(), 1);
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.globalVariables.size(), 2);
TS_ASSERT_EQUALS(client.methods.size(), 15);