From 5e86044ec411f6497198ecfb83a5931313f07495 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 5 Nov 2009 02:09:23 +0000 Subject: Acting on Daniel's nagging, remove PathDiagnosticClientFactory() and migrate work in the destructors of PathDiagnosticClients from their destructors to FlushReports(). The destructors now currently call FlushReports(); this will be fixed in a subsequent patch. llvm-svn: 86108 --- clang/lib/Frontend/HTMLDiagnostics.cpp | 70 ++++++++++------------------------ 1 file changed, 21 insertions(+), 49 deletions(-) (limited to 'clang/lib/Frontend/HTMLDiagnostics.cpp') diff --git a/clang/lib/Frontend/HTMLDiagnostics.cpp b/clang/lib/Frontend/HTMLDiagnostics.cpp index 648ecac3bf4..935b6da6261 100644 --- a/clang/lib/Frontend/HTMLDiagnostics.cpp +++ b/clang/lib/Frontend/HTMLDiagnostics.cpp @@ -39,16 +39,20 @@ class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient { bool createdDir, noDir; Preprocessor* PP; std::vector BatchedDiags; - llvm::SmallVectorImpl *FilesMade; public: - HTMLDiagnostics(const std::string& prefix, Preprocessor* pp, - llvm::SmallVectorImpl *filesMade = 0); - - virtual ~HTMLDiagnostics(); + HTMLDiagnostics(const std::string& prefix, Preprocessor* pp); + + virtual ~HTMLDiagnostics() { FlushDiagnostics(NULL); } + + virtual void FlushDiagnostics(llvm::SmallVectorImpl *FilesMade); virtual void SetPreprocessor(Preprocessor *pp) { PP = pp; } virtual void HandlePathDiagnostic(const PathDiagnostic* D); + + virtual llvm::StringRef getName() const { + return "HTMLDiagnostics"; + } unsigned ProcessMacroPiece(llvm::raw_ostream& os, const PathDiagnosticMacroPiece& P, @@ -61,57 +65,22 @@ public: const char *HighlightStart = "", const char *HighlightEnd = ""); - void ReportDiag(const PathDiagnostic& D); + void ReportDiag(const PathDiagnostic& D, + llvm::SmallVectorImpl *FilesMade); }; } // end anonymous namespace -HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp, - llvm::SmallVectorImpl* filesMade) +HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp) : Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false), - PP(pp), FilesMade(filesMade) { - + PP(pp) { // All html files begin with "report" FilePrefix.appendComponent("report"); } PathDiagnosticClient* -clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP, - llvm::SmallVectorImpl* FilesMade) -{ - return new HTMLDiagnostics(prefix, PP, FilesMade); -} - -//===----------------------------------------------------------------------===// -// Factory for HTMLDiagnosticClients -//===----------------------------------------------------------------------===// - -namespace { -class VISIBILITY_HIDDEN HTMLDiagnosticsFactory - : public PathDiagnosticClientFactory { - - std::string Prefix; - Preprocessor *PP; -public: - HTMLDiagnosticsFactory(const std::string& prefix, Preprocessor* pp) - : Prefix(prefix), PP(pp) {} - - virtual ~HTMLDiagnosticsFactory() {} - - const char *getName() const { return "HTMLDiagnostics"; } - - PathDiagnosticClient* - createPathDiagnosticClient(llvm::SmallVectorImpl *FilesMade) { - - return new HTMLDiagnostics(Prefix, PP, FilesMade); - } -}; -} // end anonymous namespace - -PathDiagnosticClientFactory* -clang::CreateHTMLDiagnosticClientFactory(const std::string& prefix, - Preprocessor* PP) { - return new HTMLDiagnosticsFactory(prefix, PP); +clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP) { + return new HTMLDiagnostics(prefix, PP); } //===----------------------------------------------------------------------===// @@ -131,16 +100,19 @@ void HTMLDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) { BatchedDiags.push_back(D); } -HTMLDiagnostics::~HTMLDiagnostics() { +void +HTMLDiagnostics::FlushDiagnostics(llvm::SmallVectorImpl *FilesMade) +{ while (!BatchedDiags.empty()) { const PathDiagnostic* D = BatchedDiags.back(); BatchedDiags.pop_back(); - ReportDiag(*D); + ReportDiag(*D, FilesMade); delete D; } } -void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { +void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, + llvm::SmallVectorImpl *FilesMade){ // Create the HTML directory if it is missing. if (!createdDir) { createdDir = true; -- cgit v1.2.3