================
@@ -2218,6 +2218,40 @@ 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);
+ if (Arg->isTypeDependent())
+ return false;
+
+ QualType ArgTy = Arg->getType();
+
+ if (!ArgTy->isIntegerType()) {
+ S.Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+ << 1 << /*scalar=*/1 << /*unsigned integer=*/1 << /*floating point=*/0
+ << ArgTy;
+ return true;
+ }
+ const auto *bitIntType = dyn_cast<BitIntType>(ArgTy);
+ if (bitIntType != nullptr) {
----------------
AaronBallman wrote:
```suggestion
if (const auto *BT = dyn_cast<BitIntType>(ArgTy)) {
```
then use `BT` instead of `bitIntType` (which doesn't match our usual style
guides).
https://github.com/llvm/llvm-project/pull/162433
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits