SPIRV-Tools/source/util
Marius Hillenbrand 1ed847f438
Fix endianness of string literals (#4622)
* Fix endianness of string literals

To get correct and consistent encoding and decoding of string literals
on big-endian platforms, use spvtools::utils::MakeString and MakeVector
(or wrapper functions) consistently for handling string literals.

- add variant of MakeVector that encodes a string literal into an
  existing vector of words
- add variants of MakeString
- add a wrapper spvDecodeLiteralStringOperand in source/
- fix wrapper Operand::AsString to use MakeString (source/opt)
- remove Operand::AsCString as broken and unused
- add a variant of GetOperandAs for string literals (source/val)
... and apply those wrappers throughout the code.

Fixes  #149

* Extend round trip test for StringLiterals to flip word order

In the encoding/decoding roundtrip tests for string literals, include
a case that flips byte order in words after encoding and then checks for
successful decoding. That is, on a little-endian host flip to big-endian
byte order and then decode, and vice versa.

* BinaryParseTest.InstructionWithStringOperand: also flip byte order

Test binary parsing of string operands both with the host's and with the
reversed byte order.
2021-12-08 12:01:26 -05:00
..
bit_vector.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
bit_vector.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
bitutils.h Support constant-folding UConvert and SConvert (#2960) 2019-10-16 16:29:55 -04:00
hex_float.h Avoid uninitialised read when parsing hex float (#4646) 2021-12-08 11:09:25 -05:00
ilist_node.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
ilist.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
make_unique.h Use MakeUnique. (#1837) 2018-08-14 15:01:50 -04:00
parse_number.cpp Use MakeUnique. (#1837) 2018-08-14 15:01:50 -04:00
parse_number.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
small_vector.h Use MakeUnique. (#1837) 2018-08-14 15:01:50 -04:00
string_utils.cpp Add option for the max id bound. (#1870) 2018-09-10 11:49:41 -04:00
string_utils.h Fix endianness of string literals (#4622) 2021-12-08 12:01:26 -05:00
timer.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
timer.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00