From 27b18f8144b7cb3ec9ab864f9431ebc44a3c51fc Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 17 Nov 2009 02:14:36 +0000 Subject: 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. llvm-svn: 89027 --- clang/lib/Sema/SemaExpr.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index a74d50365e2..535632e6db8 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -681,15 +681,11 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, isAddressOfOperand)); } - LookupResult Lookup; - LookupParsedName(Lookup, S, SS, Name, LookupOrdinaryName, false, true, Loc); + LookupResult Lookup(*this, Name, Loc, LookupOrdinaryName); + LookupParsedName(Lookup, S, SS, true); - if (Lookup.isAmbiguous()) { - DiagnoseAmbiguousLookup(Lookup, Name, Loc, - SS && SS->isSet() ? SS->getRange() - : SourceRange()); + if (Lookup.isAmbiguous()) return ExprError(); - } NamedDecl *D = Lookup.getAsSingleDecl(Context); @@ -2075,17 +2071,14 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, } // The record definition is complete, now make sure the member is valid. - LookupResult Result; - LookupQualifiedName(Result, DC, MemberName, LookupMemberName, false); + LookupResult Result(*this, MemberName, MemberLoc, LookupMemberName); + LookupQualifiedName(Result, DC); if (Result.empty()) return ExprError(Diag(MemberLoc, diag::err_no_member) << MemberName << DC << BaseExpr->getSourceRange()); - if (Result.isAmbiguous()) { - DiagnoseAmbiguousLookup(Result, MemberName, MemberLoc, - BaseExpr->getSourceRange()); + if (Result.isAmbiguous()) return ExprError(); - } NamedDecl *MemberDecl = Result.getAsSingleDecl(Context); @@ -5887,8 +5880,8 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, } } - LookupResult R; - LookupQualifiedName(R, RD, OC.U.IdentInfo, LookupMemberName); + LookupResult R(*this, OC.U.IdentInfo, OC.LocStart, LookupMemberName); + LookupQualifiedName(R, RD); FieldDecl *MemberDecl = dyn_cast_or_null(R.getAsSingleDecl(Context)); -- cgit v1.2.3