@@ -500,7 +500,13 @@ static bool retrieveIntegerConstantExpr(const MatchFinder::MatchResult &Result,
500500 const Expr *&ConstExpr) {
501501 std::string CstId = (Id + " -const" ).str ();
502502 ConstExpr = Result.Nodes .getNodeAs <Expr>(CstId);
503- return ConstExpr && ConstExpr->isIntegerConstantExpr (Value, *Result.Context );
503+ if (!ConstExpr)
504+ return false ;
505+ Optional<llvm::APSInt> R = ConstExpr->getIntegerConstantExpr (*Result.Context );
506+ if (!R)
507+ return false ;
508+ Value = *R;
509+ return true ;
504510}
505511
506512// Overloaded `retrieveIntegerConstantExpr` for compatibility.
@@ -673,7 +679,7 @@ static bool retrieveRelationalIntegerConstantExpr(
673679
674680 if (const auto *Arg = OverloadedOperatorExpr->getArg (1 )) {
675681 if (!Arg->isValueDependent () &&
676- !Arg->isIntegerConstantExpr (Value, *Result.Context ))
682+ !Arg->isIntegerConstantExpr (*Result.Context ))
677683 return false ;
678684 }
679685 Symbol = OverloadedOperatorExpr->getArg (0 );
@@ -1265,21 +1271,23 @@ void RedundantExpressionCheck::check(const MatchFinder::MatchResult &Result) {
12651271 " left-right-shift-confusion" )) {
12661272 const auto *ShiftingConst = Result.Nodes .getNodeAs <Expr>(" shift-const" );
12671273 assert (ShiftingConst && " Expr* 'ShiftingConst' is nullptr!" );
1268- APSInt ShiftingValue;
1274+ Optional<llvm::APSInt> ShiftingValue =
1275+ ShiftingConst->getIntegerConstantExpr (*Result.Context );
12691276
1270- if (!ShiftingConst-> isIntegerConstantExpr ( ShiftingValue, *Result. Context ) )
1277+ if (!ShiftingValue)
12711278 return ;
12721279
12731280 const auto *AndConst = Result.Nodes .getNodeAs <Expr>(" and-const" );
12741281 assert (AndConst && " Expr* 'AndCont' is nullptr!" );
1275- APSInt AndValue;
1276- if (!AndConst->isIntegerConstantExpr (AndValue, *Result.Context ))
1282+ Optional<llvm::APSInt> AndValue =
1283+ AndConst->getIntegerConstantExpr (*Result.Context );
1284+ if (!AndValue)
12771285 return ;
12781286
12791287 // If ShiftingConst is shifted left with more bits than the position of the
12801288 // leftmost 1 in the bit representation of AndValue, AndConstant is
12811289 // ineffective.
1282- if (AndValue. getActiveBits () > ShiftingValue)
1290+ if (AndValue-> getActiveBits () > * ShiftingValue)
12831291 return ;
12841292
12851293 auto Diag = diag (BinaryAndExpr->getOperatorLoc (),
0 commit comments