(P)) {
// Get the string and determining its maximum substring.
const auto &Msg = P.getString();
unsigned max_token = 0;
unsigned cnt = 0;
unsigned len = Msg.size();
for (char C : Msg)
switch (C) {
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)
if (len / characters > lines) {
++characters;
break;
}
}
em = characters / 2;
}
if (em < max_line/2)
os << "; max-width:" << em << "em";
}
else
os << "; max-width:100em";
os << "\">";
if (!SuppressIndex) {
os << "
";
os << " " << num << " ";
if (num > 1) {
os << " | ";
}
os << " | ";
}
if (const auto *MP = dyn_cast(&P)) {
os << "Within the expansion of the macro '";
// Get the name of the macro by relexing it.
{
FullSourceLoc L = MP->getLocation().asLocation().getExpansionLoc();
assert(L.isFileID());
StringRef BufferInfo = L.getBufferData();
std::pair LocInfo = L.getDecomposedLoc();
const char* MacroName = LocInfo.second + BufferInfo.data();
Lexer rawLexer(SM.getLocForStartOfFile(LocInfo.first), PP.getLangOpts(),
BufferInfo.begin(), MacroName, BufferInfo.end());
Token TheTok;
rawLexer.LexFromRawLexer(TheTok);
for (unsigned i = 0, n = TheTok.getLength(); i < n; ++i)
os << MacroName[i];
}
os << "':\n";
if (!SuppressIndex) {
os << " | ";
if (num < max) {
os << " | ";
}
os << "
";
}
// Within a macro piece. Write out each event.
ProcessMacroPiece(os, *MP, 0);
}
else {
os << html::EscapeText(P.getString());
if (!SuppressIndex) {
os << "