[cfe-commits] r49796 - in /cfe/trunk/Driver: ASTConsumers.cpp ASTConsumers.h HTMLDiagnostics.cpp HTMLDiagnostics.h HTMLPrint.cpp clang.cpp

Ted Kremenek kremenek at apple.com
Wed Apr 16 09:39:57 PDT 2008


Author: kremenek
Date: Wed Apr 16 11:39:56 2008
New Revision: 49796

URL: http://llvm.org/viewvc/llvm-project?rev=49796&view=rev
Log:
Hook up HTMLDiagnostics to use Chris's new syntax highlighting.  --html-diags
currently doesn't pass in the Preprocessor from the driver, so we don't get
syntax highlighting when we create HTMLDiagnostics in that way.

Modified:
    cfe/trunk/Driver/ASTConsumers.cpp
    cfe/trunk/Driver/ASTConsumers.h
    cfe/trunk/Driver/HTMLDiagnostics.cpp
    cfe/trunk/Driver/HTMLDiagnostics.h
    cfe/trunk/Driver/HTMLPrint.cpp
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=49796&r1=49795&r2=49796&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Wed Apr 16 11:39:56 2008
@@ -624,7 +624,7 @@
 }
 
 //===----------------------------------------------------------------------===//
-// CheckeRConsumer - Generic Driver for running intra-procedural path-sensitive
+// CheckerConsumer - Generic Driver for running intra-procedural path-sensitive
 //  analyses.
 
 namespace {
@@ -633,16 +633,18 @@
 protected:
   Diagnostic &Diags;
   ASTContext* Ctx;
+  Preprocessor* PP;
   const std::string& HTMLDir;
   bool Visualize;
   bool TrimGraph;
   llvm::OwningPtr<PathDiagnosticClient> PD;
   bool AnalyzeAll;
 public:
-  CheckerConsumer(Diagnostic &diags, const std::string& fname,
-            const std::string& htmldir,
-            bool visualize, bool trim, bool analyzeAll)
-    : CFGVisitor(fname), Diags(diags), HTMLDir(htmldir),
+  CheckerConsumer(Diagnostic &diags, Preprocessor* pp,
+                  const std::string& fname,
+                  const std::string& htmldir,
+                  bool visualize, bool trim, bool analyzeAll)
+    : CFGVisitor(fname), Diags(diags), PP(pp), HTMLDir(htmldir),
       Visualize(visualize), TrimGraph(trim), AnalyzeAll(analyzeAll) {}
   
   virtual void Initialize(ASTContext &Context) { Ctx = &Context; }    
@@ -670,7 +672,7 @@
   // Lazily create the diagnostic client.
   
   if (!HTMLDir.empty() && PD.get() == NULL)
-    PD.reset(CreateHTMLDiagnosticClient(HTMLDir));
+    PD.reset(CreateHTMLDiagnosticClient(HTMLDir, PP));
   
 
   if (!Visualize) {
@@ -716,10 +718,10 @@
 namespace {
 class GRSimpleValsVisitor : public CheckerConsumer {
 public:
-  GRSimpleValsVisitor(Diagnostic &diags, const std::string& fname,
-                      const std::string& htmldir,
+  GRSimpleValsVisitor(Diagnostic &diags, Preprocessor* pp,
+                      const std::string& fname, const std::string& htmldir,
                       bool visualize, bool trim, bool analyzeAll)
-  : CheckerConsumer(diags, fname, htmldir, visualize, trim, analyzeAll) {}
+  : CheckerConsumer(diags, pp, fname, htmldir, visualize, trim, analyzeAll) {}
 
   virtual const char* getCheckerName() { return "GRSimpleVals"; }
   
@@ -730,12 +732,13 @@
 } // end anonymous namespace
 
 ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags,
+                                       Preprocessor* PP,
                                        const std::string& FunctionName,
                                        const std::string& HTMLDir,
                                        bool Visualize, bool TrimGraph,
                                        bool AnalyzeAll) {
   
-  return new GRSimpleValsVisitor(Diags, FunctionName, HTMLDir,
+  return new GRSimpleValsVisitor(Diags, PP, FunctionName, HTMLDir,
                                  Visualize, TrimGraph, AnalyzeAll);
 }
 
@@ -746,10 +749,11 @@
 namespace {
 class CFRefCountCheckerVisitor : public CheckerConsumer {
 public:
-  CFRefCountCheckerVisitor(Diagnostic &diags, const std::string& fname,
-                      const std::string& htmldir,
-                      bool visualize, bool trim, bool analyzeAll)
-  : CheckerConsumer(diags, fname, htmldir, visualize, trim, analyzeAll) {}
+  CFRefCountCheckerVisitor(Diagnostic &diags, Preprocessor* pp,
+                           const std::string& fname,
+                           const std::string& htmldir,
+                           bool visualize, bool trim, bool analyzeAll)
+  : CheckerConsumer(diags, pp, fname, htmldir, visualize, trim, analyzeAll) {}
   
   virtual const char* getCheckerName() { return "CFRefCountChecker"; }
   
@@ -760,12 +764,13 @@
 } // end anonymous namespace
 
 ASTConsumer* clang::CreateCFRefChecker(Diagnostic &Diags,
+                                       Preprocessor* PP,
                                        const std::string& FunctionName,
                                        const std::string& HTMLDir,
                                        bool Visualize, bool TrimGraph,
                                        bool AnalyzeAll) {
   
-  return new CFRefCountCheckerVisitor(Diags, FunctionName, HTMLDir,
+  return new CFRefCountCheckerVisitor(Diags, PP, FunctionName, HTMLDir,
                                       Visualize, TrimGraph, AnalyzeAll);
 }
 

Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=49796&r1=49795&r2=49796&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Wed Apr 16 11:39:56 2008
@@ -44,11 +44,13 @@
 ASTConsumer *CreateUnitValsChecker(Diagnostic &Diags);
   
 ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags,
+                                Preprocessor* PP,
                                 const std::string& Function,
                                 const std::string& HTMLDir, bool Visualize,
                                 bool TrimGraph, bool AnalyzeAll);
   
 ASTConsumer *CreateCFRefChecker(Diagnostic &Diags,
+                                Preprocessor* PP,
                                 const std::string& Function,
                                 const std::string& HTMLDir, bool Visualize,
                                 bool TrimGraph, bool AnalyzeAll);

Modified: cfe/trunk/Driver/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLDiagnostics.cpp?rev=49796&r1=49795&r2=49796&view=diff

==============================================================================
--- cfe/trunk/Driver/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/Driver/HTMLDiagnostics.cpp Wed Apr 16 11:39:56 2008
@@ -37,8 +37,9 @@
 class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient {
   llvm::sys::Path Directory, FilePrefix;
   bool createdDir, noDir;
+  Preprocessor* PP;
 public:
-  HTMLDiagnostics(const std::string& prefix);
+  HTMLDiagnostics(const std::string& prefix, Preprocessor* pp = NULL);
 
   virtual ~HTMLDiagnostics() {}
   
@@ -52,17 +53,18 @@
   
 } // end anonymous namespace
 
-HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix)
-  : Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false) {
+HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
+  : Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false),
+    PP(pp) {
   
   // All html files begin with "report" 
   FilePrefix.appendComponent("report");
 }
 
 PathDiagnosticClient*
-clang::CreateHTMLDiagnosticClient(const std::string& prefix) {
+clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP) {
   
-  return new HTMLDiagnostics(prefix);
+  return new HTMLDiagnostics(prefix, PP);
 }
 
 //===----------------------------------------------------------------------===//
@@ -116,6 +118,15 @@
   html::EscapeText(R, FileID);
   html::AddLineNumbers(R, FileID);
   
+  // If we have a preprocessor, relex the file and syntax highlight.
+  // We might not have a preprocessor if we come from a deserialized AST file,
+  // for example.
+  
+  if (PP) {
+    html::SyntaxHighlight(R, FileID, *PP);
+    html::HighlightMacros(R, FileID, *PP);
+  }
+  
   // Get the full directory name of the analyzed file.
 
   const FileEntry* Entry = SMgr.getFileEntryForID(FileID);

Modified: cfe/trunk/Driver/HTMLDiagnostics.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLDiagnostics.h?rev=49796&r1=49795&r2=49796&view=diff

==============================================================================
--- cfe/trunk/Driver/HTMLDiagnostics.h (original)
+++ cfe/trunk/Driver/HTMLDiagnostics.h Wed Apr 16 11:39:56 2008
@@ -18,8 +18,10 @@
 
 namespace clang {
   class PathDiagnosticClient;
+  class Preprocessor;
   
-  PathDiagnosticClient* CreateHTMLDiagnosticClient(const std::string& prefix);
+  PathDiagnosticClient* CreateHTMLDiagnosticClient(const std::string& prefix,
+                                                   Preprocessor* PP);
 }
 
 #endif

Modified: cfe/trunk/Driver/HTMLPrint.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLPrint.cpp?rev=49796&r1=49795&r2=49796&view=diff

==============================================================================
--- cfe/trunk/Driver/HTMLPrint.cpp (original)
+++ cfe/trunk/Driver/HTMLPrint.cpp Wed Apr 16 11:39:56 2008
@@ -59,8 +59,10 @@
   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 we have a preprocessor, relex the file and syntax highlight.
+  // We might not have a preprocessor if we come from a deserialized AST file,
+  // for example.
+  
   if (PP) {
     html::SyntaxHighlight(R, FileID, *PP);
     html::HighlightMacros(R, FileID, *PP);

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=49796&r1=49795&r2=49796&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Apr 16 11:39:56 2008
@@ -1066,11 +1066,11 @@
       return CreateUnitValsChecker(Diag);
       
     case AnalysisGRSimpleVals:
-      return CreateGRSimpleVals(Diag, AnalyzeSpecificFunction, OutputFile,
+      return CreateGRSimpleVals(Diag, PP, AnalyzeSpecificFunction, OutputFile,
                                 VisualizeEG, TrimGraph, AnalyzeAll);
       
     case CheckerCFRef:
-      return CreateCFRefChecker(Diag, AnalyzeSpecificFunction, OutputFile,
+      return CreateCFRefChecker(Diag, PP, AnalyzeSpecificFunction, OutputFile,
                                 VisualizeEG, TrimGraph, AnalyzeAll);
       
     case TestSerialization:
@@ -1290,7 +1290,7 @@
   TextDiagnostics* TextDiagClient = NULL;
   
   if (!HTMLDiag.empty()) {
-    DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
+    DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag, NULL));
   }
   else { // Use Text diagnostics.
     if (!VerifyDiagnostics) {





More information about the cfe-commits mailing list