[PATCH] D64281: [Object] Create MutableELFObject Class for Doing Mutations on ELFObjectFiles [Part 1]

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 23:01:00 PDT 2019


abrachet added a comment.

In D64281#1640799 <https://reviews.llvm.org/D64281#1640799>, @jhenderson wrote:

> In D64281#1640474 <https://reviews.llvm.org/D64281#1640474>, @abrachet wrote:
>
> > I've been thinking about this, is `size_t` safe to use? Some methods from inherited classes use `uint64_t` on my machine its fine because even `unsigned long` and `unsigned long long` have the same width and sign but on a 32 bit machine I think that assigning to a `size_t` (which is guaranteed to be word size, I think) from a `uint64_t` might produce a warning. I don't think there are any examples in this patch, but this seemed like the best place to ask.
>
>
> You should use size_t and consider casting for cases using uint64_t. In a 32-bit build, size_t is usually a 32-bit number (i.e. `unsigned int`), so theoretically, the compiler could produce warnings for truncation issues when converting from a uint64_t. Since the main thing these indexes are used for is for accessing a vector, the type should match the argument type of `std::vector<T>::operator[]`, which is (usually) a `size_t`.


@MaskRay In the past I remember you finding usages on certain types (or similar) in the code base. Is there some kind of tool you use that could search every time a function that takes a `size_t` but is called with a `unit64_t`? Do you use `clang-query` for these kinds of things?


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

https://reviews.llvm.org/D64281





More information about the llvm-commits mailing list