================
@@ -2318,6 +2318,67 @@ static bool BuiltinCountZeroBitsGeneric(Sema &S,
CallExpr *TheCall) {
return false;
}
+/// Checks that __builtin_stdc_rotate_{left,right} was called with two
+/// arguments, that the first argument is an unsigned integer type, and that
+/// the second argument is an integer type.
+static bool BuiltinRotateGeneric(Sema &S, CallExpr *TheCall) {
+ if (S.checkArgCount(TheCall, 2))
+ return true;
+
+ ExprResult Arg0Res = S.DefaultLvalueConversion(TheCall->getArg(0));
+ if (Arg0Res.isInvalid())
+ return true;
+
+ Expr *Arg0 = Arg0Res.get();
+ TheCall->setArg(0, Arg0);
+
+ QualType Arg0Ty = Arg0->getType();
+ if (!Arg0Ty->isUnsignedIntegerType()) {
+ ExprResult ConvArg0Res = S.PerformImplicitConversion(
+ TheCall->getArg(0), S.Context.UnsignedIntTy,
AssignmentAction::Passing);
----------------
efriedma-quic wrote:
Implicitly choosing `unsigned int` as the type of the argument seems like a bad
idea; the value might not actually fit into an unsigned int, and there could be
other weird effects if you're implicitly converting from signed to unsigned.
Users can always explicitly cast if they need to.
https://github.com/llvm/llvm-project/pull/160259
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits