clover: Define error subclass to signal build option parse failure.
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 17 May 2016 14:03:11 +0000 (16:03 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 12 Jul 2016 03:34:34 +0000 (20:34 -0700)
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
src/gallium/state_trackers/clover/api/program.cpp
src/gallium/state_trackers/clover/core/error.hpp
src/gallium/state_trackers/clover/llvm/invocation.cpp

index ff199abe5c0a51f939db840b7175d9cf28a22dbc..848d2d0329c6d9de0dd69969cd17e4555c228e94 100644 (file)
@@ -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;
 
index 3165402d7e3d3356db012391573631df65e8553a..0490c19a276d42462a8db23e7849942e573c0550 100644 (file)
@@ -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 = "") :
index db3b48176b0c891f404ba668374aab8e67fd52fb..944c30566c0ac0444d880693b173beba6f5de4d3 100644 (file)
@@ -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;