[all-commits] [llvm/llvm-project] 134ffa: NFC: Fix -Wsign-compare warnings on 32-bit builds

Hubert Tong via All-commits all-commits at lists.llvm.org
Tue Oct 20 17:52:28 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 134ffa8138c31444685013e10f592cd7c88d675b
      https://github.com/llvm/llvm-project/commit/134ffa8138c31444685013e10f592cd7c88d675b
  Author: Hubert Tong <hubert.reinterpretcast at gmail.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M llvm/lib/CodeGen/StackMaps.cpp

  Log Message:
  -----------
  NFC: Fix -Wsign-compare warnings on 32-bit builds

Comparing 32-bit `ptrdiff_t` against 32-bit `unsigned` results in
`-Wsign-compare` warnings for both GCC and Clang.

The warning for the cases in question appear to identify an issue
where the `ptrdiff_t` value would be mutated via conversion to an
unsigned type.

The warning is resolved by using the usual arithmetic conversions to
safely preserve the value of the `unsigned` operand while trying to
convert to a signed type. Host platforms where `unsigned` has the same
width as `unsigned long long` will need to make a different change, but
using an explicit cast has disadvantages that can be avoided for now.

Reviewed By: dantrushin

Differential Revision: https://reviews.llvm.org/D89612




More information about the All-commits mailing list