diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2018-11-16 16:47:59 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2018-12-03 15:36:41 +0100 |
commit | 433b1fdd3fc588cb542bb834117752dbef4e8236 (patch) | |
tree | 50cdc66184c6f2c6cc578f18204f61df427935b9 | |
parent | restore incorrectly removed code (diff) | |
download | core-433b1fdd3fc588cb542bb834117752dbef4e8236.tar.gz core-433b1fdd3fc588cb542bb834117752dbef4e8236.zip |
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.lunak@collabora.com>
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/opencl/opbase.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/opencl/opbase.hxx | 19 |
3 files changed, 29 insertions, 0 deletions
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 |