I was looking at Stream::PutRawBytes and thought I spotted a bug because both looks are using i < src_len as the loop condition despite them iterating "in different directions". On closer inspection, the existing code is correct, because it relies on well-defined unsigned integer wrapping of size_t. Correct doesn't mean readable, so this patch changes the loop condition to compare against 0 when decrementing i while still covering the edge case of src_len potentially being 0 itself.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lldb/source/Utility/Stream.cpp | ||
---|---|---|
360 | Intentional newline for consistency with Stream::PutRawBytes above. |
Comment Actions
Another option would be to go full-STL and do something like
ArrayRef<uint8_t> data(ptr, len); if (reverse) for (uint8_t byte: llvm::reverse(data)) ...
Intentional newline for consistency with Stream::PutRawBytes above.