summaryrefslogtreecommitdiff
path: root/tools/llc
diff options
context:
space:
mode:
authorVivek Pandya <vivekvpandya@gmail.com>2017-09-15 19:53:54 +0000
committerVivek Pandya <vivekvpandya@gmail.com>2017-09-15 19:53:54 +0000
commit4abccff981adfaddf2a26bc1a6a8bce374f01574 (patch)
treef9cf7a8ab83f3e3f8413b767f045bfa77ecf32c6 /tools/llc
parent885ad98e060cd960531fd534ab850babd715d65e (diff)
This reverts r313381
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313387 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llc')
-rw-r--r--tools/llc/llc.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index bbbec221208..aad237c42dc 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -235,24 +235,20 @@ GetOutputStream(const char *TargetName, Triple::OSType OS,
return FDOut;
}
-struct LLCDiagnosticHandler : public DiagnosticHandler {
- bool *HasError;
- LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
- bool handleDiagnostics(const DiagnosticInfo &DI) override {
- if (DI.getSeverity() == DS_Error)
- *HasError = true;
-
- if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
- if (!Remark->isEnabled())
- return true;
-
- DiagnosticPrinterRawOStream DP(errs());
- errs() << LLVMContext::getDiagnosticMessagePrefix(DI.getSeverity()) << ": ";
- DI.print(DP);
- errs() << "\n";
- return true;
- }
-};
+static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context) {
+ bool *HasError = static_cast<bool *>(Context);
+ if (DI.getSeverity() == DS_Error)
+ *HasError = true;
+
+ if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
+ if (!Remark->isEnabled())
+ return;
+
+ DiagnosticPrinterRawOStream DP(errs());
+ errs() << LLVMContext::getDiagnosticMessagePrefix(DI.getSeverity()) << ": ";
+ DI.print(DP);
+ errs() << "\n";
+}
static void InlineAsmDiagHandler(const SMDiagnostic &SMD, void *Context,
unsigned LocCookie) {
@@ -312,8 +308,7 @@ int main(int argc, char **argv) {
// Set a diagnostic handler that doesn't exit on the first error
bool HasError = false;
- Context.setDiagnosticHandler(
- llvm::make_unique<LLCDiagnosticHandler>(&HasError));
+ Context.setDiagnosticHandler(DiagnosticHandler, &HasError);
Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError);
if (PassRemarksWithHotness)
@@ -569,9 +564,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
PM.run(*M);
- auto HasError =
- ((const LLCDiagnosticHandler *)(Context.getDiagHandlerPtr()))->HasError;
- if (*HasError)
+ auto HasError = *static_cast<bool *>(Context.getDiagnosticContext());
+ if (HasError)
return 1;
// Compare the two outputs and make sure they're the same