clover/llvm: Simplify diagnostic_handler().
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 17 May 2016 14:02:44 +0000 (16:02 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 12 Jul 2016 03:22:29 +0000 (20:22 -0700)
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
Tested-by: Jan Vesely <jan.vesely@rutgers.edu>
src/gallium/state_trackers/clover/llvm/invocation.cpp

index 2ca57d043006a8e3119a4c2d3a1de4811f2feb2d..962f1bf142e8a0f6dfe5b07ca450c71af9c29c3b 100644 (file)
@@ -132,15 +132,11 @@ namespace {
    }
 
    void
-   diagnostic_handler(const llvm::DiagnosticInfo &di, void *data) {
-      if (di.getSeverity() == llvm::DS_Error) {
-         std::string message = *(std::string*)data;
-         llvm::raw_string_ostream stream(message);
-         llvm::DiagnosticPrinterRawOStream dp(stream);
-         di.print(dp);
-         stream.flush();
-         *(std::string*)data = message;
-
+   diagnostic_handler(const ::llvm::DiagnosticInfo &di, void *data) {
+      if (di.getSeverity() == ::llvm::DS_Error) {
+         raw_string_ostream os { *reinterpret_cast<std::string *>(data) };
+         ::llvm::DiagnosticPrinterRawOStream printer { os };
+         di.print(printer);
          throw compile_error();
       }
    }