本文整理汇总了C++中SMDiagnostic::getKind方法的典型用法代码示例。如果您正苦于以下问题:C++ SMDiagnostic::getKind方法的具体用法?C++ SMDiagnostic::getKind怎么用?C++ SMDiagnostic::getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMDiagnostic
的用法示例。
在下文中一共展示了SMDiagnostic::getKind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: diagFromLLVMAssemblyDiag
SMDiagnostic MIRParserImpl::diagFromLLVMAssemblyDiag(const SMDiagnostic &Error,
SMRange SourceRange) {
assert(SourceRange.isValid());
// Translate the location of the error from the location in the llvm IR string
// to the corresponding location in the MIR file.
auto LineAndColumn = SM.getLineAndColumn(SourceRange.Start);
unsigned Line = LineAndColumn.first + Error.getLineNo() - 1;
unsigned Column = Error.getColumnNo();
StringRef LineStr = Error.getLineContents();
SMLoc Loc = Error.getLoc();
// Get the full line and adjust the column number by taking the indentation of
// LLVM IR into account.
for (line_iterator L(*SM.getMemoryBuffer(SM.getMainFileID()), false), E;
L != E; ++L) {
if (L.line_number() == Line) {
LineStr = *L;
Loc = SMLoc::getFromPointer(LineStr.data());
auto Indent = LineStr.find(Error.getLineContents());
if (Indent != StringRef::npos)
Column += Indent;
break;
}
}
return SMDiagnostic(SM, Loc, Filename, Line, Column, Error.getKind(),
Error.getMessage(), LineStr, Error.getRanges(),
Error.getFixIts());
}
示例2: diagFromMIStringDiag
SMDiagnostic MIRParserImpl::diagFromMIStringDiag(const SMDiagnostic &Error,
SMRange SourceRange) {
assert(SourceRange.isValid() && "Invalid source range");
SMLoc Loc = SourceRange.Start;
bool HasQuote = Loc.getPointer() < SourceRange.End.getPointer() &&
*Loc.getPointer() == '\'';
// Translate the location of the error from the location in the MI string to
// the corresponding location in the MIR file.
Loc = Loc.getFromPointer(Loc.getPointer() + Error.getColumnNo() +
(HasQuote ? 1 : 0));
// TODO: Translate any source ranges as well.
return SM.GetMessage(Loc, Error.getKind(), Error.getMessage(), None,
Error.getFixIts());
}
示例3: reportDiagnostic
void MIRParserImpl::reportDiagnostic(const SMDiagnostic &Diag) {
DiagnosticSeverity Kind;
switch (Diag.getKind()) {
case SourceMgr::DK_Error:
Kind = DS_Error;
break;
case SourceMgr::DK_Warning:
Kind = DS_Warning;
break;
case SourceMgr::DK_Note:
Kind = DS_Note;
break;
}
Context.diagnose(DiagnosticInfoMIRParser(Kind, Diag));
}
示例4: error
bool MIRParserImpl::error(const SMDiagnostic &Error, SMRange SourceRange) {
assert(Error.getKind() == SourceMgr::DK_Error && "Expected an error");
reportDiagnostic(diagFromMIStringDiag(Error, SourceRange));
return true;
}