[cfe-commits] r99459 - in /cfe/trunk/lib/Sema: SemaCXXCast.cpp SemaExprCXX.cpp SemaInit.cpp
Douglas Gregor
dgregor at apple.com
Wed Mar 24 17:20:39 PDT 2010
Author: dgregor
Date: Wed Mar 24 19:20:38 2010
New Revision: 99459
URL: http://llvm.org/viewvc/llvm-project?rev=99459&view=rev
Log:
Kill off two more uses of Sema::CheckReferenceInit in favor of the new
initialization code. Exposed a bug where we were not marking an
implicit conversion as an lvalue when we were forming a call to a
conversion function whose return type is a reference.
Modified:
cfe/trunk/lib/Sema/SemaCXXCast.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=99459&r1=99458&r2=99459&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Wed Mar 24 19:20:38 2010
@@ -621,8 +621,8 @@
return TC_Failed;
}
- // FIXME: Similar to CheckReferenceInit, we actually need more AST annotation
- // than nothing.
+ // FIXME: We should probably have an AST node for lvalue-to-rvalue
+ // conversions.
return TC_Success;
}
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=99459&r1=99458&r2=99459&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Mar 24 19:20:38 2010
@@ -2048,28 +2048,26 @@
/// handles the reference binding specially.
static bool ConvertForConditional(Sema &Self, Expr *&E,
const ImplicitConversionSequence &ICS) {
- if (ICS.isStandard() && ICS.Standard.ReferenceBinding) {
- assert(ICS.Standard.DirectBinding &&
+ if ((ICS.isStandard() && ICS.Standard.ReferenceBinding) ||
+ (ICS.isUserDefined() && ICS.UserDefined.After.ReferenceBinding)) {
+ assert(((ICS.isStandard() && ICS.Standard.DirectBinding) ||
+ (ICS.isUserDefined() && ICS.UserDefined.After.DirectBinding)) &&
"TryClassUnification should never generate indirect ref bindings");
- // FIXME: CheckReferenceInit should be able to reuse the ICS instead of
- // redoing all the work.
- return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType(
- TargetType(ICS)),
- /*FIXME:*/E->getLocStart(),
- /*SuppressUserConversions=*/false,
- /*AllowExplicit=*/false,
- /*ForceRValue=*/false);
- }
- if (ICS.isUserDefined() && ICS.UserDefined.After.ReferenceBinding) {
- assert(ICS.UserDefined.After.DirectBinding &&
- "TryClassUnification should never generate indirect ref bindings");
- return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType(
- TargetType(ICS)),
- /*FIXME:*/E->getLocStart(),
- /*SuppressUserConversions=*/false,
- /*AllowExplicit=*/false,
- /*ForceRValue=*/false);
+ InitializedEntity Entity
+ = InitializedEntity::InitializeTemporary(
+ Self.Context.getLValueReferenceType(TargetType(ICS)));
+ InitializationKind Kind = InitializationKind::CreateCopy(E->getLocStart(),
+ SourceLocation());
+ InitializationSequence InitSeq(Self, Entity, Kind, &E, 1);
+ Sema::OwningExprResult Result = InitSeq.Perform(Self, Entity, Kind,
+ Sema::MultiExprArg(Self, (void **)&E, 1));
+ if (Result.isInvalid())
+ return true;
+
+ E = Result.takeAs<Expr>();
+ return false;
}
+
if (Self.PerformImplicitConversion(E, TargetType(ICS), ICS, Sema::AA_Converting))
return true;
return false;
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=99459&r1=99458&r2=99459&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Mar 24 19:20:38 2010
@@ -3382,6 +3382,7 @@
bool IsCopy = false;
FunctionDecl *Fn = Step->Function.Function;
DeclAccessPair FoundFn = Step->Function.FoundDecl;
+ bool IsLvalue = false;
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Fn)) {
// Build a call to the selected constructor.
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S);
@@ -3414,7 +3415,7 @@
} else {
// Build a call to the conversion function.
CXXConversionDecl *Conversion = cast<CXXConversionDecl>(Fn);
-
+ IsLvalue = Conversion->getResultType()->isLValueReferenceType();
S.CheckMemberOperatorAccess(Kind.getLocation(), CurInitExpr, 0,
FoundFn);
@@ -3444,7 +3445,7 @@
CurInit = S.Owned(new (S.Context) ImplicitCastExpr(CurInitExpr->getType(),
CastKind,
CurInitExpr,
- false));
+ IsLvalue));
if (!IsCopy)
CurInit = CopyIfRequiredForEntity(S, Entity, Kind, move(CurInit));
More information about the cfe-commits
mailing list