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
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index f448664..7ecac00 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -26,12 +26,15 @@
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 @@
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 @@
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);