summaryrefslogtreecommitdiffstats
path: root/clang/Driver
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-16 06:11:58 +0000
committerChris Lattner <sabre@nondot.org>2008-04-16 06:11:58 +0000
commit060d8aa2edceb01c5dd6e3b9bf248bf0c73b6d4e (patch)
tree79698b16053d2e73f5ab09a20501040139dcb6be /clang/Driver
parentdffe0f7db5fc6f7556c3513fc99f24d414c1b0f5 (diff)
downloadbcm5719-llvm-060d8aa2edceb01c5dd6e3b9bf248bf0c73b6d4e.tar.gz
bcm5719-llvm-060d8aa2edceb01c5dd6e3b9bf248bf0c73b6d4e.zip
Add a mode of hackily syntax highlighting comments. This has a number of
problems, including the fact that it doesn't work well with multi-line comments due to Ted's crazy table. However, that could be fixed, and it does work with single-line ones :). llvm-svn: 49778
Diffstat (limited to 'clang/Driver')
-rw-r--r--clang/Driver/ASTConsumers.h4
-rw-r--r--clang/Driver/HTMLPrint.cpp15
-rw-r--r--clang/Driver/clang.cpp11
3 files changed, 19 insertions, 11 deletions
diff --git a/clang/Driver/ASTConsumers.h b/clang/Driver/ASTConsumers.h
index 91ee8fbf938..6054fdf443a 100644
--- a/clang/Driver/ASTConsumers.h
+++ b/clang/Driver/ASTConsumers.h
@@ -27,6 +27,7 @@ class ASTConsumer;
class Diagnostic;
class FileManager;
struct LangOptions;
+class Preprocessor;
ASTConsumer *CreateASTPrinter(std::ostream* OS = NULL);
@@ -57,7 +58,8 @@ ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
Diagnostic &Diags,
const LangOptions &LOpts);
- ASTConsumer* CreateHTMLPrinter(const std::string &OutFile, Diagnostic &D);
+ASTConsumer* CreateHTMLPrinter(const std::string &OutFile, Diagnostic &D,
+ Preprocessor *PP);
ASTConsumer *CreateSerializationTest(Diagnostic &Diags,
FileManager& FMgr,
diff --git a/clang/Driver/HTMLPrint.cpp b/clang/Driver/HTMLPrint.cpp
index 44cd6244ecc..cb32afd8175 100644
--- a/clang/Driver/HTMLPrint.cpp
+++ b/clang/Driver/HTMLPrint.cpp
@@ -30,9 +30,10 @@ namespace {
Rewriter R;
std::string OutFilename;
Diagnostic &Diags;
+ Preprocessor *PP;
public:
- HTMLPrinter(const std::string &OutFile, Diagnostic &D)
- : OutFilename(OutFile), Diags(D) {}
+ HTMLPrinter(const std::string &OutFile, Diagnostic &D, Preprocessor *pp)
+ : OutFilename(OutFile), Diags(D), PP(pp) {}
virtual ~HTMLPrinter();
void Initialize(ASTContext &context);
@@ -40,8 +41,8 @@ namespace {
}
ASTConsumer* clang::CreateHTMLPrinter(const std::string &OutFile,
- Diagnostic &D) {
- return new HTMLPrinter(OutFile, D);
+ Diagnostic &D, Preprocessor *PP) {
+ return new HTMLPrinter(OutFile, D, PP);
}
void HTMLPrinter::Initialize(ASTContext &context) {
@@ -58,6 +59,12 @@ HTMLPrinter::~HTMLPrinter() {
html::AddLineNumbers(R, FileID);
html::AddHeaderFooterInternalBuiltinCSS(R, FileID);
+ // If we have a preprocessor, relex the file and syntax hilight. We might not
+ // have a preprocessor if we come from a deserialized AST file, for example.
+ if (PP)
+ html::SyntaxHighlight(R, FileID, *PP);
+
+
// Open the output.
FILE *OutputFILE;
if (OutFilename.empty() || OutFilename == "-")
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 09140c942e0..a9ae98e5550 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -1033,6 +1033,7 @@ static void ParseFile(Preprocessor &PP, MinimalAction *PA){
static ASTConsumer* CreateASTConsumer(const std::string& InFile,
Diagnostic& Diag, FileManager& FileMgr,
const LangOptions& LangOpts,
+ Preprocessor *PP,
llvm::Module *&DestModule) {
switch (ProgAction) {
default:
@@ -1048,7 +1049,7 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
return CreateASTViewer();
case EmitHTML:
- return CreateHTMLPrinter(OutputFile, Diag);
+ return CreateHTMLPrinter(OutputFile, Diag, PP);
case ParseCFGDump:
case ParseCFGView:
@@ -1099,10 +1100,8 @@ static void ProcessInputFile(Preprocessor &PP, const std::string &InFile) {
switch (ProgAction) {
default:
- Consumer = CreateASTConsumer(InFile,
- PP.getDiagnostics(),
- PP.getFileManager(),
- PP.getLangOptions(),
+ Consumer = CreateASTConsumer(InFile, PP.getDiagnostics(),
+ PP.getFileManager(), PP.getLangOptions(), &PP,
CodeGenModule);
if (!Consumer) {
@@ -1242,7 +1241,7 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
// translation unit, rather than InFile.
llvm::Module *DestModule;
llvm::OwningPtr<ASTConsumer>
- Consumer(CreateASTConsumer(InFile, Diag, FileMgr, TU->getLangOpts(),
+ Consumer(CreateASTConsumer(InFile, Diag, FileMgr, TU->getLangOpts(), 0,
DestModule));
if (!Consumer) {
OpenPOWER on IntegriCloud