[clang] [clang]Implement the c23 stdc bit builtins (PR #185978)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 31 09:50:59 PDT 2026
================
@@ -2345,6 +2345,29 @@ static bool BuiltinPopcountg(Sema &S, CallExpr *TheCall) {
return false;
}
+/// Checks the __builtin_stdc_* builtins that take a single unsigned integer
+/// argument and return either int, bool, or the argument type.
+static bool BuiltinStdCBuiltin(Sema &S, CallExpr *TheCall,
+ QualType ReturnType) {
+ 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())
+ return S.Diag(Arg->getBeginLoc(), diag::err_builtin_stdc_invalid_arg_type)
+ << 1 << ArgTy;
----------------
erichkeane wrote:
This '1' needs a comment explaining what it is doing.
https://github.com/llvm/llvm-project/pull/185978
More information about the cfe-commits
mailing list