r247464 - [MS ABI] Select an inheritance model in template arguments
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 13:23:47 PDT 2015
On Fri, Sep 11, 2015 at 1:18 PM, David Majnemer via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: majnemer
> Date: Fri Sep 11 15:18:09 2015
> New Revision: 247464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247464&view=rev
> Log:
> [MS ABI] Select an inheritance model in template arguments
>
> We used to only select an inheritance model if the pointer to member was
> nullptr. Instead, select a model regardless of the member pointer's
> value.
>
> N.B. This bug was exposed by making member pointers report true for
> isIncompleteType but has been latent since the member pointer scheme's
> inception.
>
> Modified:
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247464&r1=247463&r2=247464&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep 11 15:18:09 2015
> @@ -4222,7 +4222,11 @@ isNullPointerValueTemplateArgument(Sema
> QualType ParamType, Expr *Arg) {
> if (Arg->isValueDependent() || Arg->isTypeDependent())
> return NPV_NotNullPointer;
> -
> +
> + if (ParamType->isMemberPointerType())
> + if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
> + S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
>
It seems simpler to unconditionally require the type to be complete.
> +
> if (!S.getLangOpts().CPlusPlus11)
> return NPV_NotNullPointer;
>
> @@ -4670,8 +4674,6 @@ static bool CheckTemplateArgumentPointer
> S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
> Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),
> /*isNullPtr*/true);
> - if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
> - S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
> return false;
> case NPV_NotNullPointer:
> break;
>
> Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247464&r1=247463&r2=247464&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Fri Sep 11
> 15:18:09 2015
> @@ -768,3 +768,14 @@ bool g(int J::*&p, int J::*&q) { return
> // CHECK-LABEL: @"\01?h at ReferenceToMPTWithIncompleteClass@@YAHAAPQK at 1@H at Z
> "(
> int h(int K::*&p) { return k->*p; }
> }
> +
> +namespace PMFInTemplateArgument {
> +template <class C, int (C::*M)(int)>
> +void JSMethod();
> +class A {
> + int printd(int);
> + void printd();
> +};
> +void A::printd() { JSMethod<A, &A::printd>(); }
> +// CHECK-LABEL: @"\01??$JSMethod at VA@PMFInTemplateArgument@@$1?printd at 12
> @AAEHH at Z@PMFInTemplateArgument@@YAXXZ"(
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150911/b1762051/attachment.html>
More information about the cfe-commits
mailing list