Commit d9fef848 authored by Vedran Miletić's avatar Vedran Miletić Committed by Francisco Jerez
Browse files

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/

v2: fix inconsistent code formatting

Signed-off-by: default avatarVedran Miletić <>
Reviewed-by: Francisco Jerez's avatarFrancisco Jerez <>
Tested-by: Aaron Watry's avatarAaron Watry <>
parent 3a30b1a5
......@@ -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.size(), diag))
throw invalid_build_options_error();
if (diag.hasErrorOccurred())
throw invalid_build_options_error();
c->getTargetOpts().CPU = target.cpu;
c->getTargetOpts().Triple = target.triple;
c->getLangOpts().NoBuiltin = true;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment