Go to the documentation of this file.
23 #include "llvm/Support/raw_ostream.h"
24 using namespace clang;
33 std::unique_ptr<raw_ostream> Out;
38 HTMLPrinter(std::unique_ptr<raw_ostream> OS,
Preprocessor &pp,
39 bool _SyntaxHighlight,
bool _HighlightMacros)
44 void HandleTranslationUnit(
ASTContext &Ctx)
override;
48 std::unique_ptr<ASTConsumer>
51 return std::make_unique<HTMLPrinter>(std::move(OS), PP,
SyntaxHighlight,
55 void HTMLPrinter::Initialize(
ASTContext &context) {
59 void HTMLPrinter::HandleTranslationUnit(
ASTContext &Ctx) {
60 if (PP.getDiagnostics().hasErrorOccurred())
64 FileID FID = R.getSourceMgr().getMainFileID();
65 const FileEntry* Entry = R.getSourceMgr().getFileEntryForID(FID);
73 Name = R.getSourceMgr().getBufferOrFake(FID).getBufferIdentifier();
88 std::unique_ptr<char[]> Buffer(
new char[RewriteBuf.
size()]);
89 std::copy(RewriteBuf.
begin(), RewriteBuf.
end(), Buffer.get());
90 Out->write(Buffer.get(), RewriteBuf.
size());
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...
SourceManager & getSourceManager()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void AddLineNumbers(Rewriter &R, FileID FID)
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords,...
Cached information about one file (either on disk or in the virtual file system).
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 ...
RewriteBuffer - As code is rewritten, SourceBuffer's from the original input with modifications get a...
StringRef getName() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Rewriter - This is the main interface to the rewrite buffers.
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID, StringRef title)
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
std::unique_ptr< ASTConsumer > CreateHTMLPrinter(std::unique_ptr< raw_ostream > OS, Preprocessor &PP, bool SyntaxHighlight=true, bool HighlightMacros=true)
CreateHTMLPrinter - Create an AST consumer which rewrites source code to HTML with syntax highlightin...
const LangOptions & getLangOpts() const
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...