[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)
Yutong Zhu via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 23 15:20:36 PST 2025
================
@@ -10069,6 +10069,17 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
case UO_AddrOf: // should be impossible
return IntRange::forValueOfType(C, GetExprType(E));
+ case UO_Not: {
+ std::optional<IntRange> SubRange = TryGetExprRange(
+ C, UO->getSubExpr(), MaxWidth, InConstantContext, Approximate);
+ if (!SubRange)
+ return std::nullopt;
+
+ // The width increments by 1 if the sub-expression cannot be negative
+ // since it now can be.
+ return IntRange(SubRange->Width + (int)SubRange->NonNegative, false);
----------------
YutongZhuu wrote:
Fixed as suggested. Thanks for the help!
https://github.com/llvm/llvm-project/pull/126846
More information about the cfe-commits
mailing list