本文整理汇总了C++中SourceMgr::FindBufferContainingLoc方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceMgr::FindBufferContainingLoc方法的具体用法?C++ SourceMgr::FindBufferContainingLoc怎么用?C++ SourceMgr::FindBufferContainingLoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceMgr
的用法示例。
在下文中一共展示了SourceMgr::FindBufferContainingLoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckSame
bool CheckString::CheckSame(const SourceMgr &SM, StringRef Buffer) const {
if (CheckTy != Check::CheckSame)
return false;
// Count the number of newlines between the previous match and this one.
assert(Buffer.data() !=
SM.getMemoryBuffer(SM.FindBufferContainingLoc(
SMLoc::getFromPointer(Buffer.data())))
->getBufferStart() &&
"CHECK-SAME can't be the first check in a file");
const char *FirstNewLine = nullptr;
unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
if (NumNewLines != 0) {
SM.PrintMessage(Loc, SourceMgr::DK_Error,
Prefix +
"-SAME: is not on the same line as the previous match");
SM.PrintMessage(SMLoc::getFromPointer(Buffer.end()), SourceMgr::DK_Note,
"'next' match was here");
SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,
"previous match ended here");
return true;
}
return false;
}