================
@@ -114,6 +114,36 @@ 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 error diagnostics and return true on success
+ // - IsVectorType: enforces vector unsigned char
+ // - IsIntType: enforces any integer type
+ // Lambdas centralize type checks for BCD builtin handlers
+
+ // Lambda 1: verify vector unsigned char type
+ auto IsVectorType = [&](QualType ArgTy, unsigned ArgIndex) -> bool {
+ QualType VecType = Context.getVectorType(Context.UnsignedCharTy, 16,
+ VectorKind::AltiVecVector);
+ if (Context.hasSameType(ArgTy, VecType))
+ return true;
+
+ Diag(TheCall->getArg(ArgIndex)->getBeginLoc(),
+ diag::err_ppc_invalid_arg_type)
+ << ArgIndex << VecType << ArgTy;
+ return false;
+ };
+
+ // Lambda 2: verify integer type
+ auto IsIntType = [&](QualType ArgTy, unsigned ArgIndex) -> bool {
+ if (ArgTy->isIntegerType())
+ return true;
+
+ Diag(TheCall->getArg(ArgIndex)->getBeginLoc(),
+ diag::err_ppc_invalid_arg_type)
+ << ArgIndex << "integer" << ArgTy;
+ return false;
+ };
----------------
lei137 wrote:
Feel like we should have this kind of check functions already elsewhere... but
I won't block this PR for this. Please do investigate as a followup.
https://github.com/llvm/llvm-project/pull/154715
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits