[clang-tools-extra] [clang-tidy][NFC] Clean up and slightly optimize `modernize-use-integer-sign-comparison` (PR #163492)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 15 14:54:44 PDT 2025
================
@@ -119,23 +118,16 @@ void UseIntegerSignComparisonCheck::check(
Expr::EvalResult EVResult;
if (!SignedCastExpression->isValueDependent() &&
SignedCastExpression->getSubExpr()->EvaluateAsInt(EVResult,
- *Result.Context)) {
- const llvm::APSInt SValue = EVResult.Val.getInt();
- if (SValue.isNonNegative())
- return;
- }
+ *Result.Context) &&
+ EVResult.Val.getInt().isNonNegative())
+ return;
const auto *BinaryOp =
Result.Nodes.getNodeAs<BinaryOperator>("intComparison");
- if (BinaryOp == nullptr)
- return;
-
- const BinaryOperator::Opcode OpCode = BinaryOp->getOpcode();
+ assert(BinaryOp);
const Expr *LHS = BinaryOp->getLHS()->IgnoreImpCasts();
const Expr *RHS = BinaryOp->getRHS()->IgnoreImpCasts();
- if (LHS == nullptr || RHS == nullptr)
- return;
----------------
localspook wrote:
I would be surprised if it did; in my understanding, all it does is optionally skip past some AST nodes, so what would cause it to return null? (It would be good to check though, yep)
https://github.com/llvm/llvm-project/pull/163492
More information about the cfe-commits
mailing list