本文整理汇总了C++中DiagnosticInfo类的典型用法代码示例。如果您正苦于以下问题:C++ DiagnosticInfo类的具体用法?C++ DiagnosticInfo怎么用?C++ DiagnosticInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DiagnosticInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: diagnose
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;
}
}
示例2: Stream
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);
}
示例3: diagnosticHandler
static void diagnosticHandler(const DiagnosticInfo &DI) {
DiagnosticPrinterRawOStream DP(errs());
DI.print(DP);
errs() << '\n';
if (DI.getSeverity() == DS_Error)
exit(1);
}
示例4: diagnosticHandler
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);
}
示例5: getDiagnosticsOutputFile
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);
}
示例6: diagnosticHandler
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());
}
示例7: switch
/// \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);
}
示例8: switch
/// \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);
}
示例9: diagnosticHandler
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);
}
示例10: DiagnosticHandler
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";
}
示例11: linkerDiagnosticHandler
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;
}
示例12: DiagnosticHandler
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";
}
示例13: diagnosticHandler
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);
}
}
示例14: handleDiagnostics
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;
}
示例15: diagnosticHandler
void lld::diagnosticHandler(const DiagnosticInfo &DI) {
SmallString<128> S;
raw_svector_ostream OS(S);
DiagnosticPrinterRawOStream DP(OS);
DI.print(DP);
warn(S);
}