[PATCH] D88824: [Support][unittests] Enforce alignment in ConvertUTFTest

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 10:24:34 PDT 2020


rnk added a comment.

I may have been the one that picked `ArrayRef<char>` as the parameter type here, and I think what I was thinking is: "files are full of bytes, the caller is most likely to have a bag of bytes that they want to hand to the re-encoding routine, so it should accept bytes, and I'll pick some arbitrary byte-like character type here". For example, MemoryBuffer gives you back a StringRef for the file contents, and you should be able to just plug that in here. MemoryBuffer probably happens to return aligned file contents in practice, but it doesn't advertise any alignment guarantee. So maybe the best fix is to underalign the UTF16 typedef, if that's possible. This is a serialization routine, after all: it should be really generous about what it accepts.



================
Comment at: llvm/unittests/Support/ConvertUTFTest.cpp:83
   // Src is the look of disapproval.
   static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
   ArrayRef<UTF16> SrcRef = makeArrayRef((const UTF16 *)Src, 4);
----------------
I think you just need to align this to reland.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88824/new/

https://reviews.llvm.org/D88824



More information about the llvm-commits mailing list