sc/source/core/opencl/formulagroupcl.cxx | 7 +++++++ sc/source/core/opencl/opbase.cxx | 3 +++ sc/source/core/opencl/opbase.hxx | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+)
New commits: commit 433b1fdd3fc588cb542bb834117752dbef4e8236 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Fri Nov 16 16:47:59 2018 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Dec 3 15:36:41 2018 +0100 add a macro for detecting incorrect number of parameters in opencl Change-Id: Id8253537025cc373c1ff183c0059158489e11750 Reviewed-on: https://gerrit.libreoffice.org/64239 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 247422e1b80a..02608e3bfb82 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -4053,6 +4053,13 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken delete pDynamicKernel; return nullptr; } + catch (const InvalidParameterCount& ipc) + { + SAL_INFO("sc.opencl", "Dynamic formula compiler: InvalidParameterCount " << ipc.mParameterCount + << " at " << ipc.mFile << ":" << ipc.mLineNumber); + delete pDynamicKernel; + return nullptr; + } catch (const OpenCLError& oce) { // I think OpenCLError exceptions are actually exceptional (unexpected), so do use SAL_WARN diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx index e4ba2a0a6d93..2d026475a088 100644 --- a/sc/source/core/opencl/opbase.cxx +++ b/sc/source/core/opencl/opbase.cxx @@ -34,6 +34,9 @@ OpenCLError::OpenCLError( const std::string& function, cl_int error, const std:: Unhandled::Unhandled( const std::string& fn, int ln ) : mFile(fn), mLineNumber(ln) {} +InvalidParameterCount::InvalidParameterCount( int parameterCount, const std::string& file, int ln ) : + mParameterCount(parameterCount), mFile(file), mLineNumber(ln) {} + DynamicKernelArgument::DynamicKernelArgument( const ScCalcConfig& config, const std::string& s, const FormulaTreeNodeRef& ft ) : mCalcConfig(config), mSymName(s), mFormulaTree(ft) { } diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx index e30a47e500c3..112589a6a5f6 100644 --- a/sc/source/core/opencl/opbase.hxx +++ b/sc/source/core/opencl/opbase.hxx @@ -60,6 +60,25 @@ public: int const mLineNumber; }; +class InvalidParameterCount +{ +public: + InvalidParameterCount( int parameterCount, const std::string& file, int ln ); + + int mParameterCount; + std::string mFile; + int const mLineNumber; +}; + +// Helper macro to be used in code emitting OpenCL code for Calc functions. +// Requires the vSubArguments parameter. +#define CHECK_PARAMETER_COUNT(min, max) \ + do { \ + const int count = vSubArguments.size(); \ + if( count < ( min ) || count > ( max )) \ + throw InvalidParameterCount( count, __FILE__, __LINE__ ); \ + } while( false ) + typedef std::shared_ptr<FormulaTreeNode> FormulaTreeNodeRef; class FormulaTreeNode _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits