diff options
author | John McCall <rjmccall@apple.com> | 2009-10-09 21:13:30 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-10-09 21:13:30 +0000 |
commit | f36e02d4aff98bf2e52e342e0038d4172fbb5e64 (patch) | |
tree | de0e84cc5c69c3749a01794221565dcbe5d22614 /lib/Sema/SemaCXXScopeSpec.cpp | |
parent | d7e5bdb23c6ba2786cf94788c9af555e2c1276ce (diff) |
Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines. Call out uses which assume a single
result.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 8f536da777..911cf67770 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -302,11 +302,11 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) { if (NNS->getKind() != NestedNameSpecifier::Identifier) return 0; - LookupResult Found - = LookupName(S, NNS->getAsIdentifier(), LookupNestedNameSpecifierName); + LookupResult Found; + LookupName(Found, S, NNS->getAsIdentifier(), LookupNestedNameSpecifierName); assert(!Found.isAmbiguous() && "Cannot handle ambiguities here yet"); - NamedDecl *Result = Found; + NamedDecl *Result = Found.getAsSingleDecl(Context); if (isAcceptableNestedNameSpecifier(Result)) return Result; @@ -359,8 +359,8 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(SS)) return 0; - Found = LookupQualifiedName(LookupCtx, &II, LookupNestedNameSpecifierName, - false); + LookupQualifiedName(Found, LookupCtx, &II, LookupNestedNameSpecifierName, + false); if (!ObjectType.isNull() && Found.getKind() == LookupResult::NotFound) { // C++ [basic.lookup.classref]p4: @@ -384,9 +384,9 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // reconstruct the result from when name lookup was performed at template // definition time. if (S) - Found = LookupName(S, &II, LookupNestedNameSpecifierName); - else - Found = LookupResult::CreateLookupResult(Context, ScopeLookupResult); + LookupName(Found, S, &II, LookupNestedNameSpecifierName); + else if (ScopeLookupResult) + Found.addDecl(ScopeLookupResult); ObjectTypeSearchedInScope = true; } @@ -401,11 +401,11 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, return NestedNameSpecifier::Create(Context, Prefix, &II); } else { // Perform unqualified name lookup in the current scope. - Found = LookupName(S, &II, LookupNestedNameSpecifierName); + LookupName(Found, S, &II, LookupNestedNameSpecifierName); } // FIXME: Deal with ambiguities cleanly. - NamedDecl *SD = Found; + NamedDecl *SD = Found.getAsSingleDecl(Context); if (isAcceptableNestedNameSpecifier(SD)) { if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) { // C++ [basic.lookup.classref]p4: @@ -416,15 +416,15 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // into the current scope (the scope of the postfix-expression) to // see if we can find the same name there. As above, if there is no // scope, reconstruct the result from the template instantiation itself. - LookupResult FoundOuter; - if (S) - FoundOuter = LookupName(S, &II, LookupNestedNameSpecifierName); - else - FoundOuter = LookupResult::CreateLookupResult(Context, - ScopeLookupResult); + NamedDecl *OuterDecl; + if (S) { + LookupResult FoundOuter; + LookupName(FoundOuter, S, &II, LookupNestedNameSpecifierName); + // FIXME: Handle ambiguities! + OuterDecl = FoundOuter.getAsSingleDecl(Context); + } else + OuterDecl = ScopeLookupResult; - // FIXME: Handle ambiguities in FoundOuter! - NamedDecl *OuterDecl = FoundOuter; if (isAcceptableNestedNameSpecifier(OuterDecl) && OuterDecl->getCanonicalDecl() != SD->getCanonicalDecl() && (!isa<TypeDecl>(OuterDecl) || !isa<TypeDecl>(SD) || @@ -461,8 +461,11 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S, // If we didn't find anything during our lookup, try again with // ordinary name lookup, which can help us produce better error // messages. - if (!SD) - SD = LookupName(S, &II, LookupOrdinaryName); + if (!SD) { + Found.clear(); + LookupName(Found, S, &II, LookupOrdinaryName); + SD = Found.getAsSingleDecl(Context); + } unsigned DiagID; if (SD) |