diff options
author | CarlosAlbertoEnciso <carlos.alberto.enciso@gmail.com> | 2021-06-15 06:52:50 +0100 |
---|---|---|
committer | CarlosAlbertoEnciso <carlos.alberto.enciso@gmail.com> | 2021-06-15 06:53:21 +0100 |
commit | d0a5d8611935b548e1ec546b49201d47ac0a762c (patch) | |
tree | 1283a05eb4ac62f72a8e102b4ba8709a7b44aa50 /llvm/lib/DebugInfo/CodeView/Formatters.cpp | |
parent | 68c161090ef6fe83218af6f627170ae56e5800b1 (diff) | |
download | llvm-d0a5d8611935b548e1ec546b49201d47ac0a762c.zip llvm-d0a5d8611935b548e1ec546b49201d47ac0a762c.tar.gz llvm-d0a5d8611935b548e1ec546b49201d47ac0a762c.tar.bz2 |
[Debug-Info][CodeView] Fix GUID string generation for MSVC generated objects.
This patch is to address https://bugs.llvm.org/show_bug.cgi?id=50459.
YAML:455:28: error: GUID strings are 38 characters long
The valid format for a GUID is {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
where X is a hex digit (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
The length of the individual components must be: 8, 4, 4, 4, 12.
For some cases, the converted string generated by obj2yaml, does not
comply with those lengths. yaml2obj checks that the GUID string must
be 38 characters including the dashes and braces.
Reviewed By: amccarth
Differential Revision: https://reviews.llvm.org/D103089
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/Formatters.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/Formatters.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/Formatters.cpp b/llvm/lib/DebugInfo/CodeView/Formatters.cpp index 3a67f31..f1f51bc 100644 --- a/llvm/lib/DebugInfo/CodeView/Formatters.cpp +++ b/llvm/lib/DebugInfo/CodeView/Formatters.cpp @@ -23,6 +23,17 @@ GuidAdapter::GuidAdapter(StringRef Guid) GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid) : FormatAdapter(std::move(Guid)) {} +// From https://docs.microsoft.com/en-us/windows/win32/msi/guid documentation: +// The GUID data type is a text string representing a Class identifier (ID). +// All GUIDs must be authored in uppercase. +// The valid format for a GUID is {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} where +// X is a hex digit (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). +// +// The individual string components must be padded to comply with the specific +// lengths of {8-4-4-4-12} characters. +// The llvm-yaml2obj tool checks that a GUID follow that format: +// - the total length to be 38 (including the curly braces. +// - there is a dash at the positions: 8, 13, 18 and 23. void GuidAdapter::format(raw_ostream &Stream, StringRef Style) { assert(Item.size() == 16 && "Expected 16-byte GUID"); struct MSGuid { @@ -33,11 +44,11 @@ void GuidAdapter::format(raw_ostream &Stream, StringRef Style) { }; const MSGuid *G = reinterpret_cast<const MSGuid *>(Item.data()); Stream - << '{' << format_hex_no_prefix(G->Data1, sizeof(G->Data1), /*Upper=*/true) - << '-' << format_hex_no_prefix(G->Data2, sizeof(G->Data2), /*Upper=*/true) - << '-' << format_hex_no_prefix(G->Data3, sizeof(G->Data3), /*Upper=*/true) - << '-' << format_hex_no_prefix(G->Data4 >> 48, 2, /*Upper=*/true) << '-' - << format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 6, /*Upper=*/true) + << '{' << format_hex_no_prefix(G->Data1, 8, /*Upper=*/true) + << '-' << format_hex_no_prefix(G->Data2, 4, /*Upper=*/true) + << '-' << format_hex_no_prefix(G->Data3, 4, /*Upper=*/true) + << '-' << format_hex_no_prefix(G->Data4 >> 48, 4, /*Upper=*/true) << '-' + << format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 12, /*Upper=*/true) << '}'; } |