diff options
author | John McCall <rjmccall@apple.com> | 2009-11-17 02:14:36 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-11-17 02:14:36 +0000 |
commit | a24dc2e38c7fb0f7f138b3d14b5f0f241fd0eccf (patch) | |
tree | d040e3cf363229c97136c3663a267a040760acd8 /lib/Sema/SemaCXXScopeSpec.cpp | |
parent | 936d2a8a3968231199dddbc78378e8fddbab6e25 (diff) |
Carry lookup configuration throughout lookup on the LookupResult. Give
LookupResult RAII powers to diagnose ambiguity in the results. Other diagnostics
(e.g. access control and deprecation) will be moved to automatically trigger
during lookup as part of this same mechanism.
This abstraction makes it much easier to encapsulate aliasing declarations
(e.g. using declarations) inside the lookup system: eventually, lookup will
just produce the aliases in the LookupResult, and the standard access methods
will naturally strip the aliases off.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89027 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index ce3fb5f83c..b196dcec6f 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -307,8 +307,9 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) { if (NNS->getKind() != NestedNameSpecifier::Identifier) return 0; - LookupResult Found; - LookupName(Found, S, NNS->getAsIdentifier(), LookupNestedNameSpecifierName); + LookupResult Found(*this, NNS->getAsIdentifier(), SourceLocation(), + LookupNestedNameSpecifierName); + LookupName(Found, S); assert(!Found.isAmbiguous() && "Cannot handle ambiguities here yet"); NamedDecl *Result = Found.getAsSingleDecl(Context); @@ -336,6 +337,8 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecifier *Prefix = static_cast<NestedNameSpecifier *>(SS.getScopeRep()); + LookupResult Found(*this, &II, IdLoc, LookupNestedNameSpecifierName); + // Determine where to perform name lookup DeclContext *LookupCtx = 0; bool isDependent = false; @@ -350,9 +353,10 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // so long into the context associated with the prior nested-name-specifier. LookupCtx = computeDeclContext(SS, EnteringContext); isDependent = isDependentScopeSpecifier(SS); + Found.setContextRange(SS.getRange()); } - LookupResult Found; + bool ObjectTypeSearchedInScope = false; if (LookupCtx) { // Perform "qualified" name lookup into the declaration context we @@ -364,10 +368,9 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(SS)) return 0; - LookupQualifiedName(Found, LookupCtx, &II, LookupNestedNameSpecifierName, - false); + LookupQualifiedName(Found, LookupCtx); - if (!ObjectType.isNull() && Found.getKind() == LookupResult::NotFound) { + if (!ObjectType.isNull() && Found.empty()) { // C++ [basic.lookup.classref]p4: // If the id-expression in a class member access is a qualified-id of // the form @@ -389,7 +392,7 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // reconstruct the result from when name lookup was performed at template // definition time. if (S) - LookupName(Found, S, &II, LookupNestedNameSpecifierName); + LookupName(Found, S); else if (ScopeLookupResult) Found.addDecl(ScopeLookupResult); @@ -406,7 +409,7 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, return NestedNameSpecifier::Create(Context, Prefix, &II); } else { // Perform unqualified name lookup in the current scope. - LookupName(Found, S, &II, LookupNestedNameSpecifierName); + LookupName(Found, S); } // FIXME: Deal with ambiguities cleanly. @@ -423,9 +426,8 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // scope, reconstruct the result from the template instantiation itself. NamedDecl *OuterDecl; if (S) { - LookupResult FoundOuter; - LookupName(FoundOuter, S, &II, LookupNestedNameSpecifierName); - // FIXME: Handle ambiguities! + LookupResult FoundOuter(*this, &II, IdLoc, LookupNestedNameSpecifierName); + LookupName(FoundOuter, S); OuterDecl = FoundOuter.getAsSingleDecl(Context); } else OuterDecl = ScopeLookupResult; @@ -467,8 +469,8 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // ordinary name lookup, which can help us produce better error // messages. if (!SD) { - Found.clear(); - LookupName(Found, S, &II, LookupOrdinaryName); + Found.clear(LookupOrdinaryName); + LookupName(Found, S); SD = Found.getAsSingleDecl(Context); } |