@@ -2200,6 +2200,30 @@ static bool BuiltinCpu(Sema &S, const TargetInfo &TI, CallExpr *TheCall,
2200
2200
return false;
2201
2201
}
2202
2202
2203
+ /// Checks that __builtin_bswapg was called with a single argument, which is an
2204
+ /// unsigned integer, and overrides the return value type to the integer type.
2205
+ static bool BuiltinBswapg(Sema &S, CallExpr *TheCall) {
2206
+ if (S.checkArgCount(TheCall, 1))
2207
+ return true;
2208
+ ExprResult ArgRes = S.DefaultLvalueConversion(TheCall->getArg(0));
2209
+ if (ArgRes.isInvalid())
2210
+ return true;
2211
+
2212
+ Expr *Arg = ArgRes.get();
2213
+ TheCall->setArg(0, Arg);
2214
+
2215
+ QualType ArgTy = Arg->getType();
2216
+
2217
+ if (!ArgTy->isIntegerType()) {
2218
+ S.Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
2219
+ << 1 << /* scalar */ 1 << /* unsigned integer ty */ 1 << /* no fp */ 0
2220
+ << ArgTy;
2221
+ return true;
2222
+ }
2223
+ TheCall->setType(ArgTy);
2224
+ return false;
2225
+ }
2226
+
2203
2227
/// Checks that __builtin_popcountg was called with a single argument, which is
2204
2228
/// an unsigned integer.
2205
2229
static bool BuiltinPopcountg(Sema &S, CallExpr *TheCall) {
@@ -3448,6 +3472,10 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
3448
3472
}
3449
3473
break;
3450
3474
}
3475
+ case Builtin::BI__builtin_bswapg:
3476
+ if (BuiltinBswapg(*this, TheCall))
3477
+ return ExprError();
3478
+ break;
3451
3479
case Builtin::BI__builtin_popcountg:
3452
3480
if (BuiltinPopcountg(*this, TheCall))
3453
3481
return ExprError();
0 commit comments