[Mesa-dev,39/47] clover: Define error subclass to signal build option parse failure.

Submitted by Francisco Jerez on July 4, 2016, 12:51 a.m.

Details

Message ID 20160704005156.5703-40-currojerez@riseup.net
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Francisco Jerez July 4, 2016, 12:51 a.m.
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
---
 src/gallium/state_trackers/clover/api/program.cpp     | 6 ++++--
 src/gallium/state_trackers/clover/core/error.hpp      | 6 ++++++
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index ff199ab..848d2d0 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -183,9 +183,8 @@  clBuildProgram(cl_program d_prog, cl_uint num_devs,
 
    prog.build(devs, opts);
    return CL_SUCCESS;
+
 } catch (error &e) {
-   if (e.get() == CL_INVALID_COMPILER_OPTIONS)
-      return CL_INVALID_BUILD_OPTIONS;
    return e.get();
 }
 
@@ -225,6 +224,9 @@  clCompileProgram(cl_program d_prog, cl_uint num_devs,
    prog.build(devs, opts, headers);
    return CL_SUCCESS;
 
+} catch (invalid_build_options_error &e) {
+   return CL_INVALID_COMPILER_OPTIONS;
+
 } catch (build_error &e) {
    return CL_COMPILE_PROGRAM_FAILURE;
 
diff --git a/src/gallium/state_trackers/clover/core/error.hpp b/src/gallium/state_trackers/clover/core/error.hpp
index 3165402..0490c19 100644
--- a/src/gallium/state_trackers/clover/core/error.hpp
+++ b/src/gallium/state_trackers/clover/core/error.hpp
@@ -65,6 +65,12 @@  namespace clover {
       cl_int code;
    };
 
+   class invalid_build_options_error : public error {
+   public:
+      invalid_build_options_error(const std::string &what = "") :
+         error(CL_INVALID_BUILD_OPTIONS, what) {}
+   };
+
    class build_error : public error {
    public:
       build_error(const std::string &what = "") :
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index db3b481..944c305 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -98,7 +98,7 @@  namespace {
 
       if (!clang::CompilerInvocation::CreateFromArgs(
              c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
-         throw error(CL_INVALID_COMPILER_OPTIONS);
+         throw invalid_build_options_error();
 
       c->getTargetOpts().CPU = target.cpu;
       c->getTargetOpts().Triple = target.triple;