diff options
author | John McCall <rjmccall@apple.com> | 2009-11-30 22:42:35 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-11-30 22:42:35 +0000 |
commit | 10eae1851d3f6cfa9ab665fc2bd54a3ff57293d8 (patch) | |
tree | 92bacc32cd9c5e89a53994b619effcc494843cc7 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | 120037fec7ad543a95ec19aced0ab5778a160de9 (diff) | |
download | bcm5719-llvm-10eae1851d3f6cfa9ab665fc2bd54a3ff57293d8.tar.gz bcm5719-llvm-10eae1851d3f6cfa9ab665fc2bd54a3ff57293d8.zip |
Eliminate the use of OverloadedFunctionDecl in member expressions.
Create a new UnresolvedMemberExpr for these lookups. Assorted hackery
around qualified member expressions; this will all go away when we
implement the correct (i.e. extremely delayed) implicit-member semantics.
llvm-svn: 90161
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 0b3426b2f3c..00fb65df92c 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2236,9 +2236,6 @@ Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) { /// /// FIXME: Should Objective-C also use this approach? /// -/// \param SS if non-NULL, the C++ nested-name-specifier that precedes the -/// name of the declaration referenced. -/// /// \param D the declaration being referenced from the current scope. /// /// \param NameLoc the location of the name in the source. @@ -2247,16 +2244,11 @@ Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) { /// access, will be set to the type of the "this" pointer to be used when /// building that implicit member access. /// -/// \param MemberType if the reference to this declaration is an implicit -/// member access, will be set to the type of the member being referenced -/// (for use at the type of the resulting member access expression). -/// /// \returns true if this is an implicit member reference (in which case /// \p ThisType and \p MemberType will be set), or false if it is not an /// implicit member reference. -bool Sema::isImplicitMemberReference(const CXXScopeSpec &SS, NamedDecl *D, - SourceLocation NameLoc, QualType &ThisType, - QualType &MemberType) { +bool Sema::isImplicitMemberReference(const LookupResult &R, + QualType &ThisType) { // If this isn't a C++ method, then it isn't an implicit member reference. CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext); if (!MD || MD->isStatic()) @@ -2269,33 +2261,21 @@ bool Sema::isImplicitMemberReference(const CXXScopeSpec &SS, NamedDecl *D, // class member access expression (5.2.5) using (*this) (9.3.2) // as the postfix-expression to the left of the '.' operator. DeclContext *Ctx = 0; - if (FieldDecl *FD = dyn_cast<FieldDecl>(D)) { + if (R.isUnresolvableResult()) { + // FIXME: this is just picking one at random + Ctx = R.getRepresentativeDecl()->getDeclContext(); + } else if (FieldDecl *FD = R.getAsSingle<FieldDecl>()) { Ctx = FD->getDeclContext(); - MemberType = FD->getType(); - - if (const ReferenceType *RefType = MemberType->getAs<ReferenceType>()) - MemberType = RefType->getPointeeType(); - else if (!FD->isMutable()) - MemberType - = Context.getQualifiedType(MemberType, - Qualifiers::fromCVRMask(MD->getTypeQualifiers())); - } else if (isa<UnresolvedUsingValueDecl>(D)) { - Ctx = D->getDeclContext(); - MemberType = Context.DependentTy; } else { - for (OverloadIterator Ovl(D), OvlEnd; Ovl != OvlEnd; ++Ovl) { - CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*Ovl); + for (LookupResult::iterator I = R.begin(), E = R.end(); I != E; ++I) { + CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*I); FunctionTemplateDecl *FunTmpl = 0; - if (!Method && (FunTmpl = dyn_cast<FunctionTemplateDecl>(*Ovl))) + if (!Method && (FunTmpl = dyn_cast<FunctionTemplateDecl>(*I))) Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl()); // FIXME: Do we have to know if there are explicit template arguments? if (Method && !Method->isStatic()) { Ctx = Method->getParent(); - if (isa<CXXMethodDecl>(D) && !FunTmpl) - MemberType = Method->getType(); - else - MemberType = Context.OverloadTy; break; } } @@ -2307,6 +2287,8 @@ bool Sema::isImplicitMemberReference(const CXXScopeSpec &SS, NamedDecl *D, // Determine whether the declaration(s) we found are actually in a base // class. If not, this isn't an implicit member reference. ThisType = MD->getThisType(Context); + + // FIXME: this doesn't really work for overloaded lookups. QualType CtxType = Context.getTypeDeclType(cast<CXXRecordDecl>(Ctx)); QualType ClassType |