================
@@ -104,14 +104,81 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const
TargetInfo &TI,
return Diag(TheCall->getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
<< TheCall->getSourceRange();
+ // Common BCD type-validation helpers
+ // Emit diagnostics and return true on failure
+ // - VerifyVectorType: enforces vector unsigned char
+ // - VerifyIntType: enforces any integer type
+ // Lambdas centralize type checks for all BCD builtin handlers
+ QualType VecType = Context.getVectorType(Context.UnsignedCharTy, 16,
+ VectorKind::AltiVecVector);
+ // Lambda 1: verify vector type
+ auto VerifyVectorType = [&](QualType ArgTy, SourceLocation Loc,
+ unsigned ArgIndex) -> bool {
+ if (!Context.hasSameType(ArgTy, VecType)) {
+ Diag(Loc, diag::err_ppc_bcd_invalid_vector_type)
+ << ArgIndex << VecType << ArgTy;
+ return true;
+ }
+ return false;
+ };
+
+ // Lambda 2: verify integer type
+ auto VerifyIntType = [&](QualType ArgTy, SourceLocation Loc,
+ unsigned ArgIndex) -> bool {
+ if (!ArgTy->isIntegerType()) {
+ Diag(Loc, diag::err_ppc_bcd_invalid_integer_type)
+ << ArgIndex << "integer type" << ArgTy;
+ return true;
+ }
+ return false;
+ };
+
switch (BuiltinID) {
default:
return false;
- case PPC::BI__builtin_ppc_bcdsetsign:
----------------
tonykuttai wrote:
Why are we modifying `bcdsetsign` in this PR ?
https://github.com/llvm/llvm-project/pull/154715
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits