diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-12-18 19:37:40 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-12-18 19:37:40 +0000 |
commit | 55ad91fecb076c4afadb2cf0591e1bc94db6df0b (patch) | |
tree | 6ee2558608a2372f2d130e18adc9b7fa3f0b45d7 /clang/lib/Sema/SemaTemplate.cpp | |
parent | 9443f0ea5e233948c36b180b8551987df0fbdd45 (diff) | |
download | bcm5719-llvm-55ad91fecb076c4afadb2cf0591e1bc94db6df0b.tar.gz bcm5719-llvm-55ad91fecb076c4afadb2cf0591e1bc94db6df0b.zip |
Ultrasimplistic sketch for the parsing of C++ template-ids. This won't
become useful or correct until we (1) parse template arguments
correctly, (2) have some way to turn template-ids into types,
declarators, etc., and (3) have a real representation of templates.
llvm-svn: 61208
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 2dcb9fe3361..d300f283b66 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -18,6 +18,42 @@ using namespace clang; +/// isTemplateName - Determines whether the identifier II is a +/// template name in the current scope, and returns the template +/// declaration if II names a template. An optional CXXScope can be +/// passed to indicate the C++ scope in which the identifier will be +/// found. +Sema::DeclTy *Sema::isTemplateName(IdentifierInfo &II, Scope *S, + const CXXScopeSpec *SS) { + DeclContext *DC = 0; + if (SS) { + if (SS->isInvalid()) + return 0; + DC = static_cast<DeclContext*>(SS->getScopeRep()); + } + Decl *IIDecl = LookupDecl(&II, Decl::IDNS_Ordinary, S, DC, false); + + if (IIDecl) { + // FIXME: We need to represent templates via some kind of + // TemplateDecl, because what follows is a hack that only works in + // one specific case. + if (FunctionDecl *FD = dyn_cast<FunctionDecl>(IIDecl)) { + if (FD->getType()->isDependentType()) + return FD; + } else if (OverloadedFunctionDecl *Ovl + = dyn_cast<OverloadedFunctionDecl>(IIDecl)) { + for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(), + FEnd = Ovl->function_end(); + F != FEnd; ++F) { + if ((*F)->getType()->isDependentType()) + return Ovl; + } + } + return 0; + } + return 0; +} + /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining /// that the template parameter 'PrevDecl' is being shadowed by a new /// declaration at location Loc. Returns true to indicate that this is |