bool
MicrosoftMangleContextImpl::shouldMangleStringLiteral(const StringLiteral *SL) {
- return SL->isAscii() || SL->isWide();
- // TODO: This needs to be updated when MSVC gains support for Unicode
- // literals.
+ return SL->isAscii() || SL->isWide() || SL->isUTF16() || SL->isUTF32();
}
void MicrosoftCXXNameMangler::mangle(const NamedDecl *D, StringRef Prefix) {
Mangler.getStream() << "\01??_C@_";
// <char-type>: The "kind" of string literal is encoded into the mangled name.
- // TODO: This needs to be updated when MSVC gains support for unicode
- // literals.
- if (SL->isAscii())
- Mangler.getStream() << '0';
- else if (SL->isWide())
+ if (SL->isWide())
Mangler.getStream() << '1';
else
- llvm_unreachable("unexpected string literal kind!");
+ Mangler.getStream() << '0';
// <literal-length>: The next part of the mangled name consists of the length
// of the string.
unsigned NumCharsToMangle = std::min(32U, SL->getLength());
for (unsigned I = 0, E = NumCharsToMangle * SL->getCharByteWidth(); I != E;
++I)
- MangleByte(GetBigEndianByte(I));
+ if (SL->isWide())
+ MangleByte(GetBigEndianByte(I));
+ else
+ MangleByte(GetLittleEndianByte(I));
// Encode the NUL terminator if there is room.
if (NumCharsToMangle < 32)
// CHECK: @"\01??_C@_1EK@KFPEBLPK@?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AAA?$AAB@"
const wchar_t *UnicodeLiteral = L"\ud7ff";
// CHECK: @"\01??_C@_13IIHIAFKH@?W?$PP?$AA?$AA@"
+const char16_t *U16Literal = u"hi";
+// CHECK: @"\01??_C@_05OMLEGLOC@h?$AAi?$AA?$AA?$AA@"
+const char32_t *U32Literal = U"hi";
+// CHECK: @"\01??_C@_0M@GFNAJIPG@h?$AA?$AA?$AAi?$AA?$AA?$AA?$AA?$AA?$AA?$AA@"