当前位置: 首页>>代码示例>>C++>>正文


C++ DiagnosticInfo类代码示例

本文整理汇总了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;
  }
}
开发者ID:c0d1f1ed,项目名称:llvm,代码行数:32,代码来源:LLVMContext.cpp

示例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);
}
开发者ID:GameFusion,项目名称:llvm,代码行数:29,代码来源:LTOCodeGenerator.cpp

示例3: diagnosticHandler

static void diagnosticHandler(const DiagnosticInfo &DI) {
    DiagnosticPrinterRawOStream DP(errs());
    DI.print(DP);
    errs() << '\n';
    if (DI.getSeverity() == DS_Error)
        exit(1);
}
开发者ID:cadets,项目名称:llvm,代码行数:7,代码来源:Miscompilation.cpp

示例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);
}
开发者ID:ispras,项目名称:llvm-for-v8,代码行数:28,代码来源:llvm-lto.cpp

示例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);
}
开发者ID:BNieuwenhuizen,项目名称:llvm,代码行数:26,代码来源:LLVMContext.cpp

示例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());
}
开发者ID:nightwishud,项目名称:accmut,代码行数:29,代码来源:gold-plugin.cpp

示例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);
}
开发者ID:bhushan23,项目名称:clang,代码行数:33,代码来源:CodeGenAction.cpp

示例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);
}
开发者ID:oyeniyi-wale,项目名称:clang,代码行数:60,代码来源:CodeGenAction.cpp

示例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);
}
开发者ID:AmesianX,项目名称:llvm-othergen,代码行数:10,代码来源:llvm-dis.cpp

示例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";
}
开发者ID:OpenKimono,项目名称:llvm,代码行数:10,代码来源:llc.cpp

示例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;
}
开发者ID:oyeniyi-wale,项目名称:clang,代码行数:14,代码来源:CodeGenAction.cpp

示例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";
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例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);
  }
}
开发者ID:efcs,项目名称:llvm,代码行数:14,代码来源:lto.cpp

示例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;
 }
开发者ID:jamboree,项目名称:llvm,代码行数:15,代码来源:lto.cpp

示例15: diagnosticHandler

void lld::diagnosticHandler(const DiagnosticInfo &DI) {
  SmallString<128> S;
  raw_svector_ostream OS(S);
  DiagnosticPrinterRawOStream DP(OS);
  DI.print(DP);
  warn(S);
}
开发者ID:wenyuzhao,项目名称:lld,代码行数:7,代码来源:ErrorHandler.cpp


注:本文中的DiagnosticInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。