diff options
author | Kevin Cadieux <kevca@microsoft.com> | 2022-06-29 09:06:46 -0700 |
---|---|---|
committer | Stella Stamenova <stilis@microsoft.com> | 2022-06-29 10:20:46 -0700 |
commit | a9bef0707db101bb72d000a1f09686d97fb2d35d (patch) | |
tree | 467bbb92f91fc1ef9bd7811ecb7acbb74dc987e6 /llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | |
parent | bf223e43fe68da22f185a12c1a2fe36a726f4fe9 (diff) | |
download | llvm-a9bef0707db101bb72d000a1f09686d97fb2d35d.zip llvm-a9bef0707db101bb72d000a1f09686d97fb2d35d.tar.gz llvm-a9bef0707db101bb72d000a1f09686d97fb2d35d.tar.bz2 |
[clang-format] Fix incorrect isspace input (NFC)
This change fixes a clang-format unit test failure introduced by [D124748](https://reviews.llvm.org/D124748). The `countLeadingWhitespace` function was calling `isspace` with values that could fall outside the valid input range. The valid input range for `isspace` is unsigned 0-255. Values outside this range produce undefined behavior, which on Windows manifests as an assertion being raised in the debug runtime libraries. `countLeadingWhitespace` was calling `isspace` with a signed char that could produce a negative value if the underlying byte's value was 128 or above, which can happen for non-ASCII encodings. The fix is to use `StringRef`'s `bytes_begin` and `bytes_end` iterators to read the values as unsigned chars instead.
This bug can be reproduced by building the `check-clang-unit` target with a DEBUG configuration under Windows. This change is already covered by existing unit tests.
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D128786
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp')
0 files changed, 0 insertions, 0 deletions