diff --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp index 6b23f7cd4a9c86..beca3933bcd230 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp @@ -165,7 +165,7 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) { Expr::EvalResult ConstPtr; if (!Ptr->isInstantiationDependent() && Ptr->EvaluateAsRValue(ConstPtr, Ctx) && - ((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isNullValue()) || + ((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isZero()) || (ConstPtr.Val.isLValue() && ConstPtr.Val.isNullPointer()))) { diag(Loc, "constructing string from nullptr is undefined behaviour"); } diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 0ac36708f07749..3cfbfb670403b7 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2757,8 +2757,8 @@ static bool handleIntIntBinOp(EvalInfo &Info, const Expr *E, const APSInt &LHS, Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS); // Check for overflow case: INT_MIN / -1 or INT_MIN % -1. APSInt supports // this operation and gives the two's complement result. - if (RHS.isNegative() && RHS.isAllOnesValue() && - LHS.isSigned() && LHS.isMinSignedValue()) + if (RHS.isNegative() && RHS.isAllOnes() && LHS.isSigned() && + LHS.isMinSignedValue()) return HandleOverflow(Info, E, -LHS.extend(LHS.getBitWidth() + 1), E->getType()); return true; @@ -15324,7 +15324,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) { llvm::APSInt REval = Exp->getRHS()->EvaluateKnownConstInt(Ctx); if (REval == 0) return ICEDiag(IK_ICEIfUnevaluated, E->getBeginLoc()); - if (REval.isSigned() && REval.isAllOnesValue()) { + if (REval.isSigned() && REval.isAllOnes()) { llvm::APSInt LEval = Exp->getLHS()->EvaluateKnownConstInt(Ctx); if (LEval.isMinSignedValue()) return ICEDiag(IK_ICEIfUnevaluated, E->getBeginLoc()); diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp index caf938a5b9582d..176c0407278315 100644 --- a/clang/lib/AST/OpenMPClause.cpp +++ b/clang/lib/AST/OpenMPClause.cpp @@ -2313,9 +2313,8 @@ void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx, if (Optional CondVal = Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)) - VMI.addTrait(CondVal->isNullValue() - ? TraitProperty::user_condition_false - : TraitProperty::user_condition_true, + VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false + : TraitProperty::user_condition_true, ""); else VMI.addTrait(TraitProperty::user_condition_false, ""); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 6bef004987828a..ed485ed6f5d15a 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1647,7 +1647,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { for (unsigned i = 2; i < E->getNumSubExprs(); ++i) { llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2); // Check for -1 and output it as undef in the IR. - if (Idx.isSigned() && Idx.isAllOnesValue()) + if (Idx.isSigned() && Idx.isAllOnes()) Indices.push_back(-1); else Indices.push_back(Idx.getZExtValue()); diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index e3ae2ebd44a0d5..64fad46323cbc8 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -1357,7 +1357,7 @@ bool NumericLiteralParser::GetFixedPointValue(llvm::APInt &StoreVal, unsigned Sc Val *= Base; } } else if (BaseShift < 0) { - for (int64_t i = BaseShift; i < 0 && !Val.isNullValue(); ++i) + for (int64_t i = BaseShift; i < 0 && !Val.isZero(); ++i) Val = Val.udiv(Base); } diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 66450f61c091e9..207b28ec597274 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1729,7 +1729,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, // value so we bail out. if (SizeOp->isValueDependent()) break; - if (!SizeOp->EvaluateKnownConstInt(Context).isNullValue()) { + if (!SizeOp->EvaluateKnownConstInt(Context).isZero()) { CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc()); CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc()); } @@ -6776,7 +6776,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { << TheCall->getArg(i)->getSourceRange()); // Allow -1 which will be translated to undef in the IR. - if (Result->isSigned() && Result->isAllOnesValue()) + if (Result->isSigned() && Result->isAllOnes()) continue; if (Result->getActiveBits() > 64 || diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index aedfc07c466dc2..6b95e9c8bcd9de 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3813,7 +3813,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { llvm::APInt Val(bit_width, 0, isSigned); bool Overflowed = Literal.GetFixedPointValue(Val, scale); - bool ValIsZero = Val.isNullValue() && !Overflowed; + bool ValIsZero = Val.isZero() && !Overflowed; auto MaxVal = Context.getFixedPointMax(Ty).getValue(); if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero) @@ -5254,7 +5254,7 @@ ExprResult Sema::ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, // OpenMP 5.0, 2.1.6 Iterators, Restrictions // If the step expression of a range-specification equals zero, the // behavior is unspecified. - if (Result && Result->isNullValue()) { + if (Result && Result->isZero()) { Diag(Step->getExprLoc(), diag::err_omp_iterator_step_constant_zero) << Step << Step->getSourceRange(); IsCorrect = false; diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 3a1249b7a7ff0a..55f36611a64f8f 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -18895,7 +18895,7 @@ class MapBaseChecker final : public StmtVisitor { Expr::EvalResult ResultL; if (!OASE->getLength()->isValueDependent() && OASE->getLength()->EvaluateAsInt(ResultR, SemaRef.getASTContext()) && - !ResultR.Val.getInt().isOneValue()) { + !ResultR.Val.getInt().isOne()) { SemaRef.Diag(OASE->getLength()->getExprLoc(), diag::err_omp_invalid_map_this_expr); SemaRef.Diag(OASE->getLength()->getExprLoc(), diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp index 73283779223747..11e4afcfaffff7 100644 --- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -794,7 +794,7 @@ DefinedOrUnknownSVal MemRegionManager::getStaticSize(const MemRegion *MR, const AnalyzerOptions &Opts = SVB.getAnalyzerOptions(); if (Opts.ShouldConsiderSingleElementArraysAsFlexibleArrayMembers && - Size.isOneValue()) + Size.isOne()) return true; } return false; diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 69554576bdb2e0..c972494f42623d 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -1568,7 +1568,7 @@ class ConstraintAssignor : public ConstraintAssignorBase { assert(!Constraint.isEmpty() && "Empty ranges shouldn't get here"); if (Constraint.getConcreteValue()) - return !Constraint.getConcreteValue()->isNullValue(); + return !Constraint.getConcreteValue()->isZero(); APSIntType T{Constraint.getMinValue()}; Const Zero = T.getZeroValue(); diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp index fcb658549f5538..681a1f64eadc10 100644 --- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -128,14 +128,14 @@ SVal SimpleSValBuilder::MakeSymIntVal(const SymExpr *LHS, // a&0 and a&(~0) if (RHS == 0) return makeIntVal(0, resultTy); - else if (RHS.isAllOnesValue()) + else if (RHS.isAllOnes()) isIdempotent = true; break; case BO_Or: // a|0 and a|(~0) if (RHS == 0) isIdempotent = true; - else if (RHS.isAllOnesValue()) { + else if (RHS.isAllOnes()) { const llvm::APSInt &Result = BasicVals.Convert(resultTy, RHS); return nonloc::ConcreteInt(Result); } @@ -509,7 +509,7 @@ SVal SimpleSValBuilder::evalBinOpNN(ProgramStateRef state, continue; case BO_Shr: // (~0)>>a - if (LHSValue.isAllOnesValue() && LHSValue.isSigned()) + if (LHSValue.isAllOnes() && LHSValue.isSigned()) return evalCast(lhs, resultTy, QualType{}); LLVM_FALLTHROUGH; case BO_Shl: