r232609 - MS ABI: Empty pack expansions had their mangling changed in 2013->2015
David Majnemer
david.majnemer at gmail.com
Tue Mar 17 20:56:28 PDT 2015
Author: majnemer
Date: Tue Mar 17 22:56:27 2015
New Revision: 232609
URL: http://llvm.org/viewvc/llvm-project?rev=232609&view=rev
Log:
MS ABI: Empty pack expansions had their mangling changed in 2013->2015
We used to support the 2013 mangling and changed it to the more
reasonable 2015 mangling. Let's make the mangling conditional on what
version of MSVC is targeted.
This fixes PR21888.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=232609&r1=232608&r2=232609&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Mar 17 22:56:27 2015
@@ -118,6 +118,10 @@ public:
!ObjCSubscriptingLegacyRuntime;
}
+ bool isCompatibleWithMSVC(unsigned MajorVersion) const {
+ return MSCompatibilityVersion >= MajorVersion * 10000000U;
+ }
+
/// \brief Reset all of the options that are not considered when building a
/// module.
void resetNonModularOptions();
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=232609&r1=232608&r2=232609&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Mar 17 22:56:27 2015
@@ -1203,7 +1203,11 @@ void MicrosoftCXXNameMangler::mangleTemp
if (TemplateArgs.empty()) {
if (isa<TemplateTypeParmDecl>(Parm) ||
isa<TemplateTemplateParmDecl>(Parm))
- Out << "$$V";
+ // MSVC 2015 changed the mangling for empty expanded template packs,
+ // use the old mangling for link compatibility for old versions.
+ Out << (Context.getASTContext().getLangOpts().isCompatibleWithMSVC(19)
+ ? "$$V"
+ : "$$$V");
else if (isa<NonTypeTemplateParmDecl>(Parm))
Out << "$S";
else
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=232609&r1=232608&r2=232609&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Tue Mar 17 22:56:27 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck %s --check-prefix=CHECK --check-prefix=MSVC2015
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=18.00 | FileCheck %s --check-prefix=CHECK --check-prefix=MSVC2013
namespace FTypeWithQuals {
template <typename T>
@@ -218,13 +219,15 @@ template <typename...>
void templ_fun_with_ty_pack() {}
template void templ_fun_with_ty_pack<>();
-// CHECK-DAG: @"\01??$templ_fun_with_ty_pack@$$V@@YAXXZ"
+// MSVC2013-DAG: @"\01??$templ_fun_with_ty_pack@$$$V@@YAXXZ"
+// MSVC2015-DAG: @"\01??$templ_fun_with_ty_pack@$$V@@YAXXZ"
template <template <class> class...>
void templ_fun_with_templ_templ_pack() {}
template void templ_fun_with_templ_templ_pack<>();
-// CHECK-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$V@@YAXXZ"
+// MSVC2013-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$$V@@YAXXZ"
+// MSVC2015-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$V@@YAXXZ"
namespace PR20047 {
template <typename T>
More information about the cfe-commits
mailing list