Partial expansion of C++ operator overloading (for binary operators)
to support operators defined as member functions, e.g.,
struct X {
bool operator==(X&);
};
Overloading with non-member operators is supported, and the special
rules for the implicit object parameter (e.g., the ability for a
non-const *this to bind to an rvalue) are implemented.
This change also refactors and generalizes the code for adding
overload candidates for overloaded operator calls (C++ [over.match.expr]),
both to match the rules more exactly (name lookup of non-member
operators actually ignores member operators) and to make this routine
more reusable for the other overloaded operators.
Testing for the initialization of the implicit object parameter is
very light. More tests will come when we get support for calling
member functions directly (e.g., o.m(a1, a2)).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59564 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index c3bd33e..6512937 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -413,6 +413,10 @@
bool PerformCopyInitialization(Expr *&From, QualType ToType,
const char *Flavor);
+ ImplicitConversionSequence
+ TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method);
+ bool PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method);
+
/// OverloadingResult - Capture the result of performing overload
/// resolution.
enum OverloadingResult {
@@ -425,9 +429,16 @@
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversions = false);
+ void AddMethodCandidate(CXXMethodDecl *Method,
+ Expr *Object, Expr **Args, unsigned NumArgs,
+ OverloadCandidateSet& CandidateSet,
+ bool SuppressUserConversions = true);
void AddConversionCandidate(CXXConversionDecl *Conversion,
Expr *From, QualType ToType,
OverloadCandidateSet& CandidateSet);
+ void AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S,
+ Expr **Args, unsigned NumArgs,
+ OverloadCandidateSet& CandidateSet);
void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet);