static void diagnosticHandler(const DiagnosticInfo &DI) { raw_ostream &OS = errs(); OS << "llvm-lto: "; switch (DI.getSeverity()) { case DS_Error: OS << "error"; break; case DS_Warning: OS << "warning"; break; case DS_Remark: OS << "remark"; break; case DS_Note: OS << "note"; break; } if (!CurrentActivity.empty()) OS << ' ' << CurrentActivity; OS << ": "; DiagnosticPrinterRawOStream DP(OS); DI.print(DP); OS << '\n'; if (DI.getSeverity() == DS_Error) exit(1); }
void LLVMContext::diagnose(const DiagnosticInfo &DI) { if (auto *OptDiagBase = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) { yaml::Output *Out = getDiagnosticsOutputFile(); if (Out) { // For remarks the << operator takes a reference to a pointer. auto *P = const_cast<DiagnosticInfoOptimizationBase *>(OptDiagBase); *Out << P; } } // If there is a report handler, use it. if (pImpl->DiagHandler && (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && pImpl->DiagHandler->handleDiagnostics(DI)) return; if (!isDiagnosticEnabled(DI)) return; // Otherwise, print the message with a prefix based on the severity. DiagnosticPrinterRawOStream DP(errs()); errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; DI.print(DP); errs() << "\n"; if (DI.getSeverity() == DS_Error) exit(1); }
static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context) { bool *HasError = static_cast<bool *>(Context); if (DI.getSeverity() == DS_Error) *HasError = true; DiagnosticPrinterRawOStream DP(errs()); errs() << LLVMContext::getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; DI.print(DP); errs() << "\n"; }
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"; }
void LLVMContext::diagnose(const DiagnosticInfo &DI) { // If there is a report handler, use it. if (pImpl->DiagnosticHandler) { if (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext); return; } if (!isDiagnosticEnabled(DI)) return; // Otherwise, print the message with a prefix based on the severity. std::string MsgStorage; raw_string_ostream Stream(MsgStorage); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); Stream.flush(); switch (DI.getSeverity()) { case DS_Error: errs() << "error: " << MsgStorage << "\n"; exit(1); case DS_Warning: errs() << "warning: " << MsgStorage << "\n"; break; case DS_Remark: errs() << "remark: " << MsgStorage << "\n"; break; case DS_Note: errs() << "note: " << MsgStorage << "\n"; break; } }
static void diagnosticHandler(const DiagnosticInfo &DI) { DiagnosticPrinterRawOStream DP(errs()); DI.print(DP); errs() << '\n'; if (DI.getSeverity() == DS_Error) exit(1); }
/// \brief This function is invoked when the backend needs /// to report something to the user. void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) { unsigned DiagID = diag::err_fe_inline_asm; llvm::DiagnosticSeverity Severity = DI.getSeverity(); // Get the diagnostic ID based. switch (DI.getKind()) { case llvm::DK_InlineAsm: if (InlineAsmDiagHandler(cast<DiagnosticInfoInlineAsm>(DI))) return; ComputeDiagID(Severity, inline_asm, DiagID); break; case llvm::DK_StackSize: if (StackSizeDiagHandler(cast<DiagnosticInfoStackSize>(DI))) return; ComputeDiagID(Severity, backend_frame_larger_than, DiagID); break; default: // Plugin IDs are not bound to any value as they are set dynamically. ComputeDiagRemarkID(Severity, backend_plugin, DiagID); break; } std::string MsgStorage; { raw_string_ostream Stream(MsgStorage); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); } // Report the backend message using the usual diagnostic mechanism. FullSourceLoc Loc; Diags.Report(Loc, DiagID).AddString(MsgStorage); }
static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { if (const auto *BDI = dyn_cast<BitcodeDiagnosticInfo>(&DI)) { std::error_code EC = BDI->getError(); if (EC == BitcodeError::InvalidBitcodeSignature) return; } std::string ErrStorage; { raw_string_ostream OS(ErrStorage); DiagnosticPrinterRawOStream DP(OS); DI.print(DP); } ld_plugin_level Level; switch (DI.getSeverity()) { case DS_Error: message(LDPL_FATAL, "LLVM gold plugin has failed to create LTO module: %s", ErrStorage.c_str()); llvm_unreachable("Fatal doesn't return."); case DS_Warning: Level = LDPL_WARNING; break; case DS_Note: case DS_Remark: Level = LDPL_INFO; break; } message(Level, "LLVM gold plugin: %s", ErrStorage.c_str()); }
void LTOCodeGenerator::DiagnosticHandler2(const DiagnosticInfo &DI) { // Map the LLVM internal diagnostic severity to the LTO diagnostic severity. lto_codegen_diagnostic_severity_t Severity; switch (DI.getSeverity()) { case DS_Error: Severity = LTO_DS_ERROR; break; case DS_Warning: Severity = LTO_DS_WARNING; break; case DS_Remark: Severity = LTO_DS_REMARK; break; case DS_Note: Severity = LTO_DS_NOTE; break; } // Create the string that will be reported to the external diagnostic handler. std::string MsgStorage; raw_string_ostream Stream(MsgStorage); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); Stream.flush(); // If this method has been called it means someone has set up an external // diagnostic handler. Assert on that. assert(DiagHandler && "Invalid diagnostic handler"); (*DiagHandler)(Severity, MsgStorage.c_str(), DiagContext); }
static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { raw_ostream &OS = errs(); OS << (char *)Context << ": "; switch (DI.getSeverity()) { case DS_Error: OS << "error: "; break; case DS_Warning: OS << "warning: "; break; case DS_Remark: OS << "remark: "; break; case DS_Note: OS << "note: "; break; } DiagnosticPrinterRawOStream DP(OS); DI.print(DP); OS << '\n'; if (DI.getSeverity() == DS_Error) exit(1); }
/// \brief This function is invoked when the backend needs /// to report something to the user. void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) { unsigned DiagID = diag::err_fe_inline_asm; llvm::DiagnosticSeverity Severity = DI.getSeverity(); // Get the diagnostic ID based. switch (DI.getKind()) { case llvm::DK_InlineAsm: if (InlineAsmDiagHandler(cast<DiagnosticInfoInlineAsm>(DI))) return; ComputeDiagID(Severity, inline_asm, DiagID); break; case llvm::DK_StackSize: if (StackSizeDiagHandler(cast<DiagnosticInfoStackSize>(DI))) return; ComputeDiagID(Severity, backend_frame_larger_than, DiagID); break; case llvm::DK_OptimizationRemark: // Optimization remarks are always handled completely by this // handler. There is no generic way of emitting them. OptimizationRemarkHandler(cast<DiagnosticInfoOptimizationRemark>(DI)); return; case llvm::DK_OptimizationRemarkMissed: // Optimization remarks are always handled completely by this // handler. There is no generic way of emitting them. OptimizationRemarkHandler(cast<DiagnosticInfoOptimizationRemarkMissed>(DI)); return; case llvm::DK_OptimizationRemarkAnalysis: // Optimization remarks are always handled completely by this // handler. There is no generic way of emitting them. OptimizationRemarkHandler( cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI)); return; case llvm::DK_OptimizationRemarkAnalysisFPCommute: // Optimization remarks are always handled completely by this // handler. There is no generic way of emitting them. OptimizationRemarkHandler( cast<DiagnosticInfoOptimizationRemarkAnalysisFPCommute>(DI)); return; case llvm::DK_OptimizationFailure: // Optimization failures are always handled completely by this // handler. OptimizationFailureHandler(cast<DiagnosticInfoOptimizationFailure>(DI)); return; default: // Plugin IDs are not bound to any value as they are set dynamically. ComputeDiagRemarkID(Severity, backend_plugin, DiagID); break; } std::string MsgStorage; { raw_string_ostream Stream(MsgStorage); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); } // Report the backend message using the usual diagnostic mechanism. FullSourceLoc Loc; Diags.Report(Loc, DiagID).AddString(MsgStorage); }
void LLVMContext::diagnose(const DiagnosticInfo &DI) { // If there is a report handler, use it. if (pImpl->DiagHandler && (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && pImpl->DiagHandler->handleDiagnostics(DI)) return; if (!isDiagnosticEnabled(DI)) return; // Otherwise, print the message with a prefix based on the severity. DiagnosticPrinterRawOStream DP(errs()); errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; DI.print(DP); errs() << "\n"; if (DI.getSeverity() == DS_Error) exit(1); }
static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { assert(DI.getSeverity() == DS_Error && "Only expecting errors"); raw_ostream &OS = errs(); OS << (char *)Context << ": "; DiagnosticPrinterRawOStream DP(OS); DI.print(DP); OS << '\n'; exit(1); }
void LLVMContext::diagnose(const DiagnosticInfo &DI) { if (auto *OptDiagBase = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) if (RemarkStreamer *RS = getRemarkStreamer()) RS->emit(*OptDiagBase); // If there is a report handler, use it. if (pImpl->DiagHandler && (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && pImpl->DiagHandler->handleDiagnostics(DI)) return; if (!isDiagnosticEnabled(DI)) return; // Otherwise, print the message with a prefix based on the severity. DiagnosticPrinterRawOStream DP(errs()); errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; DI.print(DP); errs() << "\n"; if (DI.getSeverity() == DS_Error) exit(1); }
static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { if (DI.getSeverity() != DS_Error) { DiagnosticPrinterRawOStream DP(errs()); DI.print(DP); errs() << '\n'; return; } sLastErrorString = ""; { raw_string_ostream Stream(sLastErrorString); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); } }
void BackendConsumer::linkerDiagnosticHandler(const DiagnosticInfo &DI) { if (DI.getSeverity() != DS_Error) return; std::string MsgStorage; { raw_string_ostream Stream(MsgStorage); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); } Diags.Report(diag::err_fe_cannot_link_module) << LinkModule->getModuleIdentifier() << MsgStorage; }
bool handleDiagnostics(const DiagnosticInfo &DI) override { if (DI.getSeverity() != DS_Error) { DiagnosticPrinterRawOStream DP(errs()); DI.print(DP); errs() << '\n'; return true; } sLastErrorString = ""; { raw_string_ostream Stream(sLastErrorString); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); } return true; }
static void diagnosticHandler(const DiagnosticInfo &DI) { unsigned Severity = DI.getSeverity(); switch (Severity) { case DS_Error: errs() << "ERROR: "; break; case DS_Warning: if (SuppressWarnings) return; errs() << "WARNING: "; break; case DS_Remark: case DS_Note: llvm_unreachable("Only expecting warnings and errors"); } DiagnosticPrinterRawOStream DP(errs()); DI.print(DP); errs() << '\n'; }
static void diagnosticHandler(const DiagnosticInfo &DI) { std::string ErrStorage; { raw_string_ostream OS(ErrStorage); DiagnosticPrinterRawOStream DP(OS); DI.print(DP); } ld_plugin_level Level; switch (DI.getSeverity()) { case DS_Error: message(LDPL_FATAL, "LLVM gold plugin has failed to create LTO module: %s", ErrStorage.c_str()); case DS_Warning: Level = LDPL_WARNING; break; case DS_Note: case DS_Remark: Level = LDPL_INFO; break; } message(Level, "LLVM gold plugin: %s", ErrStorage.c_str()); }
void LLVMContext::diagnose(const DiagnosticInfo &DI) { // If there is a report handler, use it. if (pImpl->DiagnosticHandler) { pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext); return; } // Optimization remarks are selective. They need to check whether // the regexp pattern, passed via -pass-remarks, matches the name // of the pass that is emitting the diagnostic. If there is no match, // ignore the diagnostic and return. if (DI.getKind() == llvm::DK_OptimizationRemark && !pImpl->optimizationRemarksEnabledFor( cast<DiagnosticInfoOptimizationRemark>(DI).getPassName())) return; // Otherwise, print the message with a prefix based on the severity. std::string MsgStorage; raw_string_ostream Stream(MsgStorage); DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); Stream.flush(); switch (DI.getSeverity()) { case DS_Error: errs() << "error: " << MsgStorage << "\n"; exit(1); case DS_Warning: errs() << "warning: " << MsgStorage << "\n"; break; case DS_Remark: errs() << "remark: " << MsgStorage << "\n"; break; case DS_Note: errs() << "note: " << MsgStorage << "\n"; break; } }