[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 4 15:06:01 UTC 2018


 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 4678d37fdc64145b10f997668fd2890ddb3c8462
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 16 16:47:59 2018 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Dec 4 16:05:39 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.lunak at collabora.com>
    (cherry picked from commit 433b1fdd3fc588cb542bb834117752dbef4e8236)
    Reviewed-on: https://gerrit.libreoffice.org/64469

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 7df68fc77fab..e18eeb9932d0 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -3640,6 +3640,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 5833796726a1..8fef4d3e1d09 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


More information about the Libreoffice-commits mailing list