clang-cl: Fix mangling of catchable types with names longer than 4kiB

The mangling used to contain the MD5 name of both the RTTI type
descriptor and the name of the copy ctor in MSVC2013, but it changed
to just the former in 2015. It looks like it changed back to the old
mangling in VS2017 version 15.7 and onwards, including VS2019 (version
16.0). VS2017 version 15.0 still has the VS2015 mangling. Versions
between 15.0 and 15.7 are't on godbolt. I found 15.4 (_MSC_VER 1911)
locally and that uses the 15.0 mangling still, but I didn't find 15.5 or
15.6, so I'm not sure where exactly it changed back.

Differential Revision: https://reviews.llvm.org/D62490

llvm-svn: 361959
This commit is contained in:
Nico Weber 2019-05-29 13:48:19 +00:00
parent 24c5629625
commit e3b1f5d22c
3 changed files with 28 additions and 6 deletions

View File

@ -109,7 +109,8 @@ public:
MSVC2013 = 1800,
MSVC2015 = 1900,
MSVC2017 = 1910,
MSVC2017_5 = 1912
MSVC2017_5 = 1912,
MSVC2017_7 = 1914,
};
/// Clang versions with different platform ABI conformance.

View File

@ -3151,12 +3151,18 @@ void MicrosoftMangleContextImpl::mangleCXXCatchableType(
}
Mangler.getStream() << RTTIMangling;
// VS2015 CTP6 omits the copy-constructor in the mangled name. This name is,
// in fact, superfluous but I'm not sure the change was made consciously.
// VS2015 and VS2017.1 omit the copy-constructor in the mangled name but
// both older and newer versions include it.
// FIXME: It is known that the Ctor is present in 2013, and in 2017.7
// (_MSC_VER 1914) and newer, and that it's omitted in 2015 and 2017.4
// (_MSC_VER 1911), but it's unknown when exactly it reappeared (1914?
// Or 1912, 1913 aleady?).
bool OmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
LangOptions::MSVC2015) &&
!getASTContext().getLangOpts().isCompatibleWithMSVC(
LangOptions::MSVC2017_7);
llvm::SmallString<64> CopyCtorMangling;
if (!getASTContext().getLangOpts().isCompatibleWithMSVC(
LangOptions::MSVC2015) &&
CD) {
if (!OmitCopyCtor && CD) {
llvm::raw_svector_ostream Stream(CopyCtorMangling);
msvc_hashing_ostream MHO(Stream);
mangleCXXCtor(CD, CT, MHO);

File diff suppressed because one or more lines are too long