clover: Define error subclass to signal build option parse failure.

Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
This commit is contained in:
Francisco Jerez 2016-05-17 16:03:11 +02:00
parent 4ef1c0918d
commit 2a73ae662c
3 changed files with 11 additions and 3 deletions

View 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;

View 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 = "") :

View 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;