[PATCH] D37494: Change encodeU/SLEB128 to pad to certain number of bytes

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 5 16:12:34 PDT 2017


ruiu added a comment.

The new function may write more bytes than `PadTo` bytes, so it seems the only reliable way of using it is to pass 5 as `PadTo`. Is there any other use case than that?



================
Comment at: include/llvm/Support/LEB128.h:22-24
 /// Utility function to encode a SLEB128 value to an output stream.
 inline void encodeSLEB128(int64_t Value, raw_ostream &OS,
+                          unsigned PadTo = 0) {
----------------
It is perhaps a matter of personal taste, but it feels `Len` is a better name than `PadTo`. I'd also add a comment that if an encoded number of shorter than Len bytes, it is padded so that it becomes Len bytes in total.


https://reviews.llvm.org/D37494





More information about the llvm-commits mailing list