本文整理汇总了C++中DirectiveList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ DirectiveList::begin方法的具体用法?C++ DirectiveList::begin怎么用?C++ DirectiveList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectiveList
的用法示例。
在下文中一共展示了DirectiveList::begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintExpected
/// \brief Takes a list of diagnostics that were expected to have been generated
/// but were not and produces a diagnostic to the user from this.
static unsigned PrintExpected(DiagnosticsEngine &Diags, const llvm::SourceMgr &SourceMgr,
DirectiveList &DL, DiagnosticsEngine::Level Kind) {
if (DL.empty())
return 0;
for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
Directive &D = **I;
Diags.ReportError(D.DirectiveLoc,llvm::Twine("Inconsistend verify directive: ")+D.Text);
}
return DL.size();
}
示例2: DiagnoseFailures
void
DiagnoseFailures(DirectiveList & DL, DirectiveMap & DM) {
for(typename DirectiveList::const_iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
Underlying & Dir = **I;
unsigned int Line = getCompilerInstance().getSourceManager().getExpansionLineNumber(Dir.getLocation());
std::pair<typename DirectiveMap::iterator, typename DirectiveMap::iterator> rng = DM.equal_range(Line);
switch (std::distance(rng.first, rng.second))
{
case 0:
Diags.Report(Dir.getLocation(), ErrVerifyDiagNoCorrespondingDecl);
break;
default:
// Delay evaluation of diagnostics until we are certain that
// none of the statements on this line match
llvm::SmallVector<MaybeDiagnostic, 4> diags;
bool isGood = false;
// TODO: If something is unexpected, then it should not appear in any of the subexpressions.
for(typename DirectiveMap::iterator it = rng.first, end = rng.second; it != end; ++it) {
MaybeDiagnostic MD = Dir.Match(it->second.second,Diags);
// unexpected-<foo> must never fail
if(Dir.isNegate()) {
if(MD.isDiagnostic()) {
diags.push_back(MD);
isGood = false;
break;
}
} else {
if(MD.isDiagnostic())
diags.push_back(MD);
else
isGood = true;
}
}
if(!isGood) {
for(std::size_t ii = 0; ii < diags.size(); ++ii)
diags[ii].maybeReport();
}
break;
}
}
}
示例3: CheckLists
/// CheckLists - Compare expected to seen diagnostic lists and return the
/// the difference between them.
///
static unsigned CheckLists(DiagnosticsEngine &Diags, SourceManager &SourceMgr,
const char *Label,
DirectiveList &Left,
const_diag_iterator d2_begin,
const_diag_iterator d2_end) {
DirectiveList LeftOnly;
DiagList Right(d2_begin, d2_end);
for (DirectiveList::iterator I = Left.begin(), E = Left.end(); I != E; ++I) {
Directive& D = **I;
unsigned LineNo1 = SourceMgr.getPresumedLineNumber(D.DiagnosticLoc);
for (unsigned i = 0; i < D.Max; ++i) {
DiagList::iterator II, IE;
for (II = Right.begin(), IE = Right.end(); II != IE; ++II) {
unsigned LineNo2 = SourceMgr.getPresumedLineNumber(II->first);
if (LineNo1 != LineNo2)
continue;
if (!IsFromSameFile(SourceMgr, D.DiagnosticLoc, II->first))
continue;
const std::string &RightText = II->second;
if (D.match(RightText))
break;
}
if (II == IE) {
// Not found.
if (i >= D.Min) break;
LeftOnly.push_back(*I);
} else {
// Found. The same cannot be found twice.
Right.erase(II);
}
}
}
// Now all that's left in Right are those that were not matched.
unsigned num = PrintExpected(Diags, SourceMgr, LeftOnly, Label);
num += PrintUnexpected(Diags, &SourceMgr, Right.begin(), Right.end(), Label);
return num;
}
示例4: PrintProblem
static unsigned PrintProblem(Diagnostic &Diags, SourceManager *SourceMgr,
DirectiveList &DL, const char *Kind,
bool Expected) {
if (DL.empty())
return 0;
llvm::SmallString<256> Fmt;
llvm::raw_svector_ostream OS(Fmt);
for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
Directive& D = **I;
if (D.Location.isInvalid() || !SourceMgr)
OS << "\n (frontend)";
else
OS << "\n Line " << SourceMgr->getInstantiationLineNumber(D.Location);
OS << ": " << D.Text;
}
Diags.Report(diag::err_verify_inconsistent_diags)
<< Kind << !Expected << OS.str();
return DL.size();
}
示例5: PrintExpected
/// \brief Takes a list of diagnostics that were expected to have been generated
/// but were not and produces a diagnostic to the user from this.
static unsigned PrintExpected(DiagnosticsEngine &Diags, SourceManager &SourceMgr,
DirectiveList &DL, const char *Kind) {
if (DL.empty())
return 0;
SmallString<256> Fmt;
llvm::raw_svector_ostream OS(Fmt);
for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
Directive &D = **I;
OS << "\n Line " << SourceMgr.getPresumedLineNumber(D.DiagnosticLoc);
if (D.DirectiveLoc != D.DiagnosticLoc)
OS << " (directive at "
<< SourceMgr.getFilename(D.DirectiveLoc) << ":"
<< SourceMgr.getPresumedLineNumber(D.DirectiveLoc) << ")";
OS << ": " << D.Text;
}
Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit()
<< Kind << /*Unexpected=*/false << OS.str();
return DL.size();
}
示例6: CheckLists
/// CheckLists - Compare expected to seen diagnostic lists and return the
/// the difference between them.
///
static unsigned CheckLists(Diagnostic &Diags, SourceManager &SourceMgr,
const char *Label,
DirectiveList &Left,
const_diag_iterator d2_begin,
const_diag_iterator d2_end) {
DirectiveList LeftOnly;
DiagList Right(d2_begin, d2_end);
for (DirectiveList::iterator I = Left.begin(), E = Left.end(); I != E; ++I) {
Directive& D = **I;
unsigned LineNo1 = SourceMgr.getInstantiationLineNumber(D.Location);
for (unsigned i = 0; i < D.Count; ++i) {
DiagList::iterator II, IE;
for (II = Right.begin(), IE = Right.end(); II != IE; ++II) {
unsigned LineNo2 = SourceMgr.getInstantiationLineNumber(II->first);
if (LineNo1 != LineNo2)
continue;
const std::string &RightText = II->second;
if (D.Match(RightText))
break;
}
if (II == IE) {
// Not found.
LeftOnly.push_back(*I);
} else {
// Found. The same cannot be found twice.
Right.erase(II);
}
}
}
// Now all that's left in Right are those that were not matched.
return (PrintProblem(Diags, &SourceMgr, LeftOnly, Label, true) +
PrintProblem(Diags, &SourceMgr, Right.begin(), Right.end(),
Label, false));
}
示例7: PrintExpected
/// \brief Takes a list of diagnostics that were expected to have been generated
/// but were not and produces a diagnostic to the user from this.
static unsigned PrintExpected(DiagnosticsEngine &Diags, llvm::SourceMgr &SourceMgr,
DirectiveList &DL, const char *Kind) {
if (DL.empty())
return 0;
SmallString<256> Fmt;
llvm::raw_svector_ostream OS(Fmt);
for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
Directive &D = **I;
OS << "\n Line " << SourceMgr.getLineAndColumn(D.DiagnosticLoc).first;
if (D.DirectiveLoc != D.DiagnosticLoc) {
int BufID = SourceMgr.FindBufferContainingLoc(D.DirectiveLoc);
OS << " (directive at "
<< SourceMgr.getMemoryBuffer(BufID)->getBufferIdentifier()
<< SourceMgr.getLineAndColumn(D.DirectiveLoc).first << ")";
}
OS << ": " << D.Text;
}
Diags.Report(SourceLocation(), diag::verify_inconsistent_diags)
<< Kind << /*Unexpected=*/false << OS.str();
return DL.size();
}