;
35 const char*StartTag,
const char*EndTag,
38B =
SM.getExpansionLoc(B);
39 E=
SM.getExpansionLoc(
E);
41assert(
SM.getFileID(
E) == FID &&
"B/E not in the same file!");
43 unsignedBOffset =
SM.getFileOffset(B);
44 unsignedEOffset =
SM.getFileOffset(
E);
51 const char*BufferStart =
SM.getBufferData(FID, &
Invalid).data();
56BufferStart, StartTag, EndTag);
62 const char*BufferStart,
63 const char*StartTag,
const char*EndTag) {
65RB.InsertTextAfter(B, StartTag);
66RB.InsertTextBefore(
E, EndTag);
70 boolHadOpenTag =
true;
72 unsignedLastNonWhiteSpace = B;
73 for(
unsignedi = B; i !=
E; ++i) {
74 switch(BufferStart[i]) {
80RB.InsertTextBefore(LastNonWhiteSpace+1, EndTag);
99RB.InsertTextAfter(i, StartTag);
104LastNonWhiteSpace = i;
133 returnstd::make_shared<RelexRewriteCache>();
137 boolEscapeSpaces,
boolReplaceTabs) {
140 const char*
C= Buf.getBufferStart();
141 const char* FileEnd = Buf.getBufferEnd();
143assert (
C<= FileEnd);
148 for(
unsignedFilePos = 0;
C!= FileEnd ; ++
C, ++FilePos) {
150 default: ++ColNo;
break;
158RB.ReplaceText(FilePos, 1,
" ");
162RB.ReplaceText(FilePos, 1,
"<hr>");
169 unsignedNumSpaces = 8-(ColNo&7);
171RB.ReplaceText(FilePos, 1,
172StringRef(
" " 173 " ", 6*NumSpaces));
175RB.ReplaceText(FilePos, 1, StringRef(
" ", NumSpaces));
180RB.ReplaceText(FilePos, 1,
"<");
185RB.ReplaceText(FilePos, 1,
">");
190RB.ReplaceText(FilePos, 1,
"&");
199 unsignedlen =
s.size();
201llvm::raw_string_ostream os(Str);
203 for(
unsignedi = 0 ; i < len; ++i) {
211 if(EscapeSpaces) os <<
" ";
218 for(
unsignedi = 0; i < 4; ++i)
221 for(
unsignedi = 0; i < 4; ++i)
229 case '<': os <<
"<";
break;
230 case '>': os <<
">";
break;
231 case '&': os <<
"&";
break;
239 unsignedB,
unsigned E) {
241llvm::raw_svector_ostream OS(Str);
243OS <<
"<tr class=\"codeline\" data-linenumber=\""<< LineNo <<
"\">" 244<<
"<td class=\"num\" id=\"LN"<< LineNo <<
"\">"<< LineNo
245<<
"</td><td class=\"line\">";
248OS <<
" </td></tr>";
249RB.InsertTextBefore(B, OS.str());
251RB.InsertTextBefore(B, OS.str());
252RB.InsertTextBefore(
E,
"</td></tr>");
259 const char* FileBeg = Buf.getBufferStart();
260 const char* FileEnd = Buf.getBufferEnd();
261 const char*
C= FileBeg;
264assert (
C<= FileEnd);
267 unsignedFilePos = 0;
269 while(
C!= FileEnd) {
272 unsignedLineStartPos = FilePos;
273 unsignedLineEndPos = FileEnd - FileBeg;
275assert (FilePos <= LineEndPos);
276assert (
C< FileEnd);
280 while(
C!= FileEnd) {
285LineEndPos = FilePos++;
297llvm::raw_string_ostream os(
s);
298os <<
"<table class=\"code\" data-fileid=\""<< FID.
getHashValue() <<
"\">\n";
299RB.InsertTextBefore(0, os.str());
300RB.InsertTextAfter(FileEnd - FileBeg,
"</table>");
307 const char* FileStart = Buf.getBufferStart();
308 const char* FileEnd = Buf.getBufferEnd();
314llvm::raw_string_ostream os(
s);
315os <<
"<!doctype html>\n" 322<style type="text/css"> 323body { color:#000000; background-color:#ffffff } 324body { font-family:Helvetica, sans-serif; font-size:10pt } 326.FileName { margin-top: 5px; margin-bottom: 5px; display: inline; } 327.FileNav { margin-left: 5px; margin-right: 5px; display: inline; } 328.FileNav a { text-decoration:none; font-size: larger; } 329.divider { margin-top: 30px; margin-bottom: 30px; height: 15px; } 330.divider { background-color: gray; } 331.code { border-collapse:collapse; width:100%; } 332.code { font-family: "Monospace", monospace; font-size:10pt } 333.code { line-height: 1.2em } 334.comment { color: green; font-style: oblique } 335.keyword { color: blue } 336.string_literal { color: red } 337.directive { color: darkmagenta } 339/* Macros and variables could have pop-up notes hidden by default. 340 - Macro pop-up: expansion of the macro 341 - Variable pop-up: value (table) of the variable */ 342.macro_popup, .variable_popup { display: none; } 344/* Pop-up appears on mouse-hover event. */ 345.macro:hover .macro_popup, .variable:hover .variable_popup { 348 -webkit-border-radius:5px; 349 -webkit-box-shadow:1px 1px 7px #000; 351 box-shadow:1px 1px 7px #000; 359 border: 2px solid red; 360 background-color:#FFF0F0; 365 border: 2px solid blue; 366 background-color:#F0F0FF; 368 font-family: Helvetica, sans-serif; 372/* Pop-up notes needs a relative position as a base where they pops up. */ 374 background-color: PaleGoldenRod; 377.macro { color: DarkMagenta; } 385 border: 1px solid #b0b0b0; 387 box-shadow: 1px 1px 7px black; 388 background-color: #c0c0c0; 392.num { width:2.5em; padding-right:2ex; background-color:#eeeeee } 393.num { text-align:right; font-size:8pt } 394.num { color:#444444 } 395.line { padding-left: 1ex; border-left: 3px solid #ccc } 396.line { white-space: pre } 397.msg { -webkit-box-shadow:1px 1px 7px #000 } 398.msg { box-shadow:1px 1px 7px #000 } 399.msg { -webkit-border-radius:5px } 400.msg { border-radius:5px } 401.msg { font-family:Helvetica, sans-serif; font-size:8pt } 403.msg { position:relative } 404.msg { padding:0.25em 1ex 0.25em 1ex } 405.msg { margin-top:10px; margin-bottom:10px } 406.msg { font-weight:bold } 407.msg { max-width:60em; word-wrap: break-word; white-space: pre-wrap } 408.msgT { padding:0x; spacing:0x } 409.msgEvent { background-color:#fff8b4; color:#000000 } 410.msgControl { background-color:#bbbbbb; color:#000000 } 411.msgNote { background-color:#ddeeff; color:#000000 } 412.mrange { background-color:#dfddf3 } 413.mrange { border-bottom:1px solid #6F9DBE } 414.PathIndex { font-weight: bold; padding:0px 5px; margin-right:5px; } 415.PathIndex { -webkit-border-radius:8px } 416.PathIndex { border-radius:8px } 417.PathIndexEvent { background-color:#bfba87 } 418.PathIndexControl { background-color:#8c8c8c } 419.PathIndexPopUp { background-color: #879abc; } 420.PathNav a { text-decoration:none; font-size: larger } 421.CodeInsertionHint { font-weight: bold; background-color: #10dd10 } 422.CodeRemovalHint { background-color:#de1010 } 423.CodeRemovalHint { border-bottom:1px solid #6F9DBE } 424.msg.selected{ background-color:orange !important; } 430 border-collapse: collapse; border-spacing: 0px; 441input.spoilerhider + label { 443 text-decoration: underline; 449input.spoilerhider ~ .spoiler { 455input.spoilerhider:checked + label + .spoiler{ 476llvm::function_ref<
void(RewriteBuffer &,
unsigned,
unsigned,
const char*,
477 const char*,
const char*)>
478HighlightRangeCallback) {
482llvm::MemoryBufferRef FromFile =
SM.getBufferOrFake(FID);
483 const char*BufferStart = FromFile.getBuffer().data();
496 while(Tok.
isNot(tok::eof)) {
503 casetok::identifier:
504llvm_unreachable(
"tok::identifier in raw lexing mode!");
505 casetok::raw_identifier: {
511 if(Tok.
isNot(tok::identifier))
512HighlightRangeCallback(RB, TokOffs, TokOffs + TokLen, BufferStart,
513 "<span class='keyword'>",
"</span>");
517HighlightRangeCallback(RB, TokOffs, TokOffs + TokLen, BufferStart,
518 "<span class='comment'>",
"</span>");
520 casetok::utf8_string_literal:
526 casetok::wide_string_literal:
527 casetok::utf16_string_literal:
528 casetok::utf32_string_literal:
533 casetok::string_literal:
535HighlightRangeCallback(RB, TokOffs, TokOffs + TokLen, BufferStart,
536 "<span class='string_literal'>",
"</span>");
545 unsignedTokEnd = TokOffs+TokLen;
553HighlightRangeCallback(RB, TokOffs, TokEnd, BufferStart,
554 "<span class='directive'>",
"</span>");
568llvm::MemoryBufferRef FromFile =
SM.getBufferOrFake(FID);
569 const char*BufferStart = FromFile.getBuffer().data();
572 autoCacheIt =
Cache->SyntaxHighlights.find(FID);
573 if(CacheIt !=
Cache->SyntaxHighlights.end()) {
583 autoHighlightRangeCallback = [&](RewriteBuffer &RB,
unsignedB,
unsigned E,
584 const char*BufferStart,
585 const char*StartTag,
const char*EndTag) {
589 Cache->SyntaxHighlights[FID].push_back({B,
E, StartTag, EndTag});
598 const char*,
const char*,
bool)>
599HighlightRangeCallback) {
603std::vector<Token> TokenStream;
605llvm::MemoryBufferRef FromFile =
SM.getBufferOrFake(FID);
612L.LexFromRawLexer(Tok);
622 if(Tok.
is(tok::hashhash))
628 if(Tok.
is(tok::raw_identifier))
631TokenStream.push_back(Tok);
633 if(Tok.
is(tok::eof))
break;
659TmpPP.EnterTokenStream(TokenStream,
false,
false);
666 while(Tok.
isNot(tok::eof)) {
679 if(
SM.getFileID(LLoc.
getBegin()) != FID) {
684assert(
SM.getFileID(LLoc.
getEnd()) == FID &&
685 "Start and end of expansion must be in the same ultimate file!");
688 unsignedLineLen = Expansion.size();
698 while(!Tok.
is(tok::eof) &&
702Expansion +=
"<br>";
706LineLen -= Expansion.size();
711ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok, Tok))
716LineLen += Expansion.size();
718PrevPrevTok = PrevTok;
725Expansion =
"<span class='macro_popup'>"+ Expansion +
"</span></span>";
728 "<span class='macro'>", Expansion.c_str(),
744 autoCacheIt =
Cache->MacroHighlights.find(FID);
745 if(CacheIt !=
Cache->MacroHighlights.end()) {
757 const char*EndTag,
boolisTokenRange) {
761 Cache->MacroHighlights[FID].push_back(
762{B,
E, StartTag, EndTag, isTokenRange});
static void AddLineNumber(RewriteBuffer &RB, unsigned LineNo, unsigned B, unsigned E)
static void HighlightMacrosImpl(Rewriter &R, FileID FID, const Preprocessor &PP, llvm::function_ref< void(Rewriter &, SourceLocation, SourceLocation, const char *, const char *, bool)> HighlightRangeCallback)
static void SyntaxHighlightImpl(Rewriter &R, FileID FID, const Preprocessor &PP, llvm::function_ref< void(RewriteBuffer &, unsigned, unsigned, const char *, const char *, const char *)> HighlightRangeCallback)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords,...
Defines the clang::Preprocessor interface.
Defines the SourceManager interface.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
Represents a character-granular source range.
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token.
SourceLocation getEnd() const
SourceLocation getBegin() const
Concrete class used by the front-end to report problems and issues.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
unsigned getHashValue() const
A diagnostic client that ignores all diagnostics.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
void SetCommentRetentionState(bool Mode)
SetCommentRetentionMode - Change the comment retention mode of the lexer to the specified mode.
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 ...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
IdentifierInfo * LookUpIdentifierInfo(Token &Identifier) const
Given a tok::raw_identifier token, look up the identifier information for the token and install it in...
void setDiagnostics(DiagnosticsEngine &D)
void Lex(Token &Result)
Lex the next token for this preprocessor.
SourceManager & getSourceManager() const
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
const LangOptions & getLangOpts() const
void setPragmasEnabled(bool Enabled)
void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments)
Control whether the preprocessor retains comments in output.
bool getPragmasEnabled() const
DiagnosticsEngine & getDiagnostics() const
Rewriter - This is the main interface to the rewrite buffers.
bool InsertTextBefore(SourceLocation Loc, StringRef Str)
InsertText - Insert the specified string at the specified location in the original buffer.
SourceManager & getSourceMgr() const
const LangOptions & getLangOpts() const
bool InsertTextAfter(SourceLocation Loc, StringRef Str)
InsertTextAfter - Insert the specified string at the specified location in the original buffer.
llvm::RewriteBuffer & getEditBuffer(FileID FID)
getEditBuffer - This is like getRewriteBufferFor, but always returns a buffer, and allows you to writ...
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
llvm::MemoryBufferRef getBufferOrFake(FileID FID, SourceLocation Loc=SourceLocation()) const
Return the buffer for the specified FileID.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
TokenConcatenation class, which answers the question of "Is it safe to emit two tokens without a whit...
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
void setKind(tok::TokenKind K)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
bool isNot(tok::TokenKind K) const
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID, StringRef title)
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.
RelexRewriteCacheRef instantiateRelexRewriteCache()
If you need to rewrite the same file multiple times, you can instantiate a RelexRewriteCache and refe...
void AddLineNumbers(Rewriter &R, FileID FID)
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP, RelexRewriteCacheRef Cache=nullptr)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords,...
void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP, RelexRewriteCacheRef Cache=nullptr)
HighlightMacros - This uses the macro table state from the end of the file, to reexpand macros and in...
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 ...
std::shared_ptr< RelexRewriteCache > RelexRewriteCacheRef
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
std::vector< RawHighlight > RawHighlightList
DenseMap< FileID, RawHighlightList > SyntaxHighlights
std::vector< Highlight > HighlightList
DenseMap< FileID, HighlightList > MacroHighlights
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4