[clang] [Clang][CIR] Replace -1ULL with std::numeric_limits in Itanium CXXABI (PR #178225)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 27 09:44:53 PST 2026


================
@@ -1939,7 +1941,7 @@ static CharUnits computeOffsetHint(ASTContext &astContext,
       // If the path contains a virtual base class we can't give any hint.
       // -1: no hint.
       if (pathElement.Base->isVirtual())
-        return CharUnits::fromQuantity(-1ULL);
+        return CharUnits::fromQuantity( std::numeric_limits<uint64_t>::max());
----------------
andykaylor wrote:

>From https://github.com/llvm/llvm-project/issues/147439:

> While some uses of this pattern are technically correct—such as using -1ULL to represent a binary value of all 1s—these cases are often clearer and more intentional when written using alternatives like ~0ULL or std::numeric_limits::max(). These forms improve readability and reduce the risk of misinterpretation by reviewers and static analysis tools.

The use of `-1ULL` here is intended to represent `-1`, not an all 1s value. Something to watch out for as you clean up more of these.

https://github.com/llvm/llvm-project/pull/178225


More information about the cfe-commits mailing list