[PATCH] D88824: [Support][unittests] Enforce alignment in ConvertUTFTest
Rainer Orth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 06:43:34 PDT 2020
ro added inline comments.
================
Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:100
+ assert((uintptr_t)Src % sizeof(UTF16) == 0);
+
----------------
grimar wrote:
> I think more natural way is to test pre-conditions for arguments before using them?
> I.e. I'd move this line before `const UTF16 *Src =...`
>
> ```
> assert((uintptr_t)SrcBytes.begin() % sizeof(UTF16) == 0);
> ```
I had it before the casts initially (but without the `uintptr_t` cast, breaking the build). I moved it after to avoid doubling the `SrcBytes.begin()`, keeping the line shorter.
IMO `Src` is used only when dereferenced, but I'm fine either way.
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