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

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 08:05:29 PDT 2020


thopre marked 2 inline comments as done.
thopre added inline comments.


================
Comment at: llvm/lib/Support/FileCheckImpl.h:127
+  bool isNegative() const {
+    return Signed && (Value & (1LLU << (sizeof(Value) * CHAR_BIT - 1)));
+  }
----------------
arichardson wrote:
> 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.
architecture -> system, surely the compiler can mess things up as well? It's such a shame that there isn't a better way to achieve this while being perfectly well defined.


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