logic: fixed parent node hierarchy for C++ template parameters of variable declarations
This commit is contained in:
@@ -25,6 +25,8 @@ private:
|
||||
std::string getDeclarationFileName(const clang::Decl* declaration);
|
||||
std::string getNameForAnonymousSymbol(const std::string& symbolKindName, const clang::Decl* declaration);
|
||||
std::vector<std::string> getTemplateParameterStrings(const clang::TemplateDecl* templateDecl);
|
||||
template <typename T>
|
||||
std::vector<std::string> getTemplateParameterStringsOfPatrialSpecialitarion(const T* templateDecl);
|
||||
std::string getTemplateParameterString(const clang::NamedDecl* parameter);
|
||||
std::string getTemplateParameterTypeString(const clang::NonTypeTemplateParmDecl* parameter);
|
||||
std::string getTemplateParameterTypeString(const clang::TemplateTypeParmDecl* parameter);
|
||||
@@ -34,4 +36,39 @@ private:
|
||||
const clang::NamedDecl* m_currentDecl;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::vector<std::string> CxxDeclNameResolver::getTemplateParameterStringsOfPatrialSpecialitarion(const T* partialSpecializationDecl)
|
||||
{
|
||||
std::vector<std::string> templateParameterNames;
|
||||
clang::TemplateParameterList* parameterList = partialSpecializationDecl->getTemplateParameters();
|
||||
unsigned int currentParameterIndex = 0;
|
||||
|
||||
const clang::TemplateArgumentList& templateArgumentList = partialSpecializationDecl->getTemplateArgs();
|
||||
const int templateArgumentCount = templateArgumentList.size();
|
||||
for (int i = 0; i < templateArgumentCount; i++)
|
||||
{
|
||||
const clang::TemplateArgument& templateArgument = templateArgumentList.get(i);
|
||||
if (templateArgument.isDependent()) // IMPORTANT_TODO: fix case when arg depends on template parameter of outer template class, or depends on first template parameter.
|
||||
{
|
||||
if (currentParameterIndex < parameterList->size())
|
||||
{
|
||||
templateParameterNames.push_back(getTemplateParameterString(parameterList->getParam(currentParameterIndex)));
|
||||
}
|
||||
else
|
||||
{
|
||||
//this if fixes the crash, but not the problem TODO
|
||||
// const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
// LOG_ERROR("Template getParam out of Range " + declaration->getLocation().printToString(sourceManager));
|
||||
}
|
||||
currentParameterIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
templateParameterNames.push_back(getTemplateArgumentName(templateArgument));
|
||||
}
|
||||
}
|
||||
return templateParameterNames;
|
||||
}
|
||||
|
||||
#endif // CXX_DECL_NAME_RESOLVER_H
|
||||
|
||||
Reference in New Issue
Block a user