From: Douglas Gregor Date: Wed, 29 Jul 2009 16:56:42 +0000 (+0000) Subject: When lookup of an identifier preceding a '<' finds a set of overloaded X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f511e47039798ce08287dfafcc03c445eae2168b;p=clang When lookup of an identifier preceding a '<' finds a set of overloaded functions, only return those overloaded functions that are actually function templates. Note that there is still a glaring problem with treating an OverloadedFunctionDecl as a TemplateName. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77472 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 55c43c2d0a..0300093fa4 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -65,18 +65,44 @@ TemplateNameKind Sema::isTemplateName(const IdentifierInfo &II, Scope *S, TNK = TNK_Type_template; } } - } - - // FIXME: What follows is a slightly less gross hack than what used to - // follow. - if (OverloadedFunctionDecl *Ovl - = dyn_cast(IIDecl)) { + } else if (OverloadedFunctionDecl *Ovl + = dyn_cast(IIDecl)) { for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(), FEnd = Ovl->function_end(); F != FEnd; ++F) { - if (isa(*F)) { - TemplateResult = TemplateTy::make(Ovl); - return TNK_Function_template; + if (FunctionTemplateDecl *FuncTmpl + = dyn_cast(*F)) { + // We've found a function template. Determine whether there are + // any other function templates we need to bundle together in an + // OverloadedFunctionDecl + for (++F; F != FEnd; ++F) { + if (isa(*F)) + break; + } + + if (F != FEnd) { + // Build an overloaded function decl containing only the + // function templates in Ovl. + OverloadedFunctionDecl *OvlTemplate + = OverloadedFunctionDecl::Create(Context, + Ovl->getDeclContext(), + Ovl->getDeclName()); + OvlTemplate->addOverload(FuncTmpl); + OvlTemplate->addOverload(*F); + for (++F; F != FEnd; ++F) { + if (isa(*F)) + OvlTemplate->addOverload(*F); + } + + // FIXME: HACK! We need TemplateName to be able to refer to + // sets of overloaded function templates. + TemplateResult = TemplateTy::make(OvlTemplate); + return TNK_Function_template; + } + + TNK = TNK_Function_template; + Template = FuncTmpl; + break; } } }