aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-01-29 00:07:50 +0000
committerSteve Naroff <snaroff@apple.com>2009-01-29 00:07:50 +0000
commit3e8ffd2e96e7842245f1ae0cb631eba75da1a6f7 (patch)
treefb9d3e0943df2ef7ce7d0927cfe4aedaf44bd69a /lib/Sema/SemaTemplate.cpp
parent54f0728c2ab0f967e976300478b2f5cdfed78415 (diff)
Refactor Sema::LookupDecl() into 2 functions: LookupDeclInScope() and LookupDeclInContext().
The previous interface was very confusing. This is much more explicit, which will be easier to understand/optimize/convert. The plan is to eventually deprecate both of these functions. For now, I'm focused on performance. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63256 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index f448664615..7ecac00277 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -26,12 +26,15 @@ using namespace clang;
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);
+ Decl *IIDecl = DC ?
+ LookupDeclInContext(&II, Decl::IDNS_Ordinary, DC, false) :
+ LookupDeclInScope(&II, Decl::IDNS_Ordinary, S, false);
if (IIDecl) {
// FIXME: We need to represent templates via some kind of
@@ -93,7 +96,7 @@ Sema::DeclTy *Sema::ActOnTypeParameter(Scope *S, bool Typename,
bool Invalid = false;
if (ParamName) {
- Decl *PrevDecl = LookupDecl(ParamName, Decl::IDNS_Tag, S);
+ Decl *PrevDecl = LookupDeclInScope(ParamName, Decl::IDNS_Tag, S);
if (PrevDecl && PrevDecl->isTemplateParameter())
Invalid = Invalid || DiagnoseTemplateParameterShadow(ParamNameLoc,
PrevDecl);
@@ -129,7 +132,7 @@ Sema::DeclTy *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
IdentifierInfo *ParamName = D.getIdentifier();
if (ParamName) {
- Decl *PrevDecl = LookupDecl(ParamName, Decl::IDNS_Tag, S);
+ Decl *PrevDecl = LookupDeclInScope(ParamName, Decl::IDNS_Tag, S);
if (PrevDecl && PrevDecl->isTemplateParameter())
Invalid = Invalid || DiagnoseTemplateParameterShadow(D.getIdentifierLoc(),
PrevDecl);