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();
}
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;
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 = "") :
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;