Skip to content
Snippets Groups Projects
Commit ce1c6fc5 authored by Vassil Vassilev's avatar Vassil Vassilev
Browse files

Add clarification comment.

parent 5b06f22e
No related branches found
No related tags found
No related merge requests found
......@@ -479,14 +479,30 @@ namespace cling {
}
};
if (FD->isFunctionTemplateSpecialization()) {
// 1. Remove the canonical decl.
// TODO: Can the canonical have another DeclContext and Scope, different
// from the specialization's implementation?
FunctionDecl* CanFD = FD->getCanonicalDecl();
if (FD->isFunctionTemplateSpecialization() && FD->isCanonicalDecl()) {
// Only the canonical declarations are registered in the list of the
// specializations.
FunctionTemplateDecl* FTD
= FD->getTemplateSpecializationInfo()->getTemplate();
FunctionTemplateDeclExt::removeSpecialization(FTD, CanFD);
// The canonical declaration of every specialization is registered with
// the FunctionTemplateDecl.
// Note this might revert too much in the case:
// template<typename T> T f(){ return T();}
// template<> int f();
// template<> int f() { return 0;}
// when the template specialization was forward declared the canonical
// becomes the first forward declaration. If the canonical forward
// declaration was declared outside the set of the decls to revert we have
// to keep it registered as a template specialization.
//
// In order to diagnose mismatches of the specializations, clang 'injects'
// a implicit forward declaration making it very hard distinguish between
// the explicit and the implicit forward declaration. So far the only way
// to distinguish is by source location comparison.
// FIXME: When the misbehavior of clang is fixed we must avoid relying on
// source locations
FunctionDecl* canonSpecialization = FD->getCanonicalDecl();
FunctionTemplateDeclExt::removeSpecialization(FTD, canonSpecialization);
}
return Successful;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment