================
@@ -2345,6 +2345,47 @@ static bool BuiltinPopcountg(Sema &S, CallExpr *TheCall)
{
return false;
}
+/// Checks stdc bit-utility builtins (__builtin_stdc_*):
+/// bit_ceil, bit_floor, bit_width, count_ones, count_zeros,
+/// first_leading_one, first_leading_zero, first_trailing_one,
+/// first_trailing_zero, has_single_bit, leading_ones, leading_zeros,
+/// trailing_ones, trailing_zeros. They all take a single unsigned integer
+/// argument and return either int, bool, or the argument type depending on the
+/// specific builtin.
+static bool BuiltinStdCBuiltin(Sema &S, CallExpr *TheCall) {
+ if (S.checkArgCount(TheCall, 1))
+ return true;
+
+ ExprResult ArgRes = S.DefaultLvalueConversion(TheCall->getArg(0));
+ if (ArgRes.isInvalid())
+ return true;
+
+ Expr *Arg = ArgRes.get();
+ TheCall->setArg(0, Arg);
+
+ QualType ArgTy = Arg->getType();
+ if (!ArgTy->isUnsignedIntegerType() && !ArgTy->isExtVectorBoolType()) {
+ S.Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+ << 1 << /* scalar */ 1 << /* unsigned integer ty */ 3 << /* no fp */ 0
+ << ArgTy;
+ return true;
----------------
erichkeane wrote:
do `return S.diag...`, that way this becomes a 1 liner.
https://github.com/llvm/llvm-project/pull/185978
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits