28 #include "llvm/ADT/ArrayRef.h" 29 #include "llvm/ADT/SmallString.h" 30 #include "llvm/ADT/StringRef.h" 31 #include "llvm/ADT/iterator_range.h" 32 #include "llvm/Support/Casting.h" 33 #include "llvm/Support/Errc.h" 34 #include "llvm/Support/ErrorHandling.h" 35 #include "llvm/Support/FileSystem.h" 36 #include "llvm/Support/MemoryBuffer.h" 37 #include "llvm/Support/Path.h" 38 #include "llvm/Support/raw_ostream.h" 46 #include <system_error> 50 using namespace clang;
59 class HTMLDiagnostics :
public PathDiagnosticConsumer {
60 PathDiagnosticConsumerOptions DiagOpts;
61 std::string Directory;
62 bool createdDir =
false;
65 const bool SupportsCrossFileDiagnostics;
68 HTMLDiagnostics(PathDiagnosticConsumerOptions DiagOpts,
70 bool supportsMultipleFiles)
71 : DiagOpts(
std::move(DiagOpts)), Directory(OutputDir), PP(pp),
72 SupportsCrossFileDiagnostics(supportsMultipleFiles) {}
74 ~HTMLDiagnostics()
override { FlushDiagnostics(
nullptr); }
76 void FlushDiagnosticsImpl(std::vector<const PathDiagnostic *> &Diags,
77 FilesMade *filesMade)
override;
79 StringRef
getName()
const override {
80 return "HTMLDiagnostics";
83 bool supportsCrossFileDiagnostics()
const override {
84 return SupportsCrossFileDiagnostics;
87 unsigned ProcessMacroPiece(raw_ostream &os,
88 const PathDiagnosticMacroPiece&
P,
91 void HandlePiece(
Rewriter &R,
FileID BugFileID,
const PathDiagnosticPiece &
P,
92 const std::vector<SourceRange> &PopUpRanges,
unsigned num,
96 const char *HighlightStart =
"<span class=\"mrange\">",
97 const char *HighlightEnd =
"</span>");
99 void ReportDiag(
const PathDiagnostic& D,
100 FilesMade *filesMade);
103 std::string GenerateHTML(
const PathDiagnostic& D,
Rewriter &R,
105 const char *declName);
108 void FinalizeHTML(
const PathDiagnostic& D,
Rewriter &R,
113 void RewriteFile(
Rewriter &R,
const PathPieces& path,
FileID FID);
118 StringRef showHelpJavascript();
121 StringRef generateKeyboardNavigationJavascript();
124 std::string showRelevantLinesJavascript(
125 const PathDiagnostic &D,
const PathPieces &path);
128 void dumpCoverageData(
const PathDiagnostic &D,
129 const PathPieces &path,
130 llvm::raw_string_ostream &os);
135 void ento::createHTMLDiagnosticConsumer(
145 createTextMinimalPathDiagnosticConsumer(DiagOpts, C, OutputDir, PP, CTU);
148 if (OutputDir.empty())
151 C.push_back(
new HTMLDiagnostics(std::move(DiagOpts), OutputDir, PP,
true));
154 void ento::createHTMLSingleFileDiagnosticConsumer(
158 createTextMinimalPathDiagnosticConsumer(DiagOpts, C, OutputDir, PP, CTU);
161 if (OutputDir.empty())
164 C.push_back(
new HTMLDiagnostics(std::move(DiagOpts), OutputDir, PP,
false));
167 void ento::createPlistHTMLDiagnosticConsumer(
171 createHTMLDiagnosticConsumer(
172 DiagOpts, C, std::string(llvm::sys::path::parent_path(prefix)), PP,
174 createPlistMultiFileDiagnosticConsumer(DiagOpts, C, prefix, PP, CTU);
175 createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, prefix, PP,
183 void HTMLDiagnostics::FlushDiagnosticsImpl(
184 std::vector<const PathDiagnostic *> &Diags,
185 FilesMade *filesMade) {
186 for (
const auto Diag : Diags)
187 ReportDiag(*
Diag, filesMade);
190 void HTMLDiagnostics::ReportDiag(
const PathDiagnostic& D,
191 FilesMade *filesMade) {
195 if (std::error_code ec = llvm::sys::fs::create_directories(Directory)) {
196 llvm::errs() <<
"warning: could not create directory '" 197 << Directory <<
"': " << ec.message() <<
'\n';
207 PathPieces path = D.path.flatten(
false);
210 assert(!path.empty());
211 const SourceManager &SMgr = path.front()->getLocation().getManager();
219 FileID ReportFile = path.front()->getLocation().asLocation().getExpansionLoc().getFileID();
224 if (
const Decl *DeclWithIssue = D.getDeclWithIssue()) {
225 if (
const auto *ND = dyn_cast<NamedDecl>(DeclWithIssue))
226 declName = ND->getDeclName().getAsString();
228 if (
const Stmt *Body = DeclWithIssue->getBody()) {
232 SMgr.getExpansionLoc(path.back()->getLocation().asLocation()),
234 FullSourceLoc FunL(SMgr.getExpansionLoc(Body->getBeginLoc()), SMgr);
235 offsetDecl = L.getExpansionLineNumber() - FunL.getExpansionLineNumber();
239 std::string report = GenerateHTML(D, R, SMgr, path, declName.c_str());
240 if (report.empty()) {
241 llvm::errs() <<
"warning: no diagnostics generated for main file.\n";
249 if (!DiagOpts.ShouldWriteStableReportFilename) {
250 llvm::sys::path::append(Model, Directory,
"report-%%%%%%.html");
251 if (std::error_code EC =
252 llvm::sys::fs::make_absolute(Model)) {
253 llvm::errs() <<
"warning: could not make '" << Model
254 <<
"' absolute: " << EC.message() <<
'\n';
257 if (std::error_code EC =
258 llvm::sys::fs::createUniqueFile(Model, FD, ResultPath)) {
259 llvm::errs() <<
"warning: could not create file in '" << Directory
260 <<
"': " << EC.message() <<
'\n';
268 const FileEntry* Entry = SMgr.getFileEntryForID(ReportFile);
269 std::stringstream filename;
271 filename <<
"report-" 272 << llvm::sys::path::filename(Entry->
getName()).str()
273 <<
"-" << declName.c_str()
275 <<
"-" << i <<
".html";
276 llvm::sys::path::append(Model, Directory,
278 EC = llvm::sys::fs::openFileForReadWrite(
279 Model, FD, llvm::sys::fs::CD_CreateNew, llvm::sys::fs::OF_None);
280 if (EC && EC != llvm::errc::file_exists) {
281 llvm::errs() <<
"warning: could not create file '" << Model
282 <<
"': " << EC.message() <<
'\n';
289 llvm::raw_fd_ostream os(FD,
true);
292 filesMade->addDiagnostic(D,
getName(),
293 llvm::sys::path::filename(ResultPath));
299 std::string HTMLDiagnostics::GenerateHTML(
const PathDiagnostic& D,
Rewriter &R,
300 const SourceManager& SMgr,
const PathPieces& path,
const char *declName) {
302 std::vector<FileID> FileIDs;
303 for (
auto I : path) {
304 FileID FID = I->getLocation().asLocation().getExpansionLoc().getFileID();
305 if (llvm::is_contained(FileIDs, FID))
308 FileIDs.push_back(FID);
309 RewriteFile(R, path, FID);
312 if (SupportsCrossFileDiagnostics && FileIDs.size() > 1) {
314 for (
auto I = FileIDs.begin(), E = FileIDs.end(); I != E; I++) {
316 llvm::raw_string_ostream os(
s);
318 if (I != FileIDs.begin())
319 os <<
"<hr class=divider>\n";
321 os <<
"<div id=File" << I->getHashValue() <<
">\n";
324 if (I != FileIDs.begin())
325 os <<
"<div class=FileNav><a href=\"#File" << (I - 1)->getHashValue()
326 <<
"\">←</a></div>";
333 os <<
"<div class=FileNav><a href=\"#File" << (I + 1)->getHashValue()
334 <<
"\">→</a></div>";
342 for (
auto I : llvm::make_range(FileIDs.begin() + 1, FileIDs.end())) {
344 llvm::raw_string_ostream os(
s);
360 path.back()->getLocation().asLocation().getExpansionLoc().getFileID();
362 FinalizeHTML(D, R, SMgr, path, FileIDs[0], Entry, declName);
365 llvm::raw_string_ostream os(file);
372 void HTMLDiagnostics::dumpCoverageData(
373 const PathDiagnostic &D,
374 const PathPieces &path,
375 llvm::raw_string_ostream &os) {
379 os <<
"var relevant_lines = {";
380 for (
auto I = ExecutedLines.begin(),
381 E = ExecutedLines.end(); I != E; ++I) {
382 if (I != ExecutedLines.begin())
385 os <<
"\"" << I->first.getHashValue() <<
"\": {";
386 for (
unsigned LineNo : I->second) {
387 if (LineNo != *(I->second.begin()))
390 os <<
"\"" << LineNo <<
"\": 1";
398 std::string HTMLDiagnostics::showRelevantLinesJavascript(
399 const PathDiagnostic &D,
const PathPieces &path) {
401 llvm::raw_string_ostream os(
s);
402 os <<
"<script type='text/javascript'>\n";
403 dumpCoverageData(D, path, os);
406 var filterCounterexample = function (hide) { 407 var tables = document.getElementsByClassName("code"); 408 for (var t=0; t<tables.length; t++) { 409 var table = tables[t]; 410 var file_id = table.getAttribute("data-fileid"); 411 var lines_in_fid = relevant_lines[file_id]; 415 var lines = table.getElementsByClassName("codeline"); 416 for (var i=0; i<lines.length; i++) { 418 var lineNo = el.getAttribute("data-linenumber"); 419 if (!lines_in_fid[lineNo]) { 421 el.setAttribute("hidden", ""); 423 el.removeAttribute("hidden"); 430 window.addEventListener("keydown", function (event) { 431 if (event.defaultPrevented) { 434 if (event.key == "S") { 435 var checked = document.getElementsByName("showCounterexample")[0].checked; 436 filterCounterexample(!checked); 437 document.getElementsByName("showCounterexample")[0].checked = !checked; 441 event.preventDefault(); 444 document.addEventListener("DOMContentLoaded", function() { 445 document.querySelector('input[name="showCounterexample"]').onchange= 447 filterCounterexample(this.checked); 453 <input type="checkbox" name="showCounterexample" id="showCounterexample" /> 454 <label for="showCounterexample"> 455 Show only relevant lines 463 void HTMLDiagnostics::FinalizeHTML(
const PathDiagnostic& D,
Rewriter &R,
465 const FileEntry *Entry,
const char *declName) {
472 if (llvm::sys::path::is_relative(Entry->
getName())) {
473 llvm::sys::fs::current_path(DirName);
477 int LineNumber = path.back()->getLocation().asLocation().getExpansionLineNumber();
478 int ColumnNumber = path.back()->getLocation().asLocation().getExpansionColumnNumber();
483 generateKeyboardNavigationJavascript());
487 showRelevantLinesJavascript(D, path));
492 llvm::raw_string_ostream os(
s);
494 os <<
"<!-- REPORTHEADER -->\n" 495 <<
"<h3>Bug Summary</h3>\n<table class=\"simpletable\">\n" 496 "<tr><td class=\"rowname\">File:</td><td>" 499 <<
"</td></tr>\n<tr><td class=\"rowname\">Warning:</td><td>" 500 "<a href=\"#EndPath\">line " 505 << D.getVerboseDescription() <<
"</td></tr>\n";
508 unsigned NumExtraPieces = 0;
509 for (
const auto &Piece : path) {
510 if (
const auto *
P = dyn_cast<PathDiagnosticNotePiece>(Piece.get())) {
512 P->getLocation().asLocation().getExpansionLineNumber();
514 P->getLocation().asLocation().getExpansionColumnNumber();
515 os <<
"<tr><td class=\"rowname\">Note:</td><td>" 516 <<
"<a href=\"#Note" << NumExtraPieces <<
"\">line " 517 << LineNumber <<
", column " << ColumnNumber <<
"</a><br />" 518 <<
P->getString() <<
"</td></tr>";
532 <!-- REPORTSUMMARYEXTRA --> 533 <h3>Annotated Source Code</h3> 534 <p>Press <a href="#" onclick="toggleHelp(); return false;">'?'</a> 535 to see keyboard shortcuts</p> 536 <input type="checkbox" class="spoilerhider" id="showinvocation" /> 537 <label for="showinvocation" >Show analyzer invocation</label> 538 <div class="spoiler">clang -cc1 )<<<"; 542 <div id='tooltiphint' hidden="true"> 543 <p>Keyboard shortcuts: </p> 545 <li>Use 'j/k' keys for keyboard navigation</li> 546 <li>Use 'Shift+S' to show/hide relevant lines</li> 547 <li>Use '?' to toggle this window</li> 549 <a href="#" onclick="toggleHelp(); return false;">Close</a> 558 llvm::raw_string_ostream os(
s);
560 StringRef BugDesc = D.getVerboseDescription();
561 if (!BugDesc.empty())
562 os <<
"\n<!-- BUGDESC " << BugDesc <<
" -->\n";
564 StringRef BugType = D.getBugType();
565 if (!BugType.empty())
566 os <<
"\n<!-- BUGTYPE " << BugType <<
" -->\n";
568 PathDiagnosticLocation UPDLoc = D.getUniqueingLoc();
570 ? UPDLoc.asLocation()
571 : D.getLocation().asLocation()),
573 const Decl *DeclWithIssue = D.getDeclWithIssue();
575 StringRef BugCategory = D.getCategory();
576 if (!BugCategory.empty())
577 os <<
"\n<!-- BUGCATEGORY " << BugCategory <<
" -->\n";
579 os <<
"\n<!-- BUGFILE " << DirName << Entry->
getName() <<
" -->\n";
581 os <<
"\n<!-- FILENAME " << llvm::sys::path::filename(Entry->
getName()) <<
" -->\n";
583 os <<
"\n<!-- FUNCTIONNAME " << declName <<
" -->\n";
585 os <<
"\n<!-- ISSUEHASHCONTENTOFLINEINCONTEXT " 586 <<
getIssueHash(L, D.getCheckerName(), D.getBugType(), DeclWithIssue,
590 os <<
"\n<!-- BUGLINE " 594 os <<
"\n<!-- BUGCOLUMN " 598 os <<
"\n<!-- BUGPATHLENGTH " << path.size() <<
" -->\n";
601 os <<
"\n<!-- BUGMETAEND -->\n";
610 StringRef HTMLDiagnostics::showHelpJavascript() {
612 <script type='text/javascript'> 614 var toggleHelp = function() { 615 var hint = document.querySelector("#tooltiphint"); 616 var attributeName = "hidden"; 617 if (hint.hasAttribute(attributeName)) { 618 hint.removeAttribute(attributeName); 620 hint.setAttribute("hidden", "true"); 623 window.addEventListener("keydown", function (event) { 624 if (event.defaultPrevented) { 627 if (event.key == "?") { 632 event.preventDefault(); 639 return !(Range.getBegin().isMacroID() || Range.getEnd().isMacroID());
644 const std::vector<SourceRange> &PopUpRanges) {
645 for (
const auto &Range : PopUpRanges) {
650 "<table class='variable_popup'><tbody>",
656 const PathDiagnosticPopUpPiece &Piece,
657 std::vector<SourceRange> &PopUpRanges,
658 unsigned int LastReportedPieceIndex,
659 unsigned int PopUpPieceIndex) {
661 llvm::raw_svector_ostream Out(Buf);
668 Out <<
"<tr><td valign='top'><div class='PathIndex PathIndexPopUp'>" 669 << LastReportedPieceIndex;
672 Out <<
'.' << PopUpPieceIndex;
674 Out <<
"</div></td><td>" << Piece.getString() <<
"</td></tr>";
677 if (std::find(PopUpRanges.begin(), PopUpRanges.end(), Range) ==
680 PopUpRanges.push_back(Range);
682 Out <<
"</tbody></table></span>";
684 "<span class='variable'>", Buf.c_str(),
693 void HTMLDiagnostics::RewriteFile(
Rewriter &R,
694 const PathPieces& path,
FileID FID) {
697 unsigned TotalPieces = path.size();
698 unsigned TotalNotePieces = std::count_if(
700 return isa<PathDiagnosticNotePiece>(*p);
702 unsigned PopUpPieceCount = std::count_if(
704 return isa<PathDiagnosticPopUpPiece>(*p);
707 unsigned TotalRegularPieces = TotalPieces - TotalNotePieces - PopUpPieceCount;
708 unsigned NumRegularPieces = TotalRegularPieces;
709 unsigned NumNotePieces = TotalNotePieces;
711 std::map<int, int> IndexMap;
714 std::vector<SourceRange> PopUpRanges;
715 for (
auto I = path.rbegin(), E = path.rend(); I != E; ++I) {
716 const auto &Piece = *I->get();
718 if (isa<PathDiagnosticPopUpPiece>(Piece)) {
719 ++IndexMap[NumRegularPieces];
720 }
else if (isa<PathDiagnosticNotePiece>(Piece)) {
724 HandlePiece(R, FID, Piece, PopUpRanges, NumNotePieces, TotalNotePieces);
727 HandlePiece(R, FID, Piece, PopUpRanges, NumRegularPieces,
735 NumRegularPieces = TotalRegularPieces;
736 for (
auto I = path.rbegin(), E = path.rend(); I != E; ++I) {
737 const auto &Piece = *I->get();
739 if (
const auto *PopUpP = dyn_cast<PathDiagnosticPopUpPiece>(&Piece)) {
740 int PopUpPieceIndex = IndexMap[NumRegularPieces];
750 if (PopUpPieceIndex > 0)
751 --IndexMap[NumRegularPieces];
753 }
else if (!isa<PathDiagnosticNotePiece>(Piece)) {
773 const PathDiagnosticPiece &
P,
774 const std::vector<SourceRange> &PopUpRanges,
775 unsigned num,
unsigned max) {
784 assert(&Pos.
getManager() == &
SM &&
"SourceManagers are different!");
785 std::pair<FileID, unsigned> LPosInfo =
SM.getDecomposedExpansionLoc(Pos);
787 if (LPosInfo.first != BugFileID)
790 llvm::MemoryBufferRef Buf =
SM.getBufferOrFake(LPosInfo.first);
791 const char *FileStart = Buf.getBufferStart();
795 unsigned ColNo =
SM.getColumnNumber(LPosInfo.first, LPosInfo.second);
797 const char *LineStart = TokInstantiationPtr-ColNo;
800 const char *LineEnd = TokInstantiationPtr;
801 const char *FileEnd = Buf.getBufferEnd();
802 while (*LineEnd !=
'\n' && LineEnd != FileEnd)
807 for (
const char*
c = LineStart;
c != TokInstantiationPtr; ++
c)
808 PosNo += *
c ==
'\t' ? 8 : 1;
812 const char *
Kind =
nullptr;
814 bool SuppressIndex = (
max == 1);
815 switch (
P.getKind()) {
823 SuppressIndex =
true;
827 llvm_unreachable(
"Calls and extra notes should already be handled");
831 llvm::raw_string_ostream os(sbuf);
833 os <<
"\n<tr><td class=\"num\"></td><td class=\"line\"><div id=\"";
842 os <<
"\" class=\"msg";
844 os <<
" msg" <<
Kind;
845 os <<
"\" style=\"margin-left:" << PosNo <<
"ex";
848 if (!isa<PathDiagnosticMacroPiece>(
P)) {
850 const auto &Msg =
P.getString();
851 unsigned max_token = 0;
853 unsigned len = Msg.size();
863 if (cnt > max_token) max_token = cnt;
872 const unsigned max_line = 120;
874 if (max_token >= max_line)
877 unsigned characters = max_line;
878 unsigned lines = len / max_line;
881 for (; characters > max_token; --characters)
882 if (len / characters > lines) {
892 os <<
"; max-width:" << em <<
"em";
895 os <<
"; max-width:100em";
899 if (!SuppressIndex) {
900 os <<
"<table class=\"msgT\"><tr><td valign=\"top\">";
901 os <<
"<div class=\"PathIndex";
902 if (
Kind) os <<
" PathIndex" <<
Kind;
903 os <<
"\">" << num <<
"</div>";
906 os <<
"</td><td><div class=\"PathNav\"><a href=\"#Path" 908 <<
"\" title=\"Previous event (" 910 <<
")\">←</a></div>";
916 if (
const auto *MP = dyn_cast<PathDiagnosticMacroPiece>(&
P)) {
917 os <<
"Within the expansion of the macro '";
925 const char* MacroName = LocInfo.second + BufferInfo.data();
927 BufferInfo.begin(), MacroName, BufferInfo.end());
930 rawLexer.LexFromRawLexer(TheTok);
931 for (
unsigned i = 0, n = TheTok.getLength(); i < n; ++i)
937 if (!SuppressIndex) {
940 os <<
"<td><div class=\"PathNav\"><a href=\"#";
944 os <<
"Path" << (num + 1);
945 os <<
"\" title=\"Next event (" 947 <<
")\">→</a></div></td>";
950 os <<
"</tr></table>";
954 ProcessMacroPiece(os, *MP, 0);
959 if (!SuppressIndex) {
962 os <<
"<td><div class=\"PathNav\"><a href=\"#";
966 os <<
"Path" << (num + 1);
967 os <<
"\" title=\"Next event (" 969 <<
")\">→</a></div></td>";
972 os <<
"</tr></table>";
976 os <<
"</div></td></tr>";
979 unsigned DisplayPos = LineEnd - FileStart;
981 SM.getLocForStartOfFile(LPosInfo.first).getLocWithOffset(DisplayPos);
987 for (
const auto &Range : Ranges) {
989 if (std::find(PopUpRanges.begin(), PopUpRanges.end(),
Range) !=
998 unsigned x = n % (
'z' -
'a');
1004 os << char(
'a' + x);
1007 unsigned HTMLDiagnostics::ProcessMacroPiece(raw_ostream &os,
1008 const PathDiagnosticMacroPiece&
P,
1010 for (
const auto &subPiece :
P.subPieces) {
1011 if (
const auto *MP = dyn_cast<PathDiagnosticMacroPiece>(subPiece.get())) {
1012 num = ProcessMacroPiece(os, *MP, num);
1016 if (
const auto *EP = dyn_cast<PathDiagnosticEventPiece>(subPiece.get())) {
1017 os <<
"<div class=\"msg msgEvent\" style=\"width:94%; " 1018 "margin-left:5px\">" 1019 "<table class=\"msgT\"><tr>" 1020 "<td valign=\"top\"><div class=\"PathIndex PathIndexEvent\">";
1022 os <<
"</div></td><td valign=\"top\">" 1024 <<
"</td></tr></table></div>\n";
1033 const char *HighlightStart,
1034 const char *HighlightEnd) {
1039 unsigned StartLineNo =
SM.getExpansionLineNumber(InstantiationStart);
1042 unsigned EndLineNo =
SM.getExpansionLineNumber(InstantiationEnd);
1044 if (EndLineNo < StartLineNo)
1047 if (
SM.getFileID(InstantiationStart) != BugFileID ||
1048 SM.getFileID(InstantiationEnd) != BugFileID)
1052 unsigned EndColNo =
SM.getExpansionColumnNumber(InstantiationEnd);
1053 unsigned OldEndColNo = EndColNo;
1069 StringRef HTMLDiagnostics::generateKeyboardNavigationJavascript() {
1071 <script type='text/javascript'> 1072 var digitMatcher = new RegExp("[0-9]+"); 1074 var querySelectorAllArray = function(selector) { 1075 return Array.prototype.slice.call( 1076 document.querySelectorAll(selector)); 1079 document.addEventListener("DOMContentLoaded", function() { 1080 querySelectorAllArray(".PathNav > a").forEach( 1081 function(currentValue, currentIndex) { 1082 var hrefValue = currentValue.getAttribute("href"); 1083 currentValue.onclick = function() { 1084 scrollTo(document.querySelector(hrefValue)); 1090 var findNum = function() { 1091 var s = document.querySelector(".selected"); 1092 if (!s || s.id == "EndPath") { 1095 var out = parseInt(digitMatcher.exec(s.id)[0]); 1099 var scrollTo = function(el) { 1100 querySelectorAllArray(".selected").forEach(function(s) { 1101 s.classList.remove("selected"); 1103 el.classList.add("selected"); 1104 window.scrollBy(0, el.getBoundingClientRect().top - 1105 (window.innerHeight / 2)); 1108 var move = function(num, up, numItems) { 1109 if (num == 1 && up || num == numItems - 1 && !up) { 1111 } else if (num == 0 && up) { 1112 return numItems - 1; 1113 } else if (num == 0 && !up) { 1114 return 1 % numItems; 1116 return up ? num - 1 : num + 1; 1119 var numToId = function(num) { 1121 return document.getElementById("EndPath") 1123 return document.getElementById("Path" + num); 1126 var navigateTo = function(up) { 1127 var numItems = document.querySelectorAll( 1128 ".line > .msgEvent, .line > .msgControl").length; 1129 var currentSelected = findNum(); 1130 var newSelected = move(currentSelected, up, numItems); 1131 var newEl = numToId(newSelected, numItems); 1133 // Scroll element into center. 1137 window.addEventListener("keydown", function (event) { 1138 if (event.defaultPrevented) { 1141 if (event.key == "j") { 1142 navigateTo(/*up=*/false); 1143 } else if (event.key == "k") { 1144 navigateTo(/*up=*/true); 1148 event.preventDefault(); SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
SourceLocation getLocForEndOfFile(FileID FID) const
Return the source location corresponding to the last byte of the specified file.
Defines the clang::FileManager interface and associated types.
FullSourceLoc getExpansionLoc() const
Stmt - This represents one statement.
static bool shouldDisplayPopUpRange(const SourceRange &Range)
Defines the SourceManager interface.
__DEVICE__ int max(int __a, int __b)
llvm::SmallString< 32 > getIssueHash(const FullSourceLoc &IssueLoc, llvm::StringRef CheckerName, llvm::StringRef WarningMessage, const Decl *IssueDecl, const LangOptions &LangOpts)
Returns an opaque identifier for a diagnostic.
Decl - This represents one declaration (or definition), e.g.
RewriteBuffer - As code is rewritten, SourceBuffer's from the original input with modifications get a...
void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP)
HighlightMacros - This uses the macro table state from the end of the file, to reexpand macros and in...
void AddLineNumbers(Rewriter &R, FileID FID)
Token - This structure provides full information about a lexed token.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const LangOptions & getLangOpts() const
static void HandlePopUpPieceStartTag(Rewriter &R, const std::vector< SourceRange > &PopUpRanges)
SourceManager & getSourceMgr() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords,...
__device__ __2f16 float bool s
static void HandlePopUpPieceEndTag(Rewriter &R, const PathDiagnosticPopUpPiece &Piece, std::vector< SourceRange > &PopUpRanges, unsigned int LastReportedPieceIndex, unsigned int PopUpPieceIndex)
std::pair< FileID, unsigned > getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
static unsigned MeasureTokenLength(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
MeasureTokenLength - Relex the token at the specified location and return its length in bytes in the ...
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
static void EmitAlphaCounter(raw_ostream &os, unsigned n)
const char * getCharacterData(bool *Invalid=nullptr) const
Defines the clang::Preprocessor interface.
const SourceManager & getManager() const
std::map< FileID, std::set< unsigned > > FilesToLineNumsMap
File IDs mapped to sets of line numbers.
Encodes a location in the source.
StringRef getName() const
std::vector< PathDiagnosticConsumer * > PathDiagnosticConsumers
void EscapeText(Rewriter &R, FileID FID, bool EscapeSpaces=false, bool ReplaceTabs=false)
EscapeText - HTMLize a specified file so that special characters are are translated so that they are ...
bool InsertTextAfter(SourceLocation Loc, StringRef Str)
InsertTextAfter - Insert the specified string at the specified location in the original buffer.
Cached information about one file (either on disk or in the virtual file system).
std::deque< std::string >::const_iterator meta_iterator
const RewriteBuffer * getRewriteBufferFor(FileID FID) const
getRewriteBufferFor - Return the rewrite buffer for the specified FileID.
StringRef getBufferData(bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
bool InsertTextBefore(SourceLocation Loc, StringRef Str)
InsertText - Insert the specified string at the specified location in the original buffer.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
static std::string getName(const CallEvent &Call)
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID, StringRef title)
This class is used for tools that requires cross translation unit capability.
const LangOptions & getLangOpts() const
Rewriter - This is the main interface to the rewrite buffers.
Defines the clang::SourceLocation class and associated facilities.
void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E, const char *StartTag, const char *EndTag, bool IsTokenRange=true)
HighlightRange - Highlight a range in the source code with the specified start/end tags.
A SourceLocation and its associated SourceManager.
std::shared_ptr< PathDiagnosticPiece > PathDiagnosticPieceRef
A trivial tuple used to represent a source range.
This class handles loading and caching of source files into memory.
__device__ __2f16 float c
Engages in a tight little dance with the lexer to efficiently preprocess tokens.