summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/clover
diff options
context:
space:
mode:
authorVedran Miletić <[email protected]>2016-12-21 13:49:36 +0100
committerFrancisco Jerez <[email protected]>2016-12-24 18:35:09 -0800
commitd9fef848a651b47520cbeb72c38b93d4fbf842a8 (patch)
tree28e2664884401f4dbdebb6b5c7f62095bcc8253f /src/gallium/state_trackers/clover
parent3a30b1a556b1ed7dc60befcec16343e80a3bd77e (diff)
clover: Use Clang's diagnostics
Presently errors from frontend are handled only if they occur in clang::CompilerInvocation::CreateFromArgs(). This patch uses clang::DiagnosticsEngine to detect errors such as invalid values for Clang frontend arguments. Fixes Piglit's cl/program/build/fail/invalid-version-declaration.cl test. v2: fix inconsistent code formatting Signed-off-by: Vedran Miletić <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Tested-by: Aaron Watry <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover')
-rw-r--r--src/gallium/state_trackers/clover/llvm/invocation.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 675cf1944d7..f63ff3d41c3 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -98,8 +98,9 @@ namespace {
const std::vector<std::string> &opts,
std::string &r_log) {
std::unique_ptr<clang::CompilerInstance> c { new clang::CompilerInstance };
+ clang::TextDiagnosticBuffer *diag_buffer = new clang::TextDiagnosticBuffer;
clang::DiagnosticsEngine diag { new clang::DiagnosticIDs,
- new clang::DiagnosticOptions, new clang::TextDiagnosticBuffer };
+ new clang::DiagnosticOptions, diag_buffer };
// Parse the compiler options. A file name should be present at the end
// and must have the .cl extension in order for the CompilerInvocation
@@ -111,6 +112,10 @@ namespace {
c->getInvocation(), copts.data(), copts.data() + copts.size(), diag))
throw invalid_build_options_error();
+ diag_buffer->FlushDiagnostics(diag);
+ if (diag.hasErrorOccurred())
+ throw invalid_build_options_error();
+
c->getTargetOpts().CPU = target.cpu;
c->getTargetOpts().Triple = target.triple;
c->getLangOpts().NoBuiltin = true;