本文整理汇总了C++中llvm::SMDiagnostic::getKind方法的典型用法代码示例。如果您正苦于以下问题:C++ SMDiagnostic::getKind方法的具体用法?C++ SMDiagnostic::getKind怎么用?C++ SMDiagnostic::getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::SMDiagnostic
的用法示例。
在下文中一共展示了SMDiagnostic::getKind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertBackendLocation
/// InlineAsmDiagHandler2 - This function is invoked when the backend hits an
/// error parsing inline asm. The SMDiagnostic indicates the error relative to
/// the temporary memory buffer that the inline asm parser has set up.
void BackendConsumer::InlineAsmDiagHandler2(const llvm::SMDiagnostic &D,
SourceLocation LocCookie) {
// There are a couple of different kinds of errors we could get here. First,
// we re-format the SMDiagnostic in terms of a clang diagnostic.
// Strip "error: " off the start of the message string.
StringRef Message = D.getMessage();
if (Message.startswith("error: "))
Message = Message.substr(7);
// If the SMDiagnostic has an inline asm source location, translate it.
FullSourceLoc Loc;
if (D.getLoc() != SMLoc())
Loc = ConvertBackendLocation(D, Context->getSourceManager());
unsigned DiagID;
switch (D.getKind()) {
case llvm::SourceMgr::DK_Error:
DiagID = diag::err_fe_inline_asm;
break;
case llvm::SourceMgr::DK_Warning:
DiagID = diag::warn_fe_inline_asm;
break;
case llvm::SourceMgr::DK_Note:
DiagID = diag::note_fe_inline_asm;
break;
case llvm::SourceMgr::DK_Remark:
llvm_unreachable("remarks unexpected");
}
// If this problem has clang-level source location information, report the
// issue in the source with a note showing the instantiated
// code.
if (LocCookie.isValid()) {
Diags.Report(LocCookie, DiagID).AddString(Message);
if (D.getLoc().isValid()) {
DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here);
// Convert the SMDiagnostic ranges into SourceRange and attach them
// to the diagnostic.
for (const std::pair<unsigned, unsigned> &Range : D.getRanges()) {
unsigned Column = D.getColumnNo();
B << SourceRange(Loc.getLocWithOffset(Range.first - Column),
Loc.getLocWithOffset(Range.second - Column));
}
}
return;
}
// Otherwise, report the backend issue as occurring in the generated .s file.
// If Loc is invalid, we still need to report the issue, it just gets no
// location info.
Diags.Report(Loc, DiagID).AddString(Message);
}
示例2: BitcodeInlineAsmDiagHandler
static void BitcodeInlineAsmDiagHandler(const llvm::SMDiagnostic &SM,
void *Context,
unsigned LocCookie) {
SM.print(nullptr, llvm::errs());
auto Diags = static_cast<DiagnosticsEngine *>(Context);
unsigned DiagID;
switch (SM.getKind()) {
case llvm::SourceMgr::DK_Error:
DiagID = diag::err_fe_inline_asm;
break;
case llvm::SourceMgr::DK_Warning:
DiagID = diag::warn_fe_inline_asm;
break;
case llvm::SourceMgr::DK_Note:
DiagID = diag::note_fe_inline_asm;
break;
}
Diags->Report(DiagID).AddString("cannot compile inline asm");
}