Refactored build_template_instantiation method

This commit is contained in:
Bartek Kryza
2022-08-25 13:53:13 +02:00
parent dfd3fee444
commit 1cf3ceff7b
3 changed files with 320 additions and 428 deletions

View File

@@ -62,4 +62,20 @@ template <> id_t to_id(const std::filesystem::path &file)
return to_id(file.lexically_normal().string());
}
template <> id_t to_id(const clang::TemplateArgument &template_argument)
{
if (template_argument.getKind() == clang::TemplateArgument::Type) {
if (template_argument.getAsType()->getAs<clang::EnumType>())
return to_id(*template_argument.getAsType()
->getAs<clang::EnumType>()
->getAsTagDecl());
else if (template_argument.getAsType()->getAs<clang::RecordType>())
return to_id(*template_argument.getAsType()
->getAs<clang::RecordType>()
->getAsRecordDecl());
}
throw std::runtime_error("Cannot generate id for template argument");
}
}