[Mesa-dev] [PATCH] clover: Use Clang's diagnostics
Francisco Jerez
currojerez at riseup.net
Tue Dec 20 22:28:13 UTC 2016
Vedran Miletić <vedran at miletic.net> writes:
> 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.
>
> Signed-off-by: Vedran Miletić <vedran at miletic.net>
> ---
> src/gallium/state_trackers/clover/llvm/invocation.cpp | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> index 675cf19..29dec44 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;
Inconsistent pointer formatting. With that fixed:
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
> 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;
> --
> 2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161220/29a80019/attachment.sig>
More information about the mesa-dev
mailing list