diff options
author | Bob Wilson <bob.wilson@apple.com> | 2011-11-16 21:32:23 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2011-11-16 21:32:23 +0000 |
commit | 4648255cebd2fc7c18293c1f93afd6e9add9cccc (patch) | |
tree | c43629d138762bef6ee52f84c3a8ca17b529a48b /lib/Sema/SemaChecking.cpp | |
parent | e42a0ab77ca4ad5201591aac5679ef47a08af4b6 (diff) |
Fix Neon builtin pointer argument checking for "sret" builtins.
The code for checking Neon builtin pointer argument types was assuming that
there would only be one pointer argument. But, for vld2-4 builtins, the first
argument is a special sret pointer where the result will be stored. So,
instead of scanning all the arguments to find a pointer, have TableGen figure
out the index of the pointer argument that needs checking. That's better than
scanning all the arguments regardless. <rdar://problem/10448804>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index f4968f697a..760b5f33b2 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -298,7 +298,7 @@ bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { unsigned mask = 0; unsigned TV = 0; - bool HasPtr = false; + int PtrArgNum = -1; bool HasConstPtr = false; switch (BuiltinID) { #define GET_NEON_OVERLOAD_CHECK @@ -319,28 +319,24 @@ bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { << TheCall->getArg(ImmArg)->getSourceRange(); } - if (HasPtr || HasConstPtr) { + if (PtrArgNum >= 0) { // Check that pointer arguments have the specified type. - for (unsigned ArgNo = 0; ArgNo < ImmArg; ++ArgNo) { - Expr *Arg = TheCall->getArg(ArgNo); - if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) - Arg = ICE->getSubExpr(); - ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg); - QualType RHSTy = RHS.get()->getType(); - if (!RHSTy->isPointerType()) - continue; - QualType EltTy = getNeonEltType(NeonTypeFlags(TV), Context); - if (HasConstPtr) - EltTy = EltTy.withConst(); - QualType LHSTy = Context.getPointerType(EltTy); - AssignConvertType ConvTy; - ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS); - if (RHS.isInvalid()) - return true; - if (DiagnoseAssignmentResult(ConvTy, Arg->getLocStart(), LHSTy, RHSTy, - RHS.get(), AA_Assigning)) - return true; - } + Expr *Arg = TheCall->getArg(PtrArgNum); + if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) + Arg = ICE->getSubExpr(); + ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg); + QualType RHSTy = RHS.get()->getType(); + QualType EltTy = getNeonEltType(NeonTypeFlags(TV), Context); + if (HasConstPtr) + EltTy = EltTy.withConst(); + QualType LHSTy = Context.getPointerType(EltTy); + AssignConvertType ConvTy; + ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS); + if (RHS.isInvalid()) + return true; + if (DiagnoseAssignmentResult(ConvTy, Arg->getLocStart(), LHSTy, RHSTy, + RHS.get(), AA_Assigning)) + return true; } // For NEON intrinsics which take an immediate value as part of the |