diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-07-29 16:56:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-07-29 16:56:42 +0000 |
commit | b142c2d0a8af34b1201cf83944d058ff1b4794ad (patch) | |
tree | e36f3b5060b33a65ba52a5568598ec7cc664a4c0 /clang | |
parent | a6d0436b97956085b76e1e46eff80eaa2fea745a (diff) | |
download | bcm5719-llvm-b142c2d0a8af34b1201cf83944d058ff1b4794ad.tar.gz bcm5719-llvm-b142c2d0a8af34b1201cf83944d058ff1b4794ad.zip |
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.
llvm-svn: 77472
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 55c43c2d0aa..0300093fa4a 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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<OverloadedFunctionDecl>(IIDecl)) { + } else if (OverloadedFunctionDecl *Ovl + = dyn_cast<OverloadedFunctionDecl>(IIDecl)) { for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(), FEnd = Ovl->function_end(); F != FEnd; ++F) { - if (isa<FunctionTemplateDecl>(*F)) { - TemplateResult = TemplateTy::make(Ovl); - return TNK_Function_template; + if (FunctionTemplateDecl *FuncTmpl + = dyn_cast<FunctionTemplateDecl>(*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<FunctionTemplateDecl>(*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<FunctionTemplateDecl>(*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; } } } |