]> granicus.if.org Git - clang/commitdiff
Convert CreateAnalysisConsumer and friends to just take a const Preprocessor&, and...
authorDaniel Dunbar <daniel@zuster.org>
Thu, 5 Nov 2009 02:41:58 +0000 (02:41 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 5 Nov 2009 02:41:58 +0000 (02:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86112 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/AnalysisConsumer.h
include/clang/Frontend/PathDiagnosticClients.h
lib/Frontend/AnalysisConsumer.cpp
lib/Frontend/HTMLDiagnostics.cpp
lib/Frontend/PlistDiagnostics.cpp
tools/clang-cc/clang-cc.cpp

index 3c676ce1de9b533a75ccd5f4e7b2057da8fbfa56..34054a7aa00e959e83ca498cd4514cab4abb3189 100644 (file)
@@ -68,8 +68,7 @@ struct AnalyzerOptions {
 /// CreateAnalysisConsumer - Creates an ASTConsumer to run various code
 /// analysis passes.  (The set of analyses run is controlled by command-line
 /// options.)
-ASTConsumer* CreateAnalysisConsumer(Diagnostic &diags, Preprocessor *pp,
-                                    const LangOptions &lopts,
+ASTConsumer* CreateAnalysisConsumer(const Preprocessor &pp,
                                     const std::string &output,
                                     const AnalyzerOptions& Opts);
 
index 11c660c3dc2198e48b8fb070c6076f42ab19eb12..98831ba37fe3d2dcccfd83ba3f19552e0808bccb 100644 (file)
@@ -24,10 +24,10 @@ class PathDiagnosticClient;
 class Preprocessor;
 
 PathDiagnosticClient*
-CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP = 0);
+CreateHTMLDiagnosticClient(const std::string& prefix, const Preprocessor &PP);
 
 PathDiagnosticClient*
-CreatePlistDiagnosticClient(const std::string& prefix, Preprocessor* PP,
+CreatePlistDiagnosticClient(const std::string& prefix, const Preprocessor &PP,
                             PathDiagnosticClient *SubPD = 0);
 
 } // end clang namespace
index 64a6926da32f8958b8b8113faf57e9cdfe0895c8..d2831fae566ac022464e2f43f97d1b2e1b00e299 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "clang/Frontend/AnalysisConsumer.h"
-#include "clang/Frontend/PathDiagnosticClients.h"
-#include "clang/Frontend/ManagerRegistry.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
-#include "clang/Analysis/CFG.h"
+#include "clang/AST/ParentMap.h"
+#include "clang/Analysis/Analyses/LiveVariables.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/LocalCheckers.h"
 #include "clang/Analysis/PathDiagnostic.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/AST/ParentMap.h"
 #include "clang/Analysis/PathSensitive/AnalysisManager.h"
 #include "clang/Analysis/PathSensitive/BugReporter.h"
-#include "clang/Analysis/Analyses/LiveVariables.h"
-#include "clang/Analysis/LocalCheckers.h"
-#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
 #include "clang/Analysis/PathSensitive/GRExprEngine.h"
+#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Frontend/ManagerRegistry.h"
+#include "clang/Frontend/PathDiagnosticClients.h"
+#include "clang/Lex/Preprocessor.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
@@ -52,7 +53,8 @@ namespace {
 //===----------------------------------------------------------------------===//
 
 static PathDiagnosticClient*
-CreatePlistHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP) {
+CreatePlistHTMLDiagnosticClient(const std::string& prefix,
+                                const Preprocessor &PP) {
   llvm::sys::Path F(prefix);
   PathDiagnosticClient *PD = CreateHTMLDiagnosticClient(F.getDirname(), PP);
   return CreatePlistDiagnosticClient(prefix, PP, PD);
@@ -72,10 +74,8 @@ namespace {
     Actions TranslationUnitActions;
 
   public:
-    const LangOptions& LOpts;
-    Diagnostic &Diags;
     ASTContext* Ctx;
-    Preprocessor* PP;
+    const Preprocessor &PP;
     const std::string OutDir;
     AnalyzerOptions Opts;
 
@@ -88,11 +88,10 @@ namespace {
 
     llvm::OwningPtr<AnalysisManager> Mgr;
 
-    AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
-                     const LangOptions& lopts,
+    AnalysisConsumer(const Preprocessor& pp,
                      const std::string& outdir,
                      const AnalyzerOptions& opts)
-      : LOpts(lopts), Diags(diags), Ctx(0), PP(pp), OutDir(outdir),
+      : Ctx(0), PP(pp), OutDir(outdir),
         Opts(opts), PD(0) {
       DigestAnalyzerOptions();
     }
@@ -150,7 +149,8 @@ namespace {
 
     virtual void Initialize(ASTContext &Context) {
       Ctx = &Context;
-      Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD,
+      Mgr.reset(new AnalysisManager(*Ctx, PP.getDiagnostics(),
+                                    PP.getLangOptions(), PD,
                                     CreateStoreMgr, CreateConstraintMgr,
                                     Opts.AnalyzerDisplayProgress,
                                     Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
@@ -258,7 +258,7 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
 void AnalysisConsumer::HandleCode(Decl *D, Stmt* Body, Actions& actions) {
 
   // Don't run the actions if an error has occured with parsing the file.
-  if (Diags.hasErrorOccurred())
+  if (PP.getDiagnostics().hasErrorOccurred())
     return;
 
   // Don't run the actions on declarations in header files unless
@@ -438,14 +438,10 @@ static void ActionInlineCall(AnalysisManager &mgr, Decl *D) {
 // AnalysisConsumer creation.
 //===----------------------------------------------------------------------===//
 
-ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
-                                           const LangOptions& lopts,
+ASTConsumer* clang::CreateAnalysisConsumer(const Preprocessor& pp,
                                            const std::string& OutDir,
                                            const AnalyzerOptions& Opts) {
-
-  llvm::OwningPtr<AnalysisConsumer> C(new AnalysisConsumer(diags, pp,
-                                                           lopts, OutDir,
-                                                           Opts));
+  llvm::OwningPtr<AnalysisConsumer> C(new AnalysisConsumer(pp, OutDir, Opts));
 
   for (unsigned i = 0; i < Opts.AnalysisList.size(); ++i)
     switch (Opts.AnalysisList[i]) {
@@ -458,7 +454,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
     }
 
   // Last, disable the effects of '-Werror' when using the AnalysisConsumer.
-  diags.setWarningsAsErrors(false);
+  pp.getDiagnostics().setWarningsAsErrors(false);
 
   return C.take();
 }
index ffb71cf38387cae809fb82eb4fa22e7bc001cd72..145d53f3fc6e1a38b12c75c1715831210bf00ff8 100644 (file)
@@ -37,10 +37,10 @@ namespace {
 class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient {
   llvm::sys::Path Directory, FilePrefix;
   bool createdDir, noDir;
-  Preprocessor* PP;
+  const Preprocessor &PP;
   std::vector<const PathDiagnostic*> BatchedDiags;
 public:
-  HTMLDiagnostics(const std::string& prefix, Preprocessor* pp);
+  HTMLDiagnostics(const std::string& prefix, const Preprocessor &pp);
   
   virtual ~HTMLDiagnostics() { FlushDiagnostics(NULL); }
   
@@ -69,7 +69,8 @@ public:
 
 } // end anonymous namespace
 
-HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
+HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix,
+                                 const Preprocessor &pp)
   : Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false),
     PP(pp) {
   // All html files begin with "report"
@@ -77,7 +78,8 @@ HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
 }
 
 PathDiagnosticClient*
-clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP) {
+clang::CreateHTMLDiagnosticClient(const std::string& prefix,
+                                  const Preprocessor &PP) {
   return new HTMLDiagnostics(prefix, PP);
 }
 
@@ -163,7 +165,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
     return; // FIXME: Emit a warning?
 
   // Create a new rewriter to generate HTML.
-  Rewriter R(const_cast<SourceManager&>(SMgr), PP->getLangOptions());
+  Rewriter R(const_cast<SourceManager&>(SMgr), PP.getLangOptions());
 
   // Process the path.
   unsigned n = D.size();
@@ -183,8 +185,8 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
   // We might not have a preprocessor if we come from a deserialized AST file,
   // for example.
 
-  if (PP) html::SyntaxHighlight(R, FID, *PP);
-  if (PP) html::HighlightMacros(R, FID, *PP);
+  html::SyntaxHighlight(R, FID, PP);
+  html::HighlightMacros(R, FID, PP);
 
   // Get the full directory name of the analyzed file.
 
@@ -438,7 +440,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
       assert(L.isFileID());
       std::pair<const char*, const char*> BufferInfo = L.getBufferData();
       const char* MacroName = L.getDecomposedLoc().second + BufferInfo.first;
-      Lexer rawLexer(L, PP->getLangOptions(), BufferInfo.first,
+      Lexer rawLexer(L, PP.getLangOptions(), BufferInfo.first,
                      MacroName, BufferInfo.second);
 
       Token TheTok;
index 1579badc72395bf829a39fef50a8a3a1b7a0cf0c..1be9ea8b8c41c0d3d7f3e1607a1c1acebf7c15ef 100644 (file)
@@ -64,9 +64,9 @@ PlistDiagnostics::PlistDiagnostics(const std::string& output,
   : OutputFile(output), LangOpts(LO), SubPD(subPD) {}
 
 PathDiagnosticClient*
-clang::CreatePlistDiagnosticClient(const std::string& s, Preprocessor *PP,
+clang::CreatePlistDiagnosticClient(const std::string& s, const Preprocessor &PP,
                                    PathDiagnosticClient *subPD) {
-  return new PlistDiagnostics(s, PP->getLangOptions(), subPD);
+  return new PlistDiagnostics(s, PP.getLangOptions(), subPD);
 }
 
 PathDiagnosticClient::PathGenerationScheme
index 2244e918f51b0aff008339defa23edb2e3567ad1..06ae4edf0ee05e598c9fb418ee0eeeb86e8da436 100644 (file)
@@ -1729,8 +1729,7 @@ static void ProcessInputFile(Preprocessor &PP, const std::string &InFile,
     break;
 
   case RunAnalysis:
-    Consumer.reset(CreateAnalysisConsumer(PP.getDiagnostics(), &PP,
-                                          PP.getLangOptions(), OutputFile,
+    Consumer.reset(CreateAnalysisConsumer(PP, OutputFile,
                                           ReadAnalyzerOptions()));
     break;