diff options
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index f2b70be..eeb3222 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2570,6 +2570,17 @@ static bool isValidBPFPreserveFieldInfoArg(Expr *Arg) { dyn_cast<ArraySubscriptExpr>(Arg->IgnoreParens())); } +static bool isEltOfVectorTy(ASTContext &Context, CallExpr *Call, Sema &S, + QualType VectorTy, QualType EltTy) { + QualType VectorEltTy = VectorTy->castAs<VectorType>()->getElementType(); + if (!Context.hasSameType(VectorEltTy, EltTy)) { + S.Diag(Call->getBeginLoc(), diag::err_typecheck_call_different_arg_types) + << Call->getSourceRange() << VectorEltTy << EltTy; + return false; + } + return true; +} + static bool isValidBPFPreserveTypeInfoArg(Expr *Arg) { QualType ArgType = Arg->getType(); if (ArgType->getAsPlaceholderType()) @@ -3222,6 +3233,14 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, return SemaVSXCheck(TheCall); case PPC::BI__builtin_altivec_vgnb: return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7); + case PPC::BI__builtin_altivec_vec_replace_elt: + case PPC::BI__builtin_altivec_vec_replace_unaligned: { + QualType VecTy = TheCall->getArg(0)->getType(); + QualType EltTy = TheCall->getArg(1)->getType(); + unsigned Width = Context.getIntWidth(EltTy); + return SemaBuiltinConstantArgRange(TheCall, 2, 0, Width == 32 ? 12 : 8) || + !isEltOfVectorTy(Context, TheCall, *this, VecTy, EltTy); + } case PPC::BI__builtin_vsx_xxeval: return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255); case PPC::BI__builtin_altivec_vsldbi: |