Thanks for that! Sorry I was a bit slow to get that cleaned up.
On Wed, Jul 22, 2020 at 12:41 AM Haojian Wu via cfe-commits <cfe-commits@lists.llvm.org> wrote: > > > Author: Haojian Wu > Date: 2020-07-22T09:38:56+02:00 > New Revision: 82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0 > > URL: > https://github.com/llvm/llvm-project/commit/82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0 > DIFF: > https://github.com/llvm/llvm-project/commit/82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0.diff > > LOG: Fix the clang-tidy build after get/isIntegerConstantExpression > refactoring. > > Added: > > > Modified: > > clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp > > clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp > clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp > clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp > > Removed: > > > > ################################################################################ > diff --git > a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp > > b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp > index aa860b30fe75..1837ccb6002f 100644 > --- > a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp > +++ > b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp > @@ -79,9 +79,8 @@ static QualType getUnqualifiedType(const Expr &E) { > } > > static APValue getConstantExprValue(const ASTContext &Ctx, const Expr &E) { > - llvm::APSInt IntegerConstant; > - if (E.isIntegerConstantExpr(IntegerConstant, Ctx)) > - return APValue(IntegerConstant); > + if (auto IntegerConstant = E.getIntegerConstantExpr(Ctx)) > + return APValue(*IntegerConstant); > APValue Constant; > if (Ctx.getLangOpts().CPlusPlus && E.isCXX11ConstantExpr(Ctx, &Constant)) > return Constant; > > diff --git > a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp > > b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp > index dd0bedd742a4..96b0bb0f9b02 100644 > --- > a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp > +++ > b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp > @@ -65,9 +65,9 @@ void ProBoundsConstantArrayIndexCheck::check( > if (IndexExpr->isValueDependent()) > return; // We check in the specialization. > > - llvm::APSInt Index; > - if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr, > - /*isEvaluated=*/true)) { > + Optional<llvm::APSInt> Index = > + IndexExpr->getIntegerConstantExpr(*Result.Context); > + if (!Index) { > SourceRange BaseRange; > if (const auto *ArraySubscriptE = dyn_cast<ArraySubscriptExpr>(Matched)) > BaseRange = ArraySubscriptE->getBase()->getSourceRange(); > @@ -101,9 +101,9 @@ void ProBoundsConstantArrayIndexCheck::check( > if (!StdArrayDecl) > return; > > - if (Index.isSigned() && Index.isNegative()) { > + if (Index->isSigned() && Index->isNegative()) { > diag(Matched->getExprLoc(), "std::array<> index %0 is negative") > - << Index.toString(10); > + << Index->toString(10); > return; > } > > @@ -118,11 +118,11 @@ void ProBoundsConstantArrayIndexCheck::check( > > // Get uint64_t values, because > diff erent bitwidths would lead to an assertion > // in APInt::uge. > - if (Index.getZExtValue() >= ArraySize.getZExtValue()) { > + if (Index->getZExtValue() >= ArraySize.getZExtValue()) { > diag(Matched->getExprLoc(), > "std::array<> index %0 is past the end of the array " > "(which contains %1 elements)") > - << Index.toString(10) << ArraySize.toString(10, false); > + << Index->toString(10) << ArraySize.toString(10, false); > } > } > > > diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp > b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp > index aef513a527b5..b84e4d525d8c 100644 > --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp > +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp > @@ -500,7 +500,13 @@ static bool retrieveIntegerConstantExpr(const > MatchFinder::MatchResult &Result, > const Expr *&ConstExpr) { > std::string CstId = (Id + "-const").str(); > ConstExpr = Result.Nodes.getNodeAs<Expr>(CstId); > - return ConstExpr && ConstExpr->isIntegerConstantExpr(Value, > *Result.Context); > + if (!ConstExpr) > + return false; > + Optional<llvm::APSInt> R = > ConstExpr->getIntegerConstantExpr(*Result.Context); > + if (!R) > + return false; > + Value = *R; > + return true; > } > > // Overloaded `retrieveIntegerConstantExpr` for compatibility. > @@ -673,7 +679,7 @@ static bool retrieveRelationalIntegerConstantExpr( > > if (const auto *Arg = OverloadedOperatorExpr->getArg(1)) { > if (!Arg->isValueDependent() && > - !Arg->isIntegerConstantExpr(Value, *Result.Context)) > + !Arg->isIntegerConstantExpr(*Result.Context)) > return false; > } > Symbol = OverloadedOperatorExpr->getArg(0); > @@ -1265,21 +1271,23 @@ void RedundantExpressionCheck::check(const > MatchFinder::MatchResult &Result) { > "left-right-shift-confusion")) { > const auto *ShiftingConst = Result.Nodes.getNodeAs<Expr>("shift-const"); > assert(ShiftingConst && "Expr* 'ShiftingConst' is nullptr!"); > - APSInt ShiftingValue; > + Optional<llvm::APSInt> ShiftingValue = > + ShiftingConst->getIntegerConstantExpr(*Result.Context); > > - if (!ShiftingConst->isIntegerConstantExpr(ShiftingValue, > *Result.Context)) > + if (!ShiftingValue) > return; > > const auto *AndConst = Result.Nodes.getNodeAs<Expr>("and-const"); > assert(AndConst && "Expr* 'AndCont' is nullptr!"); > - APSInt AndValue; > - if (!AndConst->isIntegerConstantExpr(AndValue, *Result.Context)) > + Optional<llvm::APSInt> AndValue = > + AndConst->getIntegerConstantExpr(*Result.Context); > + if (!AndValue) > return; > > // If ShiftingConst is shifted left with more bits than the position of > the > // leftmost 1 in the bit representation of AndValue, AndConstant is > // ineffective. > - if (AndValue.getActiveBits() > ShiftingValue) > + if (AndValue->getActiveBits() > *ShiftingValue) > return; > > auto Diag = diag(BinaryAndExpr->getOperatorLoc(), > > diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp > b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp > index 56d4cceb6002..c20472c8de59 100644 > --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp > +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp > @@ -438,11 +438,12 @@ static bool arrayMatchesBoundExpr(ASTContext *Context, > Context->getAsConstantArrayType(ArrayType); > if (!ConstType) > return false; > - llvm::APSInt ConditionSize; > - if (!ConditionExpr->isIntegerConstantExpr(ConditionSize, *Context)) > + Optional<llvm::APSInt> ConditionSize = > + ConditionExpr->getIntegerConstantExpr(*Context); > + if (!ConditionSize) > return false; > llvm::APSInt ArraySize(ConstType->getSize()); > - return llvm::APSInt::isSameValue(ConditionSize, ArraySize); > + return llvm::APSInt::isSameValue(*ConditionSize, ArraySize); > } > > ForLoopIndexUseVisitor::ForLoopIndexUseVisitor(ASTContext *Context, > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits