[clang] [Clang] Add __builtin_bswapg (PR #162433)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 8 22:04:04 PDT 2025


================
@@ -2200,6 +2200,30 @@ static bool BuiltinCpu(Sema &S, const TargetInfo &TI, CallExpr *TheCall,
   return false;
 }
 
+/// Checks that __builtin_bswapg was called with a single argument, which is an
+/// unsigned integer, and overrides the return value type to the integer type.
+static bool BuiltinBswapg(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();
----------------
ojhunt wrote:

I think you'll need a dependent check as well

https://github.com/llvm/llvm-project/pull/162433


More information about the cfe-commits mailing list