[cfe-commits] r80248 - in /cfe/trunk/lib/Sema: Sema.h SemaDeclCXX.cpp SemaExprCXX.cpp SemaOverload.cpp
Anders Carlsson
andersca at mac.com
Thu Aug 27 09:01:18 PDT 2009
Author: andersca
Date: Thu Aug 27 11:01:18 2009
New Revision: 80248
URL: http://llvm.org/viewvc/llvm-project?rev=80248&view=rev
Log:
Add a OverloadResolutionFlags and start converting some of the overload methods over to using it instead of bools arguments.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=80248&r1=80247&r2=80248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Aug 27 11:01:18 2009
@@ -721,13 +721,17 @@
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);
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=80248&r1=80247&r2=80248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Aug 27 11:01:18 2009
@@ -3144,7 +3144,10 @@
// 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;
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=80248&r1=80247&r2=80248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Aug 27 11:01:18 2009
@@ -881,14 +881,19 @@
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);
}
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=80248&r1=80247&r2=80248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Aug 27 11:01:18 2009
@@ -408,10 +408,11 @@
/// 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 @@
/*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 @@
/// 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
More information about the cfe-commits
mailing list