本文整理汇总了C++中PathDiagnosticPiece::getKind方法的典型用法代码示例。如果您正苦于以下问题:C++ PathDiagnosticPiece::getKind方法的具体用法?C++ PathDiagnosticPiece::getKind怎么用?C++ PathDiagnosticPiece::getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathDiagnosticPiece
的用法示例。
在下文中一共展示了PathDiagnosticPiece::getKind方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReportPiece
static void ReportPiece(raw_ostream &o,
const PathDiagnosticPiece &P,
const FIDMap& FM, const SourceManager &SM,
const LangOptions &LangOpts,
unsigned indent,
unsigned depth,
bool includeControlFlow,
bool isKeyEvent) {
switch (P.getKind()) {
case PathDiagnosticPiece::ControlFlow:
if (includeControlFlow)
ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
LangOpts, indent);
break;
case PathDiagnosticPiece::Call:
ReportCall(o, cast<PathDiagnosticCallPiece>(P), FM, SM, LangOpts,
indent, depth);
break;
case PathDiagnosticPiece::Event:
ReportEvent(o, cast<PathDiagnosticSpotPiece>(P), FM, SM, LangOpts,
indent, depth, isKeyEvent);
break;
case PathDiagnosticPiece::Macro:
ReportMacro(o, cast<PathDiagnosticMacroPiece>(P), FM, SM, LangOpts,
indent, depth);
break;
}
}
示例2: compareControlFlow
static Optional<bool> comparePiece(const PathDiagnosticPiece &X,
const PathDiagnosticPiece &Y) {
if (X.getKind() != Y.getKind())
return X.getKind() < Y.getKind();
FullSourceLoc XL = X.getLocation().asLocation();
FullSourceLoc YL = Y.getLocation().asLocation();
if (XL != YL)
return XL.isBeforeInTranslationUnitThan(YL);
if (X.getString() != Y.getString())
return X.getString() < Y.getString();
if (X.getRanges().size() != Y.getRanges().size())
return X.getRanges().size() < Y.getRanges().size();
const SourceManager &SM = XL.getManager();
for (unsigned i = 0, n = X.getRanges().size(); i < n; ++i) {
SourceRange XR = X.getRanges()[i];
SourceRange YR = Y.getRanges()[i];
if (XR != YR) {
if (XR.getBegin() != YR.getBegin())
return SM.isBeforeInTranslationUnit(XR.getBegin(), YR.getBegin());
return SM.isBeforeInTranslationUnit(XR.getEnd(), YR.getEnd());
}
}
switch (X.getKind()) {
case PathDiagnosticPiece::ControlFlow:
return compareControlFlow(cast<PathDiagnosticControlFlowPiece>(X),
cast<PathDiagnosticControlFlowPiece>(Y));
case PathDiagnosticPiece::Event:
case PathDiagnosticPiece::Note:
return None;
case PathDiagnosticPiece::Macro:
return compareMacro(cast<PathDiagnosticMacroPiece>(X),
cast<PathDiagnosticMacroPiece>(Y));
case PathDiagnosticPiece::Call:
return compareCall(cast<PathDiagnosticCallPiece>(X),
cast<PathDiagnosticCallPiece>(Y));
}
llvm_unreachable("all cases handled");
}
示例3: calculateImportance
static Importance calculateImportance(const PathDiagnosticPiece &Piece) {
switch (Piece.getKind()) {
case PathDiagnosticPiece::Kind::Call:
case PathDiagnosticPiece::Kind::Macro:
case PathDiagnosticPiece::Kind::Note:
// FIXME: What should be reported here?
break;
case PathDiagnosticPiece::Kind::Event:
return Piece.getTagStr() == "ConditionBRVisitor" ? Importance::Important
: Importance::Essential;
case PathDiagnosticPiece::Kind::ControlFlow:
return Importance::Unimportant;
}
return Importance::Unimportant;
}
示例4: ReportDiag
static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
const FIDMap& FM, const SourceManager &SM,
const LangOptions &LangOpts) {
unsigned indent = 4;
switch (P.getKind()) {
case PathDiagnosticPiece::ControlFlow:
ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
LangOpts, indent);
break;
case PathDiagnosticPiece::Event:
ReportEvent(o, cast<PathDiagnosticEventPiece>(P), FM, SM, LangOpts,
indent);
break;
case PathDiagnosticPiece::Macro:
ReportMacro(o, cast<PathDiagnosticMacroPiece>(P), FM, SM, LangOpts,
indent);
break;
}
}
示例5: flattenTo
void PathPieces::flattenTo(PathPieces &Primary, PathPieces &Current,
bool ShouldFlattenMacros) const {
for (PathPieces::const_iterator I = begin(), E = end(); I != E; ++I) {
PathDiagnosticPiece *Piece = I->getPtr();
switch (Piece->getKind()) {
case PathDiagnosticPiece::Call: {
PathDiagnosticCallPiece *Call = cast<PathDiagnosticCallPiece>(Piece);
IntrusiveRefCntPtr<PathDiagnosticEventPiece> CallEnter =
Call->getCallEnterEvent();
if (CallEnter)
Current.push_back(CallEnter);
Call->path.flattenTo(Primary, Primary, ShouldFlattenMacros);
IntrusiveRefCntPtr<PathDiagnosticEventPiece> callExit =
Call->getCallExitEvent();
if (callExit)
Current.push_back(callExit);
break;
}
case PathDiagnosticPiece::Macro: {
PathDiagnosticMacroPiece *Macro = cast<PathDiagnosticMacroPiece>(Piece);
if (ShouldFlattenMacros) {
Macro->subPieces.flattenTo(Primary, Primary, ShouldFlattenMacros);
} else {
Current.push_back(Piece);
PathPieces NewPath;
Macro->subPieces.flattenTo(Primary, NewPath, ShouldFlattenMacros);
// FIXME: This probably shouldn't mutate the original path piece.
Macro->subPieces = NewPath;
}
break;
}
case PathDiagnosticPiece::Event:
case PathDiagnosticPiece::ControlFlow:
Current.push_back(Piece);
break;
}
}
}
示例6: HandlePiece
void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
const PathDiagnosticPiece& P,
unsigned num, unsigned max) {
// For now, just draw a box above the line in question, and emit the
// warning.
FullSourceLoc Pos = P.getLocation().asLocation();
if (!Pos.isValid())
return;
SourceManager &SM = R.getSourceMgr();
assert(&Pos.getManager() == &SM && "SourceManagers are different!");
std::pair<FileID, unsigned> LPosInfo = SM.getDecomposedExpansionLoc(Pos);
if (LPosInfo.first != BugFileID)
return;
const llvm::MemoryBuffer *Buf = SM.getBuffer(LPosInfo.first);
const char* FileStart = Buf->getBufferStart();
// Compute the column number. Rewind from the current position to the start
// of the line.
unsigned ColNo = SM.getColumnNumber(LPosInfo.first, LPosInfo.second);
const char *TokInstantiationPtr =Pos.getExpansionLoc().getCharacterData();
const char *LineStart = TokInstantiationPtr-ColNo;
// Compute LineEnd.
const char *LineEnd = TokInstantiationPtr;
const char* FileEnd = Buf->getBufferEnd();
while (*LineEnd != '\n' && LineEnd != FileEnd)
++LineEnd;
// Compute the margin offset by counting tabs and non-tabs.
unsigned PosNo = 0;
for (const char* c = LineStart; c != TokInstantiationPtr; ++c)
PosNo += *c == '\t' ? 8 : 1;
// Create the html for the message.
const char *Kind = 0;
switch (P.getKind()) {
case PathDiagnosticPiece::Call:
llvm_unreachable("Calls should already be handled");
case PathDiagnosticPiece::Event: Kind = "Event"; break;
case PathDiagnosticPiece::ControlFlow: Kind = "Control"; break;
// Setting Kind to "Control" is intentional.
case PathDiagnosticPiece::Macro: Kind = "Control"; break;
}
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "\n<tr><td class=\"num\"></td><td class=\"line\"><div id=\"";
if (num == max)
os << "EndPath";
else
os << "Path" << num;
os << "\" class=\"msg";
if (Kind)
os << " msg" << Kind;
os << "\" style=\"margin-left:" << PosNo << "ex";
// Output a maximum size.
if (!isa<PathDiagnosticMacroPiece>(P)) {
// Get the string and determining its maximum substring.
const std::string& Msg = P.getString();
unsigned max_token = 0;
unsigned cnt = 0;
unsigned len = Msg.size();
for (std::string::const_iterator I=Msg.begin(), E=Msg.end(); I!=E; ++I)
switch (*I) {
default:
++cnt;
continue;
case ' ':
case '\t':
case '\n':
if (cnt > max_token) max_token = cnt;
cnt = 0;
}
if (cnt > max_token)
max_token = cnt;
// Determine the approximate size of the message bubble in em.
unsigned em;
const unsigned max_line = 120;
if (max_token >= max_line)
em = max_token / 2;
else {
unsigned characters = max_line;
unsigned lines = len / max_line;
if (lines > 0) {
for (; characters > max_token; --characters)
//.........这里部分代码省略.........