[cfe-commits] r81847 - in /cfe/trunk/lib/Sema: SemaDeclCXX.cpp SemaExprCXX.cpp
Douglas Gregor
dgregor at apple.com
Tue Sep 15 07:52:56 PDT 2009
On Sep 14, 2009, at 11:28 PM, Anders Carlsson wrote:
> Author: andersca
> Date: Tue Sep 15 01:28:28 2009
> New Revision: 81847
>
> URL: http://llvm.org/viewvc/llvm-project?rev=81847&view=rev
> Log:
> When performing an user defined conversion sequence, perform the
> initial standard conversion sequence. This lets us remove a
> workaround in SemaCompleteConstructorCall.
>
> Modified:
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=81847&r1=81846&r2=81847&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 15 01:28:28 2009
> @@ -3243,12 +3243,6 @@
> Expr *Arg;
> if (i < NumArgs) {
> Arg = Args[i];
> -
> - // Pass the argument.
> - if (PerformCopyInitialization(Arg, ProtoArgType, "passing"))
> - return true;
> -
> - Args[i] = 0;
> } else {
> ParmVarDecl *Param = Constructor->getParamDecl(i);
>
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=81847&r1=81846&r2=81847&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Sep 15 01:28:28 2009
> @@ -971,17 +971,34 @@
> return true;
> break;
>
> - case ImplicitConversionSequence::UserDefinedConversion:
> - {
> + case ImplicitConversionSequence::UserDefinedConversion: {
> +
> FunctionDecl *FD = ICS.UserDefined.ConversionFunction;
> CastExpr::CastKind CastKind = CastExpr::CK_Unknown;
> - if (isa<CXXConversionDecl>(FD))
> + QualType BeforeToType;
> + if (const CXXConversionDecl *Conv =
> dyn_cast<CXXConversionDecl>(FD)) {
> CastKind = CastExpr::CK_UserDefinedConversion;
> - else if (isa<CXXConstructorDecl>(FD))
> +
> + // If the user-defined conversion is specified by a
> conversion function,
> + // the initial standard conversion sequence converts the
> source type to
> + // the implicit object parameter of the conversion function.
> + BeforeToType = Context.getTagDeclType(Conv->getParent());
This isn't quite right. The conversion function might be cv-
qualified, and we're not taking that into account here. Amusingly,
PerformObjectArgumentInitialization *also* seems to get that wrong.
Argh!
> + } else if (const CXXConstructorDecl *Ctor =
> + dyn_cast<CXXConstructorDecl>(FD)) {
> CastKind = CastExpr::CK_ConstructorConversion;
> +
> + // If the user-defined conversion is specified by a
> constructor, the
> + // initial standard conversion sequence converts the source
> type to the
> + // type required by the argument of the constructor
> + BeforeToType = Ctor->getParamDecl(0)->getType();
> + }
> else
> assert(0 && "Unknown conversion function kind!");
>
> + if (PerformImplicitConversion(From, BeforeToType,
> + ICS.UserDefined.Before,
> "converting"))
> + return true;
PerformCopyInitialization would be better here, because it handles
conversion to a reference type (e.g., reference binding), which is not
strictly an "implicit conversion".
- Doug
More information about the cfe-commits
mailing list