diff --git a/lib/Demangle/MicrosoftDemangle.cpp b/lib/Demangle/MicrosoftDemangle.cpp index 14c6e1e5ef5..4942e0e3655 100644 --- a/lib/Demangle/MicrosoftDemangle.cpp +++ b/lib/Demangle/MicrosoftDemangle.cpp @@ -1154,8 +1154,11 @@ static unsigned countEmbeddedNulls(const uint8_t *StringBytes, return Result; } +// A mangled (non-wide) string literal stores the total length of the string it +// refers to (passed in NumBytes), and it contains up to 32 bytes of actual text +// (passed in StringBytes, NumChars). static unsigned guessCharByteSize(const uint8_t *StringBytes, unsigned NumChars, - unsigned NumBytes) { + uint64_t NumBytes) { assert(NumBytes > 0); // If the number of bytes is odd, this is guaranteed to be a char string. diff --git a/test/Demangle/ms-string-literals.test b/test/Demangle/ms-string-literals.test index 0e9d1edea8a..43c03c1c51e 100644 --- a/test/Demangle/ms-string-literals.test +++ b/test/Demangle/ms-string-literals.test @@ -792,3 +792,8 @@ ??_C@_07LJGFEJEB@D3?$CC?$BB?$AA?$AA?$AA?$AA@) ; CHECK: U"\x11223344" + +; This has a string length of 0x6_0000_0000, so it's 0 if treated as a 32-bit +; number. (In practice, 24GiB large string literals should be rare.) +??_C@_0GAAAAAAAA@GPLEPFHO@01234567890123456789012345678901@ +; CHECK: "01234567890123456789012345678901"...