@@ -5618,8 +5618,8 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr *TheCall) {
56185618 if (Arg->isTypeDependent() || Arg->isValueDependent())
56195619 continue;
56205620
5621- std::optional<llvm::APSInt> Result;
5622- if (!( Result = Arg->getIntegerConstantExpr(Context)) )
5621+ std::optional<llvm::APSInt> Result = Arg->getIntegerConstantExpr(Context) ;
5622+ if (!Result)
56235623 return ExprError(Diag(TheCall->getBeginLoc(),
56245624 diag::err_shufflevector_nonconstant_argument)
56255625 << Arg->getSourceRange());
@@ -5886,23 +5886,26 @@ bool Sema::BuiltinOSLogFormat(CallExpr *TheCall) {
58865886 return false;
58875887}
58885888
5889- bool Sema::BuiltinConstantArg(CallExpr *TheCall, int ArgNum,
5889+ bool Sema::BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum,
58905890 llvm::APSInt &Result) {
58915891 Expr *Arg = TheCall->getArg(ArgNum);
5892- DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
5893- FunctionDecl *FDecl = cast<FunctionDecl>(DRE->getDecl());
58945892
5895- if (Arg->isTypeDependent() || Arg->isValueDependent()) return false;
5893+ if (Arg->isTypeDependent() || Arg->isValueDependent())
5894+ return false;
58965895
5897- std::optional<llvm::APSInt> R;
5898- if (!(R = Arg->getIntegerConstantExpr(Context)))
5896+ std::optional<llvm::APSInt> R = Arg->getIntegerConstantExpr(Context);
5897+ if (!R) {
5898+ auto *DRE = cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
5899+ auto *FDecl = cast<FunctionDecl>(DRE->getDecl());
58995900 return Diag(TheCall->getBeginLoc(), diag::err_constant_integer_arg_type)
59005901 << FDecl->getDeclName() << Arg->getSourceRange();
5902+ }
59015903 Result = *R;
5904+
59025905 return false;
59035906}
59045907
5905- bool Sema::BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
5908+ bool Sema::BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low,
59065909 int High, bool RangeIsError) {
59075910 if (isConstantEvaluatedContext())
59085911 return false;
@@ -5933,7 +5936,7 @@ bool Sema::BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
59335936 return false;
59345937}
59355938
5936- bool Sema::BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
5939+ bool Sema::BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum,
59375940 unsigned Num) {
59385941 llvm::APSInt Result;
59395942
@@ -5953,7 +5956,7 @@ bool Sema::BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
59535956 return false;
59545957}
59555958
5956- bool Sema::BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum) {
5959+ bool Sema::BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum) {
59575960 llvm::APSInt Result;
59585961
59595962 // We can't check the value of a dependent argument.
@@ -5965,9 +5968,7 @@ bool Sema::BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum) {
59655968 if (BuiltinConstantArg(TheCall, ArgNum, Result))
59665969 return true;
59675970
5968- // Bit-twiddling to test for a power of 2: for x > 0, x & (x-1) is zero if
5969- // and only if x is a power of 2.
5970- if (Result.isStrictlyPositive() && (Result & (Result - 1)) == 0)
5971+ if (Result.isPowerOf2())
59715972 return false;
59725973
59735974 return Diag(TheCall->getBeginLoc(), diag::err_argument_not_power_of_2)
@@ -5996,7 +5997,7 @@ static bool IsShiftedByte(llvm::APSInt Value) {
59965997 }
59975998}
59985999
5999- bool Sema::BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
6000+ bool Sema::BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum,
60006001 unsigned ArgBits) {
60016002 llvm::APSInt Result;
60026003
@@ -6020,7 +6021,8 @@ bool Sema::BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
60206021 << Arg->getSourceRange();
60216022}
60226023
6023- bool Sema::BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
6024+ bool Sema::BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall,
6025+ unsigned ArgNum,
60246026 unsigned ArgBits) {
60256027 llvm::APSInt Result;
60266028
0 commit comments