forked from OSchip/llvm-project
Add a OverloadResolutionFlags and start converting some of the overload methods over to using it instead of bools arguments.
llvm-svn: 80248
This commit is contained in:
parent
7b8f61f3c8
commit
2f7e956f16
|
@ -721,13 +721,17 @@ public:
|
|||
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
|
||||
|
||||
/// C++ Overloading.
|
||||
enum OverloadResolutionFlags {
|
||||
ORF_None = 0x0,
|
||||
ORF_SuppressUserConversions = 0x1,
|
||||
ORF_AllowExplicit = 0x2,
|
||||
ORF_ForceRValue = 0x4
|
||||
};
|
||||
|
||||
bool IsOverload(FunctionDecl *New, Decl* OldD,
|
||||
OverloadedFunctionDecl::function_iterator &MatchedDecl);
|
||||
ImplicitConversionSequence
|
||||
TryImplicitConversion(Expr* From, QualType ToType,
|
||||
bool SuppressUserConversions = false,
|
||||
bool AllowExplicit = false,
|
||||
bool ForceRValue = false);
|
||||
TryImplicitConversion(Expr* From, QualType ToType, unsigned Flags = ORF_None);
|
||||
bool IsStandardConversion(Expr *From, QualType ToType,
|
||||
StandardConversionSequence& SCS);
|
||||
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
|
||||
|
|
|
@ -3144,7 +3144,10 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
|
|||
// the argument expression. Any difference in top-level
|
||||
// cv-qualification is subsumed by the initialization itself
|
||||
// and does not constitute a conversion.
|
||||
*ICS = TryImplicitConversion(Init, T1, SuppressUserConversions);
|
||||
*ICS = TryImplicitConversion(Init, T1,
|
||||
SuppressUserConversions ?
|
||||
ORF_SuppressUserConversions :
|
||||
ORF_None);
|
||||
// Of course, that's still a reference binding.
|
||||
if (ICS->ConversionKind == ImplicitConversionSequence::StandardConversion) {
|
||||
ICS->Standard.ReferenceBinding = true;
|
||||
|
|
|
@ -881,14 +881,19 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
|
|||
const char *Flavor, bool AllowExplicit,
|
||||
bool Elidable)
|
||||
{
|
||||
unsigned Flags = ORF_None;
|
||||
if (AllowExplicit)
|
||||
Flags |= ORF_AllowExplicit;
|
||||
|
||||
ImplicitConversionSequence ICS;
|
||||
ICS.ConversionKind = ImplicitConversionSequence::BadConversion;
|
||||
if (Elidable && getLangOptions().CPlusPlus0x) {
|
||||
ICS = TryImplicitConversion(From, ToType, /*SuppressUserConversions*/false,
|
||||
AllowExplicit, /*ForceRValue*/true);
|
||||
Flags |= ORF_ForceRValue;
|
||||
|
||||
ICS = TryImplicitConversion(From, ToType, Flags);
|
||||
}
|
||||
if (ICS.ConversionKind == ImplicitConversionSequence::BadConversion) {
|
||||
ICS = TryImplicitConversion(From, ToType, false, AllowExplicit);
|
||||
ICS = TryImplicitConversion(From, ToType, Flags);
|
||||
}
|
||||
return PerformImplicitConversion(From, ToType, ICS, Flavor);
|
||||
}
|
||||
|
|
|
@ -408,10 +408,11 @@ Sema::IsOverload(FunctionDecl *New, Decl* OldD,
|
|||
/// If @p ForceRValue, then overloading is performed as if From was an rvalue,
|
||||
/// no matter its actual lvalueness.
|
||||
ImplicitConversionSequence
|
||||
Sema::TryImplicitConversion(Expr* From, QualType ToType,
|
||||
bool SuppressUserConversions,
|
||||
bool AllowExplicit, bool ForceRValue)
|
||||
{
|
||||
Sema::TryImplicitConversion(Expr* From, QualType ToType, unsigned Flags) {
|
||||
bool SuppressUserConversions = Flags & ORF_SuppressUserConversions;
|
||||
bool AllowExplicit = Flags & ORF_AllowExplicit;
|
||||
bool ForceRValue = Flags & ORF_ForceRValue;
|
||||
|
||||
ImplicitConversionSequence ICS;
|
||||
if (IsStandardConversion(From, ToType, ICS.Standard))
|
||||
ICS.ConversionKind = ImplicitConversionSequence::StandardConversion;
|
||||
|
@ -1929,8 +1930,11 @@ Sema::TryCopyInitialization(Expr *From, QualType ToType,
|
|||
/*AllowExplicit=*/false, ForceRValue);
|
||||
return ICS;
|
||||
} else {
|
||||
return TryImplicitConversion(From, ToType, SuppressUserConversions,
|
||||
ForceRValue);
|
||||
unsigned Flags = ORF_None;
|
||||
if (SuppressUserConversions) Flags |= ORF_SuppressUserConversions;
|
||||
if (ForceRValue) Flags |= ORF_ForceRValue;
|
||||
|
||||
return TryImplicitConversion(From, ToType, Flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2064,7 +2068,7 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
|
|||
/// TryContextuallyConvertToBool - Attempt to contextually convert the
|
||||
/// expression From to bool (C++0x [conv]p3).
|
||||
ImplicitConversionSequence Sema::TryContextuallyConvertToBool(Expr *From) {
|
||||
return TryImplicitConversion(From, Context.BoolTy, false, true);
|
||||
return TryImplicitConversion(From, Context.BoolTy, ORF_AllowExplicit);
|
||||
}
|
||||
|
||||
/// PerformContextuallyConvertToBool - Perform a contextual conversion
|
||||
|
|
Loading…
Reference in New Issue