24 #include "llvm/Support/MemoryBuffer.h"
25 #include "llvm/Support/raw_ostream.h"
26 using namespace clang;
35 std::unique_ptr<raw_ostream> Out;
40 HTMLPrinter(std::unique_ptr<raw_ostream> OS,
Preprocessor &pp,
41 bool _SyntaxHighlight,
bool _HighlightMacros)
46 void HandleTranslationUnit(
ASTContext &Ctx)
override;
50 std::unique_ptr<ASTConsumer>
53 return llvm::make_unique<HTMLPrinter>(std::move(OS), PP,
SyntaxHighlight,
57 void HTMLPrinter::Initialize(
ASTContext &context) {
61 void HTMLPrinter::HandleTranslationUnit(
ASTContext &Ctx) {
62 if (PP.getDiagnostics().hasErrorOccurred())
66 FileID FID = R.getSourceMgr().getMainFileID();
67 const FileEntry* Entry = R.getSourceMgr().getFileEntryForID(FID);
75 Name = R.getSourceMgr().getBuffer(FID)->getBufferIdentifier();
90 char *
Buffer = (
char*)malloc(RewriteBuf.
size());
92 Out->write(Buffer, RewriteBuf.
size());
Defines the clang::ASTContext interface.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Defines the clang::FileManager interface and associated types.
Defines the SourceManager interface.
std::unique_ptr< llvm::MemoryBuffer > Buffer
RewriteBuffer - As code is rewritten, SourceBuffer's from the original input with modifications get a...
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...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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)
const LangOptions & getLangOpts() const
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP)
SyntaxHighlight - Relex the specified FileID and annotate the HTML with information about keywords...
Defines the clang::Preprocessor interface.
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID, const char *title=nullptr)
const char * getName() const
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 ...
Cached information about one file (either on disk or in the virtual file system). ...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Defines the Diagnostic-related interfaces.
SourceManager & getSourceManager()
Rewriter - This is the main interface to the rewrite buffers.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.