data: implicit in database
* storing the information if a node is defined implicitly in the database * the analysis however does not visit implicit nodes directly. Currently they are just recorded when used somewhere in the code. This should be changed once implicit nodes are hidde in the UI. * removed error logs for unnamed template parameters and function parameters since it is ok when they are anonymous.
This commit is contained in:
@@ -666,6 +666,12 @@ void ASTVisitor::traverseDeclContextHelper(clang::DeclContext *d)
|
||||
// with the "Base-Class" kind.
|
||||
bool ASTVisitor::TraverseCXXRecordDecl(clang::CXXRecordDecl *d)
|
||||
{
|
||||
if (d->isImplicit())
|
||||
{
|
||||
// do nothing
|
||||
return true;
|
||||
}
|
||||
|
||||
// Traverse qualifiers on the record decl.
|
||||
TraverseNestedNameSpecifierLoc(d->getQualifierLoc());
|
||||
|
||||
@@ -1132,7 +1138,7 @@ void ASTVisitor::RecordTypeRef(
|
||||
}
|
||||
}
|
||||
|
||||
bool ASTVisitor::isImpliciit(clang::Decl* d) const
|
||||
bool ASTVisitor::isPartOfImplicitTemplateSpecialization(clang::Decl* d) const
|
||||
{
|
||||
if (!d)
|
||||
{
|
||||
@@ -1146,8 +1152,20 @@ bool ASTVisitor::isImpliciit(clang::Decl* d) const
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (clang::FunctionDecl* fd = clang::dyn_cast_or_null<clang::FunctionDecl>(d))
|
||||
{
|
||||
if (fd->isTemplateInstantiation() && fd->getTemplateSpecializationKind() != clang::TSK_ExplicitSpecialization) // or undefined??
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return isImpliciit(clang::dyn_cast_or_null<clang::Decl>(d->getDeclContext()));
|
||||
return isPartOfImplicitTemplateSpecialization(clang::dyn_cast_or_null<clang::Decl>(d->getDeclContext()));
|
||||
}
|
||||
|
||||
bool ASTVisitor::isImplicit(clang::Decl* d) const
|
||||
{
|
||||
return d->isImplicit() || isPartOfImplicitTemplateSpecialization(d);
|
||||
}
|
||||
|
||||
void ASTVisitor::RecordDeclRef(
|
||||
@@ -1156,11 +1174,11 @@ void ASTVisitor::RecordDeclRef(
|
||||
RefType refType,
|
||||
SymbolType symbolType)
|
||||
{
|
||||
bool isImplicit = isImpliciit(d);
|
||||
bool declIsImplicit = isImplicit(d);
|
||||
|
||||
if (!d ||
|
||||
(isImplicit && !isLocatedInProjectFile(beginLoc)) ||
|
||||
(!isImplicit && !isLocatedInUnparsedProjectFile(beginLoc)))
|
||||
(declIsImplicit && !isLocatedInProjectFile(beginLoc)) ||
|
||||
(!declIsImplicit && !isLocatedInUnparsedProjectFile(beginLoc)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1183,7 +1201,8 @@ void ASTVisitor::RecordDeclRef(
|
||||
m_client->onTypedefParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
convertAccessType(typedefDecl->getAccess()));
|
||||
convertAccessType(typedefDecl->getAccess()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_Class:
|
||||
@@ -1193,7 +1212,8 @@ void ASTVisitor::RecordDeclRef(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
convertAccessType(recordDecl->getAccess()),
|
||||
(refType == RT_Definition ? getParseLocationOfRecordBody(recordDecl) : ParseLocation()));
|
||||
(refType == RT_Definition ? getParseLocationOfRecordBody(recordDecl) : ParseLocation()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_Struct:
|
||||
@@ -1203,13 +1223,15 @@ void ASTVisitor::RecordDeclRef(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
convertAccessType(recordDecl->getAccess()),
|
||||
(refType == RT_Definition ? getParseLocationOfRecordBody(recordDecl) : ParseLocation()));
|
||||
(refType == RT_Definition ? getParseLocationOfRecordBody(recordDecl) : ParseLocation()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_GlobalVariable:
|
||||
m_client->onGlobalVariableParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy);
|
||||
declNameHierarchy,
|
||||
declIsImplicit);
|
||||
break;
|
||||
case ST_Field:
|
||||
//if (clang::VarDecl* varDecl = clang::dyn_cast<clang::VarDecl>(d))
|
||||
@@ -1217,7 +1239,8 @@ void ASTVisitor::RecordDeclRef(
|
||||
m_client->onFieldParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
convertAccessType(d->getAccess()));
|
||||
convertAccessType(d->getAccess()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_Function:
|
||||
@@ -1226,7 +1249,8 @@ void ASTVisitor::RecordDeclRef(
|
||||
m_client->onFunctionParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
(refType == RT_Definition ? getParseLocationOfFunctionBody(functionDecl) : ParseLocation()));
|
||||
(refType == RT_Definition ? getParseLocationOfFunctionBody(functionDecl) : ParseLocation()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_Constructor:
|
||||
@@ -1239,7 +1263,8 @@ void ASTVisitor::RecordDeclRef(
|
||||
declNameHierarchy,
|
||||
convertAccessType(methodDecl->getAccess()),
|
||||
getAbstractionType(methodDecl),
|
||||
(refType == RT_Definition ? getParseLocationOfFunctionBody(methodDecl) : ParseLocation()));
|
||||
(refType == RT_Definition ? getParseLocationOfFunctionBody(methodDecl) : ParseLocation()),
|
||||
declIsImplicit);
|
||||
|
||||
for (clang::CXXMethodDecl::method_iterator it = methodDecl->begin_overridden_methods(); // iterate in traversal and use RT_Overridden or so..
|
||||
it != methodDecl->end_overridden_methods(); it++)
|
||||
@@ -1270,14 +1295,16 @@ void ASTVisitor::RecordDeclRef(
|
||||
m_client->onNamespaceParsed(
|
||||
namespaceDecl->isAnonymousNamespace() ? ParseLocation() : parseLocation,
|
||||
declNameHierarchy,
|
||||
getParseLocation(namespaceDecl->getSourceRange()));
|
||||
getParseLocation(namespaceDecl->getSourceRange()),
|
||||
declIsImplicit);
|
||||
}
|
||||
else if (clang::NamespaceAliasDecl* namespaceAliasDecl = clang::dyn_cast<clang::NamespaceAliasDecl>(d))
|
||||
{
|
||||
m_client->onNamespaceParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
getParseLocation(namespaceAliasDecl->getAliasedNamespace()->getSourceRange()));
|
||||
getParseLocation(namespaceAliasDecl->getAliasedNamespace()->getSourceRange()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_Enum:
|
||||
@@ -1287,20 +1314,23 @@ void ASTVisitor::RecordDeclRef(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
convertAccessType(enumDecl->getAccess()),
|
||||
getParseLocation(enumDecl->getSourceRange()));
|
||||
getParseLocation(enumDecl->getSourceRange()),
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_Enumerator:
|
||||
m_client->onEnumConstantParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy);
|
||||
declNameHierarchy,
|
||||
declIsImplicit);
|
||||
break;
|
||||
case ST_TemplateParameter:
|
||||
if (!d->getName().empty()) // We don't create symbols for unnamed template parameters.
|
||||
{
|
||||
m_client->onTemplateParameterTypeParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy);
|
||||
declNameHierarchy,
|
||||
declIsImplicit);
|
||||
}
|
||||
break;
|
||||
case ST_ClassTemplateSpecialization:
|
||||
@@ -1426,7 +1456,8 @@ void ASTVisitor::RecordDeclRef(
|
||||
m_client->onFunctionParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
parseLocation
|
||||
parseLocation,
|
||||
declIsImplicit
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1625,7 +1656,7 @@ ParseLocation ASTVisitor::getParseLocation(const clang::SourceRange& sourceRange
|
||||
);
|
||||
}
|
||||
|
||||
NameHierarchy ASTVisitor::getContextName()
|
||||
NameHierarchy ASTVisitor::getContextName() const
|
||||
{
|
||||
if (m_contextNameGenerator)
|
||||
{
|
||||
|
||||
@@ -163,6 +163,7 @@ private:
|
||||
// Misc routines
|
||||
bool shouldVisitTemplateInstantiations() const { return true; }
|
||||
bool shouldUseDataRecursionFor(clang::Stmt *s) const;
|
||||
//bool shouldVisitImplicitCode() const { return true; } // TODO: uncomment this when implicit nodes are hidden in the ui
|
||||
|
||||
// Dispatcher routines
|
||||
bool TraverseStmt(clang::Stmt *stmt);
|
||||
@@ -237,7 +238,8 @@ private:
|
||||
RefType refType,
|
||||
SymbolType symbolType = ST_Max);
|
||||
|
||||
bool isImpliciit(clang::Decl* d) const;
|
||||
bool isPartOfImplicitTemplateSpecialization(clang::Decl* d) const;
|
||||
bool isImplicit(clang::Decl* d) const;
|
||||
|
||||
void RecordDeclRef(
|
||||
clang::NamedDecl *d,
|
||||
@@ -247,14 +249,14 @@ private:
|
||||
|
||||
bool isLocatedInUnparsedProjectFile(clang::SourceLocation loc);
|
||||
bool isLocatedInProjectFile(clang::SourceLocation loc);
|
||||
|
||||
|
||||
ParserClient::AccessType convertAccessType(clang::AccessSpecifier access) const;
|
||||
ParserClient::AbstractionType getAbstractionType(const clang::CXXMethodDecl* methodDecl) const;
|
||||
ParseLocation getParseLocationOfRecordBody(clang::RecordDecl* decl) const;
|
||||
ParseLocation getParseLocationOfFunctionBody(const clang::FunctionDecl* decl) const;
|
||||
ParseLocation getParseLocation(const clang::SourceRange& sourceRange) const;
|
||||
|
||||
NameHierarchy getContextName();
|
||||
NameHierarchy getContextName() const;
|
||||
|
||||
struct FileIdHash {
|
||||
size_t operator()(clang::FileID fileID) const {
|
||||
|
||||
@@ -225,9 +225,8 @@ std::shared_ptr<NameElement> CxxDeclNameResolver::getDeclName()
|
||||
parameterString += ")";
|
||||
|
||||
return std::make_shared<NameElement>(
|
||||
functionName,
|
||||
functionName,
|
||||
NameElement::Signature((isStatic ? "static " : "") + returnTypeString, parameterString + (isConst ? " const" : "")));
|
||||
|
||||
}
|
||||
else if (clang::isa<clang::TemplateDecl>(declaration)) // also triggers on TemplateTemplateParmDecl
|
||||
{
|
||||
@@ -253,7 +252,24 @@ std::shared_ptr<NameElement> CxxDeclNameResolver::getDeclName()
|
||||
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart());
|
||||
return std::make_shared<NameElement>("anonymous enum (" + FilePath(presumedBegin.getFilename()).fileName() + ")");
|
||||
}
|
||||
|
||||
else if (
|
||||
(
|
||||
clang::isa<clang::TemplateTypeParmDecl>(declaration) ||
|
||||
clang::isa<clang::NonTypeTemplateParmDecl>(declaration) ||
|
||||
clang::isa<clang::TemplateTemplateParmDecl>(declaration)
|
||||
) && declNameString.size() == 0)
|
||||
{
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart());
|
||||
return std::make_shared<NameElement>("anonymous template parameter (" + FilePath(presumedBegin.getFilename()).fileName() + ")");
|
||||
}
|
||||
else if (clang::isa<clang::ParmVarDecl>(declaration) && declNameString.size() == 0)
|
||||
{
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart());
|
||||
return std::make_shared<NameElement>("anonymous parameter (" + FilePath(presumedBegin.getFilename()).fileName() + ")");
|
||||
}
|
||||
|
||||
if (declNameString.size() > 0)
|
||||
{
|
||||
return std::make_shared<NameElement>(declNameString);
|
||||
|
||||
Reference in New Issue
Block a user