[PATCH] D60390: FileCheck [10/12]: Add support for signed numeric values

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 07:32:41 PDT 2020


arichardson added inline comments.


================
Comment at: llvm/lib/Support/FileCheckImpl.h:127
+  bool isNegative() const {
+    return Signed && (Value & (1LLU << (sizeof(Value) * CHAR_BIT - 1)));
+  }
----------------
thopre wrote:
> arichardson wrote:
> > `Signed && (int64_t)Value < 0`?
> Casting to int64_t is implementation-defined if Value is > std::numeric_limits<int64_t>::max(). That said current code assumes 2-complement so I've changed for memcpy. Hopefully the compiler can elide that call.
Yes it definitely can (even at -O1): https://godbolt.org/z/5jcz9L
I'm still not sure that it's possible that casting gives a different value from memcpy on any architecture that LLVM builds on, but I'm also fine with the memcpy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60390





More information about the llvm-commits mailing list