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/SemaExpr.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/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c689a7ac2a..b4384b11fd 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -695,8 +695,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, isAddressOfOperand)); } - LookupResult Lookup = LookupParsedName(S, SS, Name, LookupOrdinaryName, - false, true, Loc); + LookupResult Lookup; + LookupParsedName(Lookup, S, SS, Name, LookupOrdinaryName, false, true, Loc); if (Lookup.isAmbiguous()) { DiagnoseAmbiguousLookup(Lookup, Name, Loc, @@ -705,7 +705,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, return ExprError(); } - NamedDecl *D = Lookup.getAsDecl(); + NamedDecl *D = Lookup.getAsSingleDecl(Context); // If this reference is in an Objective-C method, then ivar lookup happens as // well. @@ -2181,10 +2181,10 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, } // The record definition is complete, now make sure the member is valid. - LookupResult Result - = LookupQualifiedName(DC, MemberName, LookupMemberName, false); + LookupResult Result; + LookupQualifiedName(Result, DC, MemberName, LookupMemberName, false); - if (!Result) + if (Result.empty()) return ExprError(Diag(MemberLoc, diag::err_typecheck_no_member_deprecated) << MemberName << BaseExpr->getSourceRange()); if (Result.isAmbiguous()) { @@ -2193,13 +2193,14 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, return ExprError(); } + NamedDecl *MemberDecl = Result.getAsSingleDecl(Context); + if (SS && SS->isSet()) { + TypeDecl* TyD = cast<TypeDecl>(MemberDecl->getDeclContext()); QualType BaseTypeCanon = Context.getCanonicalType(BaseType).getUnqualifiedType(); QualType MemberTypeCanon - = Context.getCanonicalType( - Context.getTypeDeclType( - dyn_cast<TypeDecl>(Result.getAsDecl()->getDeclContext()))); + = Context.getCanonicalType(Context.getTypeDeclType(TyD)); if (BaseTypeCanon != MemberTypeCanon && !IsDerivedFrom(BaseTypeCanon, MemberTypeCanon)) @@ -2208,8 +2209,6 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, << MemberTypeCanon << BaseTypeCanon); } - NamedDecl *MemberDecl = Result; - // If the decl being referenced had an error, return an error for this // sub-expr without emitting another error, in order to avoid cascading // error cases. @@ -5685,10 +5684,11 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, } } + LookupResult R; + LookupQualifiedName(R, RD, OC.U.IdentInfo, LookupMemberName); + FieldDecl *MemberDecl - = dyn_cast_or_null<FieldDecl>(LookupQualifiedName(RD, OC.U.IdentInfo, - LookupMemberName) - .getAsDecl()); + = dyn_cast_or_null<FieldDecl>(R.getAsSingleDecl(Context)); // FIXME: Leaks Res if (!MemberDecl) return ExprError(Diag(BuiltinLoc, diag::err_typecheck_no_member_deprecated) |