llvm.org GIT mirror llvm / ecefdcd
llvm-undname: Fix hex escapes in wchar_t, char16_t, char32_t strings llvm-undname used to put '\x' in front of every pair of nibbles, but u"\xD7\xFF" produces a string with 6 bytes: \xD7 \0 \xFF \0 (and \0\0). Correct for a single character (plus terminating \0) is u\xD7FF instead. Now, wchar_t, char16_t, and char32_t strings roundtrip from source to clang-cl (and cl.exe) and then llvm-undname. (...at least as long as it's not a string like L"\xD7FF" L"foo" which gets demangled as L"\xD7FFfoo", where the compiler then considers the "f" as part of the hex escape. That seems ok.) Also add a comment saying that the "almost-valid" char32_t string I added in my last commit is actually produced by compilers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358857 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 6 months ago
2 changed file(s) with 10 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
10781078 writeHexDigit(&TempBuffer[Pos--], C % 16);
10791079 C /= 16;
10801080 }
1081 TempBuffer[Pos--] = 'x';
1082 assert(Pos >= 0);
1083 TempBuffer[Pos--] = '\\';
1084 }
1081 }
1082 TempBuffer[Pos--] = 'x';
1083 assert(Pos >= 0);
1084 TempBuffer[Pos--] = '\\';
10851085 OS << StringView(&TempBuffer[Pos + 1]);
10861086 }
10871087
729729 ; CHECK: L"012345678901234567890123456789AB"...
730730
731731 ??_C@_13IIHIAFKH@?W?$PP?$AA?$AA@
732 ; CHECK: L"\xD7\xFF"
732 ; CHECK: L"\xD7FF"
733
734 ??_C@_03IIHIAFKH@?$PP?W?$AA?$AA@
735 ; CHECK: u"\xD7FF"
733736
734737 ??_C@_02PCEFGMJL@hi?$AA@
735738 ; CHECK: "hi"
784787 ; This is technically not a valid u32 string since the character in it is not
785788 ; <= 0x10FFFF like unicode demands. (Also, the crc doesn't match the contents.)
786789 ; It's here because this input used to cause a stack overflow in outputHex().
787
788 ; FIXME: The demangler currently writes for \x codes for a single U string
789 ; character. That's incorrect since that would mangle two four characters.
790 ; Both cl.exe and clang-cl produce it for `const char32_t* s = U"\x11223344";`
790791
791792 ??_C@_07LJGFEJEB@D3?$CC?$BB?$AA?$AA?$AA?$AA@)
792 ; CHECK: U"\x11\x22\x33\x44"
793 ; CHECK: U"\x11223344"