diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-06 23:08:05 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-06 23:08:05 +0000 |
commit | 34d93dcddde71ef33a26e88bfb3c53b561f66aa1 (patch) | |
tree | de69dbd3dfbda24df2fcb02519662c1b28de00d8 /clang/lib/Sema/SemaOverload.cpp | |
parent | b703fd2216327edfea4037abe66d1dc386c5db5f (diff) | |
download | bcm5719-llvm-34d93dcddde71ef33a26e88bfb3c53b561f66aa1.tar.gz bcm5719-llvm-34d93dcddde71ef33a26e88bfb3c53b561f66aa1.zip |
Patch to implement C++ [over.built]p11 of overload resolution.
Doug, please review. There is a FIXME in the test case with a question
which is unrelated to this patch (that is, error is issued
before set of builtins are added to the candidate list).
llvm-svn: 83429
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 2ce0aabd7df..7a8c6c0b1a1 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -3678,7 +3678,45 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, break; case OO_ArrowStar: - // FIXME: No support for pointer-to-members yet. + // C++ [over.built]p11: + // For every quintuple (C1, C2, T, CV1, CV2), where C2 is a class type, + // C1 is the same type as C2 or is a derived class of C2, T is an object + // type or a function type, and CV1 and CV2 are cv-qualifier-seqs, + // there exist candidate operator functions of the form + // CV12 T& operator->*(CV1 C1*, CV2 T C2::*); + // where CV12 is the union of CV1 and CV2. + { + for (BuiltinCandidateTypeSet::iterator Ptr = + CandidateTypes.pointer_begin(); + Ptr != CandidateTypes.pointer_end(); ++Ptr) { + QualType C1Ty = (*Ptr); + QualType C1; + if (const PointerType *PointerTy = C1Ty->getAs<PointerType>()) { + C1 = PointerTy->getPointeeType(); + C1 = Context.getCanonicalType(C1).getUnqualifiedType(); + if (!isa<RecordType>(C1)) + continue; + } + for (BuiltinCandidateTypeSet::iterator + MemPtr = CandidateTypes.member_pointer_begin(), + MemPtrEnd = CandidateTypes.member_pointer_end(); + MemPtr != MemPtrEnd; ++MemPtr) { + const MemberPointerType *mptr = cast<MemberPointerType>(*MemPtr); + QualType C2 = QualType(mptr->getClass(), 0); + C2 = Context.getCanonicalType(C2).getUnqualifiedType(); + if (C1 != C2 && !IsDerivedFrom(C1, C2)) + break; + QualType ParamTypes[2] = { *Ptr, *MemPtr }; + // build CV12 T& + QualType T = mptr->getPointeeType(); + unsigned CV1 = (*Ptr).getCVRQualifiers(); + unsigned CV2 = T.getCVRQualifiers(); + T = Context.getCVRQualifiedType(T, (CV1 | CV2)); + QualType ResultTy = Context.getLValueReferenceType(T); + AddBuiltinCandidate(ResultTy, ParamTypes, Args, 2, CandidateSet); + } + } + } break; case OO_Conditional: |