From: David Majnemer Date: Tue, 1 Dec 2015 19:13:51 +0000 (+0000) Subject: [MS ABI] Correctly mangle nullptr member pointers for variable templates X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ac6ada6033761ebc3c26561fa50d0fdaa47474a;p=clang [MS ABI] Correctly mangle nullptr member pointers for variable templates Variable templates behave the same as class templates with regard to nullptr memeber pointers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254439 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 01e17588fe..c1c2d2d1a4 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -697,7 +697,6 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, // Function templates aren't considered for name back referencing. This // makes sense since function templates aren't likely to occur multiple // times in a symbol. - // FIXME: Test alias template mangling with MSVC 2013. if (!isa(TD)) { mangleTemplateInstantiationName(TD, *TemplateArgs); Out << '@'; @@ -1226,12 +1225,13 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, QualType T = TA.getNullPtrType(); if (const MemberPointerType *MPT = T->getAs()) { const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl(); - if (MPT->isMemberFunctionPointerType() && isa(TD)) { + if (MPT->isMemberFunctionPointerType() && + !isa(TD)) { mangleMemberFunctionPointer(RD, nullptr); return; } if (MPT->isMemberDataPointer()) { - if (isa(TD)) { + if (!isa(TD)) { mangleMemberDataPointer(RD, nullptr); return; } diff --git a/test/CodeGenCXX/mangle-ms-cxx14.cpp b/test/CodeGenCXX/mangle-ms-cxx14.cpp index 51627dd89e..d649c59aed 100644 --- a/test/CodeGenCXX/mangle-ms-cxx14.cpp +++ b/test/CodeGenCXX/mangle-ms-cxx14.cpp @@ -3,27 +3,27 @@ template int x = 0; -// CHECK: "\01??$x@X@@3HA" +// CHECK-DAG: "\01??$x@X@@3HA" template <> int x; -// CHECK: "\01??$x@H@@3HA" +// CHECK-DAG: "\01??$x@H@@3HA" template <> int x; -// CHECK: "\01?FunctionWithLocalType@@YA?A?@@XZ" +// CHECK-DAG: "\01?FunctionWithLocalType@@YA?A?@@XZ" auto FunctionWithLocalType() { struct LocalType {}; return LocalType{}; } -// CHECK: "\01?ValueFromFunctionWithLocalType@@3ULocalType@?1??FunctionWithLocalType@@YA?A?@@XZ@A" +// CHECK-DAG: "\01?ValueFromFunctionWithLocalType@@3ULocalType@?1??FunctionWithLocalType@@YA?A?@@XZ@A" auto ValueFromFunctionWithLocalType = FunctionWithLocalType(); -// CHECK: "\01??R@@QBE?A?@@XZ" +// CHECK-DAG: "\01??R@@QBE?A?@@XZ" auto LambdaWithLocalType = [] { struct LocalType {}; return LocalType{}; }; -// CHECK: "\01?ValueFromLambdaWithLocalType@@3ULocalType@?1???R@@QBE?A?@@XZ@A" +// CHECK-DAG: "\01?ValueFromLambdaWithLocalType@@3ULocalType@?1???R@@QBE?A?@@XZ@A" auto ValueFromLambdaWithLocalType = LambdaWithLocalType(); template @@ -39,6 +39,13 @@ auto TemplateFuncionWithLocalLambda(T) { // MSVC2013-DAG: "\01?ValueFromTemplateFuncionWithLocalLambda@@3ULocalType@?2???R@??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z@QBE?A?3@XZ@A" // MSVC2015-DAG: "\01?ValueFromTemplateFuncionWithLocalLambda@@3ULocalType@?1???R@??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z@QBE?A?3@XZ@A" // MSVC2015-DAG: "\01?ValueFromTemplateFuncionWithLocalLambda@@3ULocalType@?1???R@??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z@QBE?A?3@XZ@A" -// CHECK: "\01??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z" -// CHECK: "\01??R@??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z@QBE?A?1@XZ" +// CHECK-DAG: "\01??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z" +// CHECK-DAG: "\01??R@??$TemplateFuncionWithLocalLambda@H@@YA?A?@@H@Z@QBE?A?1@XZ" auto ValueFromTemplateFuncionWithLocalLambda = TemplateFuncionWithLocalLambda(0); + +struct S; +template +int WithPMD = 0; + +template <> int WithPMD; +// CHECK-DAG: "\01??$WithPMD@$GA@A@?0@@3HA"