Skip to content

Commit d933ade

Browse files
committed
[APInt] Stop using soft-deprecated constructors and methods in clang. NFC.
Stop using APInt constructors and methods that were soft-deprecated in D109483. This fixes all the uses I found in clang. Differential Revision: https://reviews.llvm.org/D110808
1 parent a9bceb2 commit d933ade

File tree

11 files changed

+18
-19
lines changed

11 files changed

+18
-19
lines changed

clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) {
165165
Expr::EvalResult ConstPtr;
166166
if (!Ptr->isInstantiationDependent() &&
167167
Ptr->EvaluateAsRValue(ConstPtr, Ctx) &&
168-
((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isNullValue()) ||
168+
((ConstPtr.Val.isInt() && ConstPtr.Val.getInt().isZero()) ||
169169
(ConstPtr.Val.isLValue() && ConstPtr.Val.isNullPointer()))) {
170170
diag(Loc, "constructing string from nullptr is undefined behaviour");
171171
}

clang/lib/AST/ExprConstant.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,8 +2757,8 @@ static bool handleIntIntBinOp(EvalInfo &Info, const Expr *E, const APSInt &LHS,
27572757
Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS);
27582758
// Check for overflow case: INT_MIN / -1 or INT_MIN % -1. APSInt supports
27592759
// this operation and gives the two's complement result.
2760-
if (RHS.isNegative() && RHS.isAllOnesValue() &&
2761-
LHS.isSigned() && LHS.isMinSignedValue())
2760+
if (RHS.isNegative() && RHS.isAllOnes() && LHS.isSigned() &&
2761+
LHS.isMinSignedValue())
27622762
return HandleOverflow(Info, E, -LHS.extend(LHS.getBitWidth() + 1),
27632763
E->getType());
27642764
return true;
@@ -15324,7 +15324,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
1532415324
llvm::APSInt REval = Exp->getRHS()->EvaluateKnownConstInt(Ctx);
1532515325
if (REval == 0)
1532615326
return ICEDiag(IK_ICEIfUnevaluated, E->getBeginLoc());
15327-
if (REval.isSigned() && REval.isAllOnesValue()) {
15327+
if (REval.isSigned() && REval.isAllOnes()) {
1532815328
llvm::APSInt LEval = Exp->getLHS()->EvaluateKnownConstInt(Ctx);
1532915329
if (LEval.isMinSignedValue())
1533015330
return ICEDiag(IK_ICEIfUnevaluated, E->getBeginLoc());

clang/lib/AST/OpenMPClause.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,9 +2313,8 @@ void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx,
23132313

23142314
if (Optional<APSInt> CondVal =
23152315
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2316-
VMI.addTrait(CondVal->isNullValue()
2317-
? TraitProperty::user_condition_false
2318-
: TraitProperty::user_condition_true,
2316+
VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2317+
: TraitProperty::user_condition_true,
23192318
"<condition>");
23202319
else
23212320
VMI.addTrait(TraitProperty::user_condition_false, "<condition>");

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
16471647
for (unsigned i = 2; i < E->getNumSubExprs(); ++i) {
16481648
llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
16491649
// Check for -1 and output it as undef in the IR.
1650-
if (Idx.isSigned() && Idx.isAllOnesValue())
1650+
if (Idx.isSigned() && Idx.isAllOnes())
16511651
Indices.push_back(-1);
16521652
else
16531653
Indices.push_back(Idx.getZExtValue());

clang/lib/Lex/LiteralSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ bool NumericLiteralParser::GetFixedPointValue(llvm::APInt &StoreVal, unsigned Sc
13571357
Val *= Base;
13581358
}
13591359
} else if (BaseShift < 0) {
1360-
for (int64_t i = BaseShift; i < 0 && !Val.isNullValue(); ++i)
1360+
for (int64_t i = BaseShift; i < 0 && !Val.isZero(); ++i)
13611361
Val = Val.udiv(Base);
13621362
}
13631363

clang/lib/Sema/SemaChecking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
17291729
// value so we bail out.
17301730
if (SizeOp->isValueDependent())
17311731
break;
1732-
if (!SizeOp->EvaluateKnownConstInt(Context).isNullValue()) {
1732+
if (!SizeOp->EvaluateKnownConstInt(Context).isZero()) {
17331733
CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
17341734
CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
17351735
}
@@ -6776,7 +6776,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
67766776
<< TheCall->getArg(i)->getSourceRange());
67776777

67786778
// Allow -1 which will be translated to undef in the IR.
6779-
if (Result->isSigned() && Result->isAllOnesValue())
6779+
if (Result->isSigned() && Result->isAllOnes())
67806780
continue;
67816781

67826782
if (Result->getActiveBits() > 64 ||

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3813,7 +3813,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
38133813

38143814
llvm::APInt Val(bit_width, 0, isSigned);
38153815
bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3816-
bool ValIsZero = Val.isNullValue() && !Overflowed;
3816+
bool ValIsZero = Val.isZero() && !Overflowed;
38173817

38183818
auto MaxVal = Context.getFixedPointMax(Ty).getValue();
38193819
if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
@@ -5254,7 +5254,7 @@ ExprResult Sema::ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc,
52545254
// OpenMP 5.0, 2.1.6 Iterators, Restrictions
52555255
// If the step expression of a range-specification equals zero, the
52565256
// behavior is unspecified.
5257-
if (Result && Result->isNullValue()) {
5257+
if (Result && Result->isZero()) {
52585258
Diag(Step->getExprLoc(), diag::err_omp_iterator_step_constant_zero)
52595259
<< Step << Step->getSourceRange();
52605260
IsCorrect = false;

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18895,7 +18895,7 @@ class MapBaseChecker final : public StmtVisitor<MapBaseChecker, bool> {
1889518895
Expr::EvalResult ResultL;
1889618896
if (!OASE->getLength()->isValueDependent() &&
1889718897
OASE->getLength()->EvaluateAsInt(ResultR, SemaRef.getASTContext()) &&
18898-
!ResultR.Val.getInt().isOneValue()) {
18898+
!ResultR.Val.getInt().isOne()) {
1889918899
SemaRef.Diag(OASE->getLength()->getExprLoc(),
1890018900
diag::err_omp_invalid_map_this_expr);
1890118901
SemaRef.Diag(OASE->getLength()->getExprLoc(),

clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ DefinedOrUnknownSVal MemRegionManager::getStaticSize(const MemRegion *MR,
794794

795795
const AnalyzerOptions &Opts = SVB.getAnalyzerOptions();
796796
if (Opts.ShouldConsiderSingleElementArraysAsFlexibleArrayMembers &&
797-
Size.isOneValue())
797+
Size.isOne())
798798
return true;
799799
}
800800
return false;

clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ class ConstraintAssignor : public ConstraintAssignorBase<ConstraintAssignor> {
15681568
assert(!Constraint.isEmpty() && "Empty ranges shouldn't get here");
15691569

15701570
if (Constraint.getConcreteValue())
1571-
return !Constraint.getConcreteValue()->isNullValue();
1571+
return !Constraint.getConcreteValue()->isZero();
15721572

15731573
APSIntType T{Constraint.getMinValue()};
15741574
Const Zero = T.getZeroValue();

0 commit comments

Comments
 (0)