summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx7
-rw-r--r--sc/source/core/opencl/opbase.cxx3
-rw-r--r--sc/source/core/opencl/opbase.hxx19
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